use le_stream::{FromLeStream, ToLeStream};
use num_traits::FromPrimitive;
use crate::Error;
use crate::ember::{Eui64, NodeId, Status};
crate::frame::parameters::frame!(
0x0082,
{ address_table_index: u8, new_eui64: Eui64, new_id: NodeId, new_extended_timeout: bool },
impl {
impl Command {
#[must_use]
pub const fn new(
address_table_index: u8,
new_eui64: Eui64,
new_id: NodeId,
new_extended_timeout: bool,
) -> Self {
Self {
address_table_index,
new_eui64,
new_id,
new_extended_timeout,
}
}
}
},
{ status: u8, payload: PreviousEntry } => Messaging(messaging)::ReplaceAddressTableEntry,
impl {
impl TryFrom<Response> for PreviousEntry {
type Error = Error;
fn try_from(response: Response) -> Result<Self, Self::Error> {
match Status::from_u8(response.status).ok_or(response.status) {
Ok(Status::Success) => Ok(response.payload),
other => Err(other.into()),
}
}
}
}
);
#[derive(Clone, Debug, Eq, PartialEq, FromLeStream, ToLeStream)]
pub struct PreviousEntry {
eui64: Eui64,
id: NodeId,
extended_timeout: bool,
}
impl PreviousEntry {
#[must_use]
pub const fn eui64(&self) -> Eui64 {
self.eui64
}
#[must_use]
pub const fn id(&self) -> NodeId {
self.id
}
#[must_use]
pub const fn extended_timeout(&self) -> bool {
self.extended_timeout
}
}