rustix::net

Struct RecvAncillaryBuffer

Source
pub struct RecvAncillaryBuffer<'buf> { /* private fields */ }
Available on crate feature net only.
Expand description

Buffer for receiving ancillary messages with recvmsg.

Use the drain function to iterate over the received messages.

Implementations§

Source§

impl<'buf> RecvAncillaryBuffer<'buf>

Source

pub fn new(buffer: &'buf mut [u8]) -> Self

Create a new, empty RecvAncillaryBuffer from a raw byte buffer.

The buffer size may be computed with cmsg_space, or it may be zero for an empty buffer, however in that case, consider default() instead, or even using recv instead of recvmsg.

§Examples

Allocate a buffer for a single file descriptor:

let mut space = [0; rustix::cmsg_space!(ScmRights(1))];
let mut cmsg_buffer = RecvAncillaryBuffer::new(&mut space);

Allocate a buffer for credentials:

let mut space = [0; rustix::cmsg_space!(ScmCredentials(1))];
let mut cmsg_buffer = RecvAncillaryBuffer::new(&mut space);

Allocate a buffer for two file descriptors and credentials:

let mut space = [0; rustix::cmsg_space!(ScmRights(2), ScmCredentials(1))];
let mut cmsg_buffer = RecvAncillaryBuffer::new(&mut space);
Source

pub fn drain(&mut self) -> AncillaryDrain<'_>

Drain all messages from the buffer.

Trait Implementations§

Source§

impl<'buf> Default for RecvAncillaryBuffer<'buf>

Source§

fn default() -> RecvAncillaryBuffer<'buf>

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

impl Drop for RecvAncillaryBuffer<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'buf> From<&'buf mut [u8]> for RecvAncillaryBuffer<'buf>

Source§

fn from(buffer: &'buf mut [u8]) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'buf> Freeze for RecvAncillaryBuffer<'buf>

§

impl<'buf> RefUnwindSafe for RecvAncillaryBuffer<'buf>

§

impl<'buf> Send for RecvAncillaryBuffer<'buf>

§

impl<'buf> Sync for RecvAncillaryBuffer<'buf>

§

impl<'buf> Unpin for RecvAncillaryBuffer<'buf>

§

impl<'buf> !UnwindSafe for RecvAncillaryBuffer<'buf>

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.