ssp/unit_data/
command.rs

1use crate::{
2    impl_command_display, impl_command_ops, impl_default, impl_message_from_buf, impl_message_ops,
3    len::UNIT_DATA_COMMAND, CommandOps, MessageOps, MessageType,
4};
5
6/// UnitData - Command (0x0D)
7///
8/// Single byte command causes the validator to return information about itself. It is similar to
9/// the Setup Request command but a more concise version. It is intended for host machines
10/// with limited resources.
11#[repr(C)]
12#[derive(Clone, Copy, Debug, PartialEq)]
13pub struct UnitDataCommand {
14    buf: [u8; UNIT_DATA_COMMAND],
15}
16
17impl UnitDataCommand {
18    /// Creates a new [UnitDataCommand] message.
19    pub fn new() -> Self {
20        let mut msg = Self {
21            buf: [0u8; UNIT_DATA_COMMAND],
22        };
23
24        msg.init();
25        msg.set_command(MessageType::UnitData);
26
27        msg
28    }
29}
30
31impl_default!(UnitDataCommand);
32impl_command_display!(UnitDataCommand);
33impl_message_from_buf!(UnitDataCommand);
34impl_message_ops!(UnitDataCommand);
35impl_command_ops!(UnitDataCommand);