Actually implement fill_info in a way that compiles. ^^'

This commit is contained in:
Gregor Reitzenstein 2020-12-16 12:49:56 +01:00
parent cfa71f8be2
commit a279a2ed48
2 changed files with 16 additions and 8 deletions

View File

@ -1,4 +1,5 @@
use std::sync::Arc; use std::sync::Arc;
use std::ops::Deref;
use capnp::capability::Promise; use capnp::capability::Promise;
use capnp::Error; use capnp::Error;
@ -28,29 +29,32 @@ impl Machine {
// TODO set all the others // TODO set all the others
} }
pub async fn fill_info(&self, builder: &mut m_info::Builder) { pub async fn fill_info(&self, builder: &mut m_info::Builder<'_>) {
let guard = self.machine.lock().await; let guard = self.machine.lock().await;
builder.set_name(guard.desc.name.as_ref()); builder.set_name(guard.desc.name.as_ref());
builder.set_description(guard.desc.description.as_ref());
match guard.state.read_only().lock_ref().status { if let Some(desc) = guard.desc.description.as_ref() {
builder.set_description(desc);
}
match guard.read_state().lock_ref().deref().state {
Status::Free => { Status::Free => {
builder.set_state(State::Free); builder.set_state(State::Free);
} }
Status::Disabled => { Status::Disabled => {
builder.set_state(State::Disabled); builder.set_state(State::Disabled);
} }
Status::Blocked(who, prio) => { Status::Blocked(_,_) => {
builder.set_state(State::Blocked); builder.set_state(State::Blocked);
} }
Status::InUse(who, prio) => { Status::InUse(_,_) => {
builder.set_state(State::InUse); builder.set_state(State::InUse);
} }
Status::ToCheck(who, prio) => { Status::ToCheck(_,_) => {
builder.set_state(State::ToCheck); builder.set_state(State::ToCheck);
} }
Status::Reserved(who, prio) => { Status::Reserved(_,_) => {
builder.set_state(State::Reserved); builder.set_state(State::Reserved);
} }
} }

View File

@ -14,7 +14,7 @@ use serde::{Serialize, Deserialize};
use futures_signals::signal::Signal; use futures_signals::signal::Signal;
use futures_signals::signal::SignalExt; use futures_signals::signal::SignalExt;
use futures_signals::signal::Mutable; use futures_signals::signal::{Mutable, ReadOnlyMutable};
use uuid::Uuid; use uuid::Uuid;
@ -172,6 +172,10 @@ impl Inner {
return Ok(tx); return Ok(tx);
} }
pub fn read_state(&self) -> ReadOnlyMutable<MachineState> {
self.state.read_only()
}
pub fn get_signal(&self) -> impl Signal { pub fn get_signal(&self) -> impl Signal {
self.state.signal_cloned() self.state.signal_cloned()
} }