Start to build sync route
This commit is contained in:
@ -238,3 +238,28 @@ impl Handler<DeleteDeviceRelay> for EnergyActor {
|
||||
self.devices.relay_delete(msg.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
pub struct RelaySyncStatus {
|
||||
enabled: bool,
|
||||
}
|
||||
|
||||
/// Synchronize a device
|
||||
#[derive(Message)]
|
||||
#[rtype(result = "anyhow::Result<Vec<RelaySyncStatus>>")]
|
||||
pub struct SynchronizeDevice(pub DeviceId, pub DeviceInfo);
|
||||
|
||||
impl Handler<SynchronizeDevice> for EnergyActor {
|
||||
type Result = anyhow::Result<Vec<RelaySyncStatus>>;
|
||||
|
||||
fn handle(&mut self, msg: SynchronizeDevice, _ctx: &mut Context<Self>) -> Self::Result {
|
||||
// TODO : implement real code
|
||||
let mut v = vec![];
|
||||
for i in 0..msg.1.max_relays {
|
||||
v.push(RelaySyncStatus {
|
||||
enabled: i % 2 == 0,
|
||||
});
|
||||
}
|
||||
Ok(v)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user