shared_mem_queue::msg_queue

Struct MsgQueue

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

An abstraction for interpreting messages based on a specific format, using ByteQueue as the underlying communication mechanism.

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 nb_read_msg(&mut self) -> Result<&[u8], MsgQueueError>

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 blocking_read_msg(&mut self) -> Result<&[u8], MsgQueueError>

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

source

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

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

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

source

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

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

Returns an error if the message is too large to fit into the receive 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.