Skip to main content

ezsp/frame/parameters/bootloader/
launch_standalone_bootloader.rs

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