Can delete a pending device

This commit is contained in:
2024-07-03 21:10:15 +02:00
parent 716af6219a
commit 2502ed6bcf
6 changed files with 120 additions and 9 deletions

View File

@ -94,6 +94,22 @@ impl Handler<EnrollDevice> for EnergyActor {
}
}
/// Delete a device
#[derive(Message)]
#[rtype(result = "anyhow::Result<()>")]
pub struct DeleteDevice(pub DeviceId);
impl Handler<DeleteDevice> for EnergyActor {
type Result = anyhow::Result<()>;
fn handle(&mut self, msg: DeleteDevice, _ctx: &mut Context<Self>) -> Self::Result {
log::info!("Requested to delete device {:?}...", &msg.0);
self.devices.delete(&msg.0)?;
// TODO : delete energy related information
Ok(())
}
}
/// Get the list of devices
#[derive(Message)]
#[rtype(result = "Vec<Device>")]