Struct xsens_mti::message::Frame

source ·
pub struct Frame<T: AsRef<[u8]>> { /* private fields */ }

Implementations§

source§

impl<T: AsRef<[u8]>> Frame<T>

source

pub const PREAMBLE: u8 = 250u8

source

pub const STD_LEN_IS_EXT: u8 = 255u8

source

pub const HEADER_SIZE: usize = 4usize

source

pub const EXT_HEADER_SIZE: usize = 6usize

source

pub const PREAMBLE_SIZE: usize = 1usize

source

pub const EXT_LEN_SIZE: usize = 2usize

source

pub const CHECKSUM_SIZE: usize = 1usize

source

pub const MAX_FRAME_SIZE: usize = 2_055usize

source

pub fn new_unchecked(buffer: T) -> Frame<T>

source

pub fn new(buffer: T) -> Result<Frame<T>, FrameError>

source

pub fn check_len(&self) -> Result<(), FrameError>

source

pub fn check_preamble(&self) -> Result<(), FrameError>

source

pub fn check_payload_length(&self) -> Result<(), FrameError>

source

pub fn check_checksum(&self) -> Result<(), FrameError>

source

pub fn into_inner(self) -> T

source

pub fn header_len() -> usize

Return the length of a message header.

Does not include extended length, payload or checksum byte.

source

pub fn buffer_len(n_payload_bytes: usize) -> usize

Return the length of a buffer required to hold a message with a payload length of n_payload_bytes + CHECKSUM_SIZE.

source

pub fn preamble(&self) -> u8

source

pub fn bus_id(&self) -> BusId

source

pub fn message_id(&self) -> MessageId

source

pub fn payload_length(&self) -> Result<PayloadLength, FrameError>

source

pub fn checksum(&self) -> Result<u8, FrameError>

Return the checksum byte.

source

pub fn compute_checksum_byte(&self) -> Result<u8, FrameError>

Compute the checksum byte value such that Self::compute_checksum() will return zero.

Excludes the preamble and current checksum byte.

source

pub fn compute_checksum(&self) -> Result<u8, FrameError>

Compute the checksum of all bytes excluding the preamble.

If the result equals zero, the message is valid and it may be processed.

source§

impl<'a, T: AsRef<[u8]> + ?Sized> Frame<&'a T>

source

pub fn payload(&self) -> Result<&'a [u8], FrameError>

Return a pointer to the payload.

Does not include the checksum byte.

source§

impl<T: AsRef<[u8]> + AsMut<[u8]>> Frame<T>

source

pub fn set_preamble(&mut self)

source

pub fn set_bus_id(&mut self, value: BusId)

source

pub fn set_message_id(&mut self, value: MessageId)

source

pub fn set_payload_length(&mut self, value: PayloadLength)

source

pub fn payload_mut(&mut self) -> Result<&mut [u8], FrameError>

Return a mutable pointer to the payload.

Does not include the checksum byte.

source

pub fn set_checksum(&mut self, value: u8) -> Result<(), FrameError>

Trait Implementations§

source§

impl<T: AsRef<[u8]>> AsRef<[u8]> for Frame<T>

source§

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

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T: Clone + AsRef<[u8]>> Clone for Frame<T>

source§

fn clone(&self) -> Frame<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug + AsRef<[u8]>> Debug for Frame<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: AsRef<[u8]>> Display for Frame<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for Frame<T>
where T: RefUnwindSafe,

§

impl<T> Send for Frame<T>
where T: Send,

§

impl<T> Sync for Frame<T>
where T: Sync,

§

impl<T> Unpin for Frame<T>
where T: Unpin,

§

impl<T> UnwindSafe for Frame<T>
where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.