pub enum DeviceMessage {
Ok(OkPayload),
Err(ErrorCode),
Rx(RxPayload),
TxDone(TxDonePayload),
}Expand description
Any device→host message, parsed into its semantic form.
Variants§
Implementations§
Source§impl DeviceMessage
impl DeviceMessage
pub const fn type_id(&self) -> u8
Sourcepub fn encode_payload(
&self,
buf: &mut [u8],
) -> Result<usize, DeviceMessageEncodeError>
pub fn encode_payload( &self, buf: &mut [u8], ) -> Result<usize, DeviceMessageEncodeError>
Encode the device-message payload (bytes between frame header and
CRC) into buf. Returns the number of bytes written.
Sourcepub fn parse(
type_id: u8,
payload: &[u8],
originating_cmd_type: Option<u8>,
) -> Result<Self, DeviceMessageParseError>
pub fn parse( type_id: u8, payload: &[u8], originating_cmd_type: Option<u8>, ) -> Result<Self, DeviceMessageParseError>
Parse a (type_id, payload) pair.
originating_cmd_type MUST be supplied for OK frames: it is
the type_id of the H→D command whose tag the host observed
echoed back. For all other device-message types it is ignored
(pass None).
Trait Implementations§
Source§impl Clone for DeviceMessage
impl Clone for DeviceMessage
Source§fn clone(&self) -> DeviceMessage
fn clone(&self) -> DeviceMessage
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DeviceMessage
impl Debug for DeviceMessage
Source§impl Format for DeviceMessage
impl Format for DeviceMessage
Source§impl PartialEq for DeviceMessage
impl PartialEq for DeviceMessage
impl Eq for DeviceMessage
impl StructuralPartialEq for DeviceMessage
Auto Trait Implementations§
impl Freeze for DeviceMessage
impl RefUnwindSafe for DeviceMessage
impl Send for DeviceMessage
impl Sync for DeviceMessage
impl Unpin for DeviceMessage
impl UnsafeUnpin for DeviceMessage
impl UnwindSafe for DeviceMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more