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§
Provided Methods§
Sourcefn set_acknak(&mut self, acknak: AckNak)
fn set_acknak(&mut self, acknak: AckNak)
Set the ACKNAK control field.
Sourcefn switch_acknak(&mut self)
fn switch_acknak(&mut self)
Switches the current ACKNAK control field value.
Sourcefn device_type(&self) -> DeviceType
fn device_type(&self) -> DeviceType
Get the device type control field.
Sourcefn set_device_type(&mut self, device_type: DeviceType)
fn set_device_type(&mut self, device_type: DeviceType)
Set the device type control field
Sourcefn message_type(&self) -> MessageType
fn message_type(&self) -> MessageType
Get the message type control field
Sourcefn set_message_type(&mut self, message_type: MessageType)
fn set_message_type(&mut self, message_type: MessageType)
Set the message type control field
Sourcefn checksum(&self) -> u8
fn checksum(&self) -> u8
Get the current checksum value
Note: to ensure validity, call calculate_checksum first
fn checksum_bytes(&self) -> &[u8] ⓘ
Sourcefn calculate_checksum(&mut self) -> u8
fn calculate_checksum(&mut self) -> u8
Calculate the message checksum
Sourcefn validate_checksum(&self) -> Result<()>
fn validate_checksum(&self) -> Result<()>
Validate the message checksum
Calculates the checksum of the buffer, and checks for a match against the current checksum.
Sourcefn as_bytes(&mut self) -> &[u8] ⓘ
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
Sourcefn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Get a mutable reference to the byte buffer
Sourcefn as_bytes_unchecked(&self) -> &[u8] ⓘ
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.