Struct MsgQueue

Source
pub struct MsgQueue<'a, const LEN: usize> { /* private fields */ }
Expand description

The MsgQueue queue type using ByteQueue as the underlying communication mechanism. Read the crate and module documentation for further information and usage examples.

Implementations§

Source§

impl<'a, const LEN: usize> MsgQueue<'a, LEN>

Source

pub fn new(byte_queue: ByteQueue, prefix: &'a [u8], rx_buf: [u8; LEN]) -> Self

Initializes a message queue for interpreting messages with the specified prefix, using the provided rx_buf as storage for incoming messages. The size of rx_buf determines how many messages can be stored before they need to be consumed or read.

Source

pub fn read_or_fail(&mut self) -> Result<&[u8], MqError>

Attempts to read a message from the queue in non-blocking mode.

Returns a slice of the message data or an error if no complete message is available.

Source

pub fn read_blocking(&mut self) -> Result<&[u8], MqError>

Attempts to read a message, blocking until a message is successfully read or an error occurs.

Source

pub fn write_or_fail(&mut self, msg_data: &[u8]) -> Result<(), MqError>

Attempts to write a message to the queue in non-blocking mode.

Returns an error if the message is too large to fit into the ByteQueue buffer (MqMsgTooBig), or if there is insufficient space in the ByteQueue (MqFull). Otherwise, the message is written successfully.

Source

pub fn write_blocking(&mut self, msg_data: &[u8]) -> Result<(), MqError>

Writes a message to the queue in blocking mode.

Returns an error if the message is too large to fit into the ByteQueue buffer (MqMsgTooBig). If there is insufficient space in the ByteQueue, this function will block until space becomes available. Once space is available, the message is written successfully.

Trait Implementations§

Source§

impl<'a, const LEN: usize> Debug for MsgQueue<'a, LEN>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, const LEN: usize> Freeze for MsgQueue<'a, LEN>

§

impl<'a, const LEN: usize> RefUnwindSafe for MsgQueue<'a, LEN>

§

impl<'a, const LEN: usize> Send for MsgQueue<'a, LEN>

§

impl<'a, const LEN: usize> !Sync for MsgQueue<'a, LEN>

§

impl<'a, const LEN: usize> Unpin for MsgQueue<'a, LEN>

§

impl<'a, const LEN: usize> UnwindSafe for MsgQueue<'a, LEN>

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.