Complete enroll route
This commit is contained in:
@ -1,9 +1,10 @@
|
||||
use crate::constants;
|
||||
use crate::devices::device::DeviceId;
|
||||
use crate::devices::device::{DeviceId, DeviceInfo};
|
||||
use crate::devices::devices_list::DevicesList;
|
||||
use crate::energy::consumption;
|
||||
use crate::energy::consumption::EnergyConsumption;
|
||||
use actix::prelude::*;
|
||||
use openssl::x509::X509Req;
|
||||
|
||||
pub struct EnergyActor {
|
||||
curr_consumption: EnergyConsumption,
|
||||
@ -79,3 +80,16 @@ impl Handler<CheckDeviceExists> for EnergyActor {
|
||||
self.devices.exists(&msg.0)
|
||||
}
|
||||
}
|
||||
|
||||
/// Enroll device
|
||||
#[derive(Message)]
|
||||
#[rtype(result = "anyhow::Result<()>")]
|
||||
pub struct EnrollDevice(pub DeviceId, pub DeviceInfo, pub X509Req);
|
||||
|
||||
impl Handler<EnrollDevice> for EnergyActor {
|
||||
type Result = anyhow::Result<()>;
|
||||
|
||||
fn handle(&mut self, msg: EnrollDevice, _ctx: &mut Context<Self>) -> Self::Result {
|
||||
self.devices.enroll(&msg.0, &msg.1, &msg.2)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user