Skip to main content

UnixDatagramExt

Trait UnixDatagramExt 

Source
pub trait UnixDatagramExt {
    // Required methods
    fn send_fds(&self, data: &[u8], fds: &[impl AsFd]) -> Result<usize>;
    fn recv_fds<const N: usize>(&self) -> Result<ReceivedFds>;
    fn recv_fds_into<const N: usize>(
        &self,
        data_buf: &mut [u8],
    ) -> Result<(usize, Vec<OwnedFd>)>;
}
Expand description

Extension trait for UnixDatagram adding fd-passing convenience methods.

Required Methods§

Source

fn send_fds(&self, data: &[u8], fds: &[impl AsFd]) -> Result<usize>

Send data plus borrowed fds. The socket must be connected.

Source

fn recv_fds<const N: usize>(&self) -> Result<ReceivedFds>

Receive data and up to N fds.

Allocates an internal 64 KiB data buffer plus an oversized cmsg buffer that prevents kernel-level fd leaks. Surplus fds beyond N are closed automatically.

Source

fn recv_fds_into<const N: usize>( &self, data_buf: &mut [u8], ) -> Result<(usize, Vec<OwnedFd>)>

Like recv_fds but writes data into a caller-supplied buffer. Returns (bytes_read, fds).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl UnixDatagramExt for UnixDatagram

Source§

fn send_fds(&self, data: &[u8], fds: &[impl AsFd]) -> Result<usize>

Source§

fn recv_fds<const N: usize>(&self) -> Result<ReceivedFds>

Source§

fn recv_fds_into<const N: usize>( &self, data_buf: &mut [u8], ) -> Result<(usize, Vec<OwnedFd>)>

Implementors§