Skip to main content

ezsp/frame/parameters/messaging/
set_address_table_remote_eui64.rs

1//! Parameters for the [`Messaging::set_address_table_remote_eui64`](crate::Messaging::set_address_table_remote_eui64) command.
2
3use num_traits::FromPrimitive;
4
5use crate::Error;
6use crate::ember::{Eui64, Status};
7
8crate::frame::parameters::frame!(
9    0x005C,
10    { address_table_index: u8, eui64: Eui64 },
11    impl {
12        impl Command {
13            /// Creates command parameters.
14            #[must_use]
15            pub const fn new(address_table_index: u8, eui64: Eui64) -> Self {
16                Self {
17                    address_table_index,
18                    eui64,
19                }
20            }
21        }
22    },
23    { status: u8 } => Messaging(messaging)::SetAddressTableRemoteEui64,
24    impl {
25        /// Converts the response into `()` or an appropriate [`Error`] depending on its status.
26        impl TryFrom<Response> for () {
27            type Error = Error;
28
29            fn try_from(response: Response) -> Result<Self, Self::Error> {
30                match Status::from_u8(response.status).ok_or(response.status) {
31                    Ok(Status::Success) => Ok(()),
32                    other => Err(other.into()),
33                }
34            }
35        }
36    }
37);