pub struct SendAncillaryBuffer<'buf, 'slice, 'fd> { /* private fields */ }
Expand description

Buffer for sending ancillary messages with sendmsg, sendmsg_v4, sendmsg_v6, sendmsg_unix, and sendmsg_any.

Use the push function to add messages to send.

Implementations§

source§

impl<'buf, 'slice, 'fd> SendAncillaryBuffer<'buf, 'slice, 'fd>

source

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

Create a new, empty SendAncillaryBuffer 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 send instead of sendmsg.

Examples

Allocate a buffer for a single file descriptor:

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

Allocate a buffer for credentials:

let mut space = [0; rustix::cmsg_space!(ScmCredentials(1))];
let mut cmsg_buffer = SendAncillaryBuffer::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 = SendAncillaryBuffer::new(&mut space);
source

pub fn clear(&mut self)

Delete all messages from the buffer.

source

pub fn push(&mut self, msg: SendAncillaryMessage<'slice, 'fd>) -> bool

Add an ancillary message to the buffer.

Returns true if the message was added successfully.

Trait Implementations§

source§

impl Default for SendAncillaryBuffer<'_, '_, '_>

source§

fn default() -> Self

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

impl<'slice, 'fd> Extend<SendAncillaryMessage<'slice, 'fd>> for SendAncillaryBuffer<'_, 'slice, 'fd>

source§

fn extend<T: IntoIterator<Item = SendAncillaryMessage<'slice, 'fd>>>( &mut self, iter: T )

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl<'buf> From<&'buf mut [u8]> for SendAncillaryBuffer<'buf, '_, '_>

source§

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

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'buf, 'slice, 'fd> RefUnwindSafe for SendAncillaryBuffer<'buf, 'slice, 'fd>

§

impl<'buf, 'slice, 'fd> Send for SendAncillaryBuffer<'buf, 'slice, 'fd>

§

impl<'buf, 'slice, 'fd> Sync for SendAncillaryBuffer<'buf, 'slice, 'fd>

§

impl<'buf, 'slice, 'fd> Unpin for SendAncillaryBuffer<'buf, 'slice, 'fd>

§

impl<'buf, 'slice, 'fd> !UnwindSafe for SendAncillaryBuffer<'buf, 'slice, 'fd>

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>,

§

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>,

§

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.