Skip to main content

ezsp/frame/parameters/binding/
set.rs

1//! Parameters for the [`Binding::set_binding`](crate::Binding::set) command.
2
3use num_traits::FromPrimitive;
4
5use crate::Error;
6use crate::ember::Status;
7use crate::ember::binding::TableEntry;
8
9crate::frame::parameters::frame!(
10    0x002B,
11    { index: u8, value: TableEntry },
12    impl {
13        impl Command {
14            /// Creates command parameters.
15            #[must_use]
16            pub const fn new(index: u8, value: TableEntry) -> Self {
17                Self { index, value }
18            }
19        }
20    },
21    { status: u8 } => Binding(binding)::Set,
22    impl {
23        /// Convert the response into a [`Result<()>`](crate::Result) by evaluating its status field.
24        impl TryFrom<Response> for () {
25            type Error = Error;
26
27            fn try_from(response: Response) -> Result<Self, Self::Error> {
28                match Status::from_u8(response.status).ok_or(response.status) {
29                    Ok(Status::Success) => Ok(()),
30                    other => Err(other.into()),
31                }
32            }
33        }
34    }
35);