Skip to main content

ezsp/frame/parameters/networking/
leave_network.rs

1//! Parameters for the [`Networking::leave_network`](crate::Networking::leave_network) command.
2
3use num_traits::FromPrimitive;
4
5use crate::Error;
6use crate::ember::Status;
7
8crate::frame::parameters::frame!(
9    0x0020,
10    {},
11    { status: u8 } => Networking(networking)::LeaveNetwork,
12    impl {
13        /// Convert a response into `()` or an appropriate [`Error`] depending on its status.
14        impl TryFrom<Response> for () {
15            type Error = Error;
16
17            fn try_from(response: Response) -> Result<Self, Self::Error> {
18                match Status::from_u8(response.status).ok_or(response.status) {
19                    Ok(Status::Success) => Ok(()),
20                    other => Err(other.into()),
21                }
22            }
23        }
24    }
25);