Struct Message

Source
#[repr(C)]
pub struct Message { pub mtype: i64, pub mtext: [u8; 65536], }
Expand description

This struct represents a message that is inserted into a message queue on every MessageQueue::send() call.

It follows the SysV message recipe of having only two fields, namely:

  • mtype: i64 - which is the type of a message, it can be used for filtering within queues and should never be a negative integer. u64 isn’t used here, however, because of the kernel’s anticipated internal representation
  • mtext - which is where the data of the message are stored. The kernel doesn’t care about what mtext is so long as it is not a pointer (because pointers are a recipe for trouble when passing the interprocess boundary). Therefore it can be either a struct or an array. Here, an array of 8K bytes was chosen to allow the maximum versatility within the default message size limit (8KiB). In the future, functionality to affect the limit shall be exposed and bigger messages will be allowed

Messages are required to be #[repr(C)] to avoid unexpected surprises.

Finally, due to the size of a Message, it is unwise to store them on the stack. On Arch x86_64, the default stack size is 8mb, which is just enough for less than a thousand messages. Use Box instead.

Fields§

§mtype: i64

This should be a positive integer. For normal usage, it is inconsequential, but you may want to use it for filtering.

In fact, if you are looking for messages with a specific type, the msgtyp parameter of msgrcv() might be of use to you.

Check out its documentation for more info.

§mtext: [u8; 65536]

This is a simple byte array. The ‘standard’ allows for mtext to be either a structure or an array. For the purposes of ipc-rs, array is the better choice.

Currently, the data is stored as CBOR, the more efficient byte JSON. Check out the documentation of serde_cbor.

Auto Trait Implementations§

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.