Trait MessageOps

Source
pub trait MessageOps {
Show 23 methods // Required methods fn buf(&self) -> &[u8] ; fn buf_mut(&mut self) -> &mut [u8] ; // Provided methods fn init(&mut self) { ... } fn len(&self) -> usize { ... } fn is_empty(&self) -> bool { ... } fn data_len(&self) -> usize { ... } fn etx_index(&self) -> usize { ... } fn chk_index(&self) -> usize { ... } fn acknak(&self) -> AckNak { ... } fn set_acknak(&mut self, acknak: AckNak) { ... } fn switch_acknak(&mut self) { ... } fn device_type(&self) -> DeviceType { ... } fn set_device_type(&mut self, device_type: DeviceType) { ... } fn message_type(&self) -> MessageType { ... } fn set_message_type(&mut self, message_type: MessageType) { ... } fn checksum(&self) -> u8 { ... } fn checksum_bytes(&self) -> &[u8] { ... } fn calculate_checksum(&mut self) -> u8 { ... } fn validate_checksum(&self) -> Result<()> { ... } fn as_bytes(&mut self) -> &[u8] { ... } fn as_bytes_mut(&mut self) -> &mut [u8] { ... } fn as_bytes_unchecked(&self) -> &[u8] { ... } fn from_buf(&mut self, buf: &[u8]) -> Result<()> { ... }
}
Expand description

Generic functions for all EBDS message types

Required Methods§

Source

fn buf(&self) -> &[u8]

Get a reference to the message buffer.

Source

fn buf_mut(&mut self) -> &mut [u8]

Get a mutable reference to the message buffer.

Provided Methods§

Source

fn init(&mut self)

Initialize common message fields

Source

fn len(&self) -> usize

Get the length of the entire message.

Source

fn is_empty(&self) -> bool

Gets whether the message buffer is empty (all zeros)

Source

fn data_len(&self) -> usize

Get the length of data bytes.

Source

fn etx_index(&self) -> usize

Get the ETX index.

Source

fn chk_index(&self) -> usize

Get the checksum index.

Source

fn acknak(&self) -> AckNak

Get the ACKNAK control field.

Source

fn set_acknak(&mut self, acknak: AckNak)

Set the ACKNAK control field.

Source

fn switch_acknak(&mut self)

Switches the current ACKNAK control field value.

Source

fn device_type(&self) -> DeviceType

Get the device type control field.

Source

fn set_device_type(&mut self, device_type: DeviceType)

Set the device type control field

Source

fn message_type(&self) -> MessageType

Get the message type control field

Source

fn set_message_type(&mut self, message_type: MessageType)

Set the message type control field

Source

fn checksum(&self) -> u8

Get the current checksum value

Note: to ensure validity, call calculate_checksum first

Source

fn checksum_bytes(&self) -> &[u8]

Source

fn calculate_checksum(&mut self) -> u8

Calculate the message checksum

Source

fn validate_checksum(&self) -> Result<()>

Validate the message checksum

Calculates the checksum of the buffer, and checks for a match against the current checksum.

Source

fn as_bytes(&mut self) -> &[u8]

Get the message as a byte buffer

Note: calculates the checksum, and sets the checksum byte.

To get the buffer without calculating the checksum, use as_bytes_unchecked

Source

fn as_bytes_mut(&mut self) -> &mut [u8]

Get a mutable reference to the byte buffer

Source

fn as_bytes_unchecked(&self) -> &[u8]

Get the message as a byte buffer

Note: does not perform checksum calculation, caller must call calculate_checksum prior to calling this function.

Source

fn from_buf(&mut self, buf: &[u8]) -> Result<()>

Deserializes a message type from a byte buffer.

Returns Ok(()) on success, and Err(_) for an invalid buffer.

Implementors§

Source§

impl MessageOps for AdvancedBookmarkModeCommand

Source§

impl MessageOps for AdvancedBookmarkModeReply

Source§

impl MessageOps for ClearAuditDataRequest

Source§

impl MessageOps for ClearAuditDataRequestAck

Source§

impl MessageOps for ClearAuditDataRequestResults

Source§

impl MessageOps for ExtendedNoteInhibitsReplyAlt

Source§

impl MessageOps for ExtendedNoteReply

Source§

impl MessageOps for QueryExtendedNoteSpecification

Source§

impl MessageOps for BaudRateChangeReply

Source§

impl MessageOps for BaudRateChangeRequest

Source§

impl MessageOps for FlashDownloadMessage7bit

Source§

impl MessageOps for FlashDownloadMessage8bit_32

Source§

impl MessageOps for FlashDownloadMessage8bit_64

Source§

impl MessageOps for FlashDownloadReply7bit

Source§

impl MessageOps for FlashDownloadReply8bit

Source§

impl MessageOps for StartDownloadCommand

Source§

impl MessageOps for StartDownloadReply

Source§

impl MessageOps for NoteRetrievedCommand

Source§

impl MessageOps for NoteRetrievedEvent

Source§

impl MessageOps for NoteRetrievedReply

Source§

impl MessageOps for OmnibusCommand

Source§

impl MessageOps for OmnibusReply

Source§

impl MessageOps for QueryApplicationIdCommand

Source§

impl MessageOps for QueryApplicationIdReply

Source§

impl MessageOps for QueryApplicationPartNumberCommand

Source§

impl MessageOps for QueryApplicationPartNumberReply

Source§

impl MessageOps for QueryBootPartNumberCommand

Source§

impl MessageOps for QueryBootPartNumberReply

Source§

impl MessageOps for QueryDeviceCapabilitiesCommand

Source§

impl MessageOps for QueryDeviceCapabilitiesReply

Source§

impl MessageOps for QuerySoftwareCrcCommand

Source§

impl MessageOps for QuerySoftwareCrcReply

Source§

impl MessageOps for QueryValueTableCommand

Source§

impl MessageOps for QueryValueTableReply

Source§

impl MessageOps for QueryVariantIdCommand

Source§

impl MessageOps for QueryVariantIdReply

Source§

impl MessageOps for QueryVariantNameCommand

Source§

impl MessageOps for QueryVariantNameReply

Source§

impl MessageOps for QueryVariantPartNumberCommand

Source§

impl MessageOps for QueryVariantPartNumberReply

Source§

impl MessageOps for SetEscrowTimeoutCommand

Source§

impl MessageOps for SetEscrowTimeoutReply

Source§

impl MessageOps for SoftReset

Source§

impl<const M: usize, const N: usize> MessageOps for SetExtendedNoteInhibits<M, N>