[go: up one dir, main page]

Struct MessageBuf

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

A buffer for receiving messages from a channel.

A MessageBuf is essentially a byte buffer and a vector of handles, but move semantics for “taking” handles requires special handling.

Note that for sending messages to a channel, the caller manages the buffers, using a plain byte slice and Vec<Handle>.

Implementations§

Source§

impl MessageBuf

Source

pub fn new() -> Self

Create a new, empty, message buffer.

Source

pub fn ensure_capacity_bytes(&mut self, n_bytes: usize)

Ensure that the buffer has the capacity to hold at least n_bytes bytes.

Source

pub fn ensure_capacity_handles(&mut self, n_handles: usize)

Ensure that the buffer has the capacity to hold at least n_handles handles.

Source

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

Get a reference to the bytes of the message buffer, as a &[u8] slice.

Source

pub fn n_handles(&self) -> usize

The number of handles in the message buffer. Note this counts the number available when the message was received; take_handle does not affect the count.

Source

pub fn take_handle(&mut self, index: usize) -> Option<Handle>

Take the handle at the specified index from the message buffer. If the method is called again with the same index, it will return None, as will happen if the index exceeds the number of handles available.

Trait Implementations§

Source§

impl Debug for MessageBuf

Source§

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

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

impl Default for MessageBuf

Source§

fn default() -> MessageBuf

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

impl Drop for MessageBuf

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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.