UnixFdStream

Struct UnixFdStream 

Source
pub struct UnixFdStream<T: AsRawFd> { /* private fields */ }
Expand description

A wrapper around a UnixStream that allows file descriptors to be sent and received with messages. Implements AsyncRead and AsyncWrite such that standard asynchronous reading and writing operations and helpers may be used.

Implementations§

Source§

impl<T: AsRawFd + NonBlocking> UnixFdStream<T>

Source

pub fn new(unix: T, max_read_fds: usize) -> Result<Self>

Create a new UnixFdStream from a UnixStream which is also configured to read up to max_read_fds for each read from the socket.

The file descriptors that are transferred are buffered in a Vec<RawFd>, but only so many will have space made for them in the receiving header as configured by max_read_fds, other file descriptors sent beyond this limit will be discarded by the kernel. We do not check for the MSG_CTRUNC flag, therefore this will be a silent discard.

Source§

impl<T: AsRawFd> UnixFdStream<T>

Source

pub fn split<'a>(&'a mut self) -> (ReadHalf<'a, T>, WriteHalf<'a, T>)

Source

pub fn into_split(self) -> (OwnedReadHalf<T>, OwnedWriteHalf<T>)

Source

pub fn push_outgoing_fd<F: IntoRawFd>(&self, fd: F)

Push a file descriptor to be written with the next message that is written to this stream. The ownership is transferred and the file descriptor is either closed when the message is sent or this instance is dropped.

Source

pub async fn readable(&self) -> Result<()>

Wait for the underlying UnixStream to become readable.

Source

pub fn pop_incoming_fd(&self) -> Option<RawFd>

Get the most recent file descriptor that was read with a message.

Source

pub fn incoming_count(&self) -> usize

Get the number of file descriptors in the incoming queue.

Trait Implementations§

Source§

impl<T: AsRawFd> AsyncRead for UnixFdStream<T>

Source§

fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<Result<()>>

Attempts to read from the AsyncRead into buf. Read more
Source§

impl<T: AsRawFd + Shutdown + Unpin> AsyncWrite for UnixFdStream<T>

Source§

fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>

Attempt to write bytes from buf into the object. Read more
Source§

fn poll_flush( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>

Attempts to flush the object, ensuring that any buffered data reach their destination. Read more
Source§

fn poll_shutdown( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>

Initiates or attempts to shut down this writer, returning success when the I/O connection has completely shut down. Read more
Source§

fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>

Like poll_write, except that it writes from a slice of buffers. Read more
Source§

fn is_write_vectored(&self) -> bool

Determines if this writer has an efficient poll_write_vectored implementation. Read more
Source§

impl<T: AsRawFd> Drop for UnixFdStream<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> !Freeze for UnixFdStream<T>

§

impl<T> !RefUnwindSafe for UnixFdStream<T>

§

impl<T> Send for UnixFdStream<T>
where T: Send,

§

impl<T> Sync for UnixFdStream<T>
where T: Sync,

§

impl<T> Unpin for UnixFdStream<T>
where T: Unpin,

§

impl<T> !UnwindSafe for UnixFdStream<T>

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.