use le_stream::{FromLeStream, ToLeStream};
use num_traits::FromPrimitive;
use crate::ember::node::Type;
use crate::ember::types::{Eui64, NodeId};
#[derive(Clone, Debug, Eq, PartialEq, FromLeStream, ToLeStream)]
pub struct Data {
eui64: Eui64,
typ: u8,
id: NodeId,
phy: u8,
power: u8,
timeout: u8,
}
impl Data {
#[must_use]
pub fn new(eui64: Eui64, typ: Type, id: NodeId, phy: u8, power: u8, timeout: u8) -> Self {
Self {
eui64,
typ: typ.into(),
id,
phy,
power,
timeout,
}
}
#[must_use]
pub const fn eui64(&self) -> Eui64 {
self.eui64
}
#[must_use]
pub fn typ(&self) -> Option<Type> {
Type::from_u8(self.typ)
}
#[must_use]
pub const fn id(&self) -> NodeId {
self.id
}
#[must_use]
pub const fn phy(&self) -> u8 {
self.phy
}
#[must_use]
pub const fn power(&self) -> u8 {
self.power
}
#[must_use]
pub const fn timeout(&self) -> u8 {
self.timeout
}
}