SerMsg

Struct SerMsg 

Source
pub struct SerMsg { /* private fields */ }
Expand description

Struct that implements all the functionality of this crate

Implementations§

Source§

impl SerMsg

Source

pub fn new() -> SerMsg

Returns a new SerMsg instance for parsing read data

Source

pub fn return_read_data(&self) -> &[u8]

Returns the data of the parsed message, should only be used after the ParseState is DataReady

Source

pub fn return_msg_id(&self) -> u8

Returns the id of the parsed message, should only be used after the ParseState is DataReady

Source

pub fn create_msg_arr(data: &[u8], id: u8) -> Option<([u8; 260], usize)>

no_std function to create a message. Packs the slice into the message format and returns an array with a fixed length of the maximum message size and the last index of the relevant bytes in the array. Returns None if the input slice exceeds the maximum supported length of 254 bytes.

Source

pub fn parse_read_bytes(&mut self, arr: &[u8]) -> (ParseState, usize)

Parses the bytes of the input slice. Returns a ParseState and the amount of bytes parsed when an error occured, a complete message was parsed or when all bytes were read.

Source§

impl SerMsg

Source

pub fn create_msg_vec(data: &[u8], id: u8) -> Option<Vec<u8>>

Packs the slice into the message format and returns a Vector containing the message bytes. Returns None if the input slice exceeds the maximum supported length of 254 bytes.

Trait Implementations§

Source§

impl Default for SerMsg

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for SerMsg

§

impl RefUnwindSafe for SerMsg

§

impl Send for SerMsg

§

impl Sync for SerMsg

§

impl Unpin for SerMsg

§

impl UnwindSafe for SerMsg

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>,

Source§

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>,

Source§

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.