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>
impl<T: AsRawFd + NonBlocking> UnixFdStream<T>
Sourcepub fn new(unix: T, max_read_fds: usize) -> Result<Self>
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>
impl<T: AsRawFd> UnixFdStream<T>
pub fn split<'a>(&'a mut self) -> (ReadHalf<'a, T>, WriteHalf<'a, T>)
pub fn into_split(self) -> (OwnedReadHalf<T>, OwnedWriteHalf<T>)
Sourcepub fn push_outgoing_fd<F: IntoRawFd>(&self, fd: F)
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.
Sourcepub async fn readable(&self) -> Result<()>
pub async fn readable(&self) -> Result<()>
Wait for the underlying UnixStream to become readable.
Sourcepub fn pop_incoming_fd(&self) -> Option<RawFd>
pub fn pop_incoming_fd(&self) -> Option<RawFd>
Get the most recent file descriptor that was read with a message.
Sourcepub fn incoming_count(&self) -> usize
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>
impl<T: AsRawFd> AsyncRead for UnixFdStream<T>
Source§impl<T: AsRawFd + Shutdown + Unpin> AsyncWrite for UnixFdStream<T>
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>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
buf into the object. Read moreSource§fn poll_flush(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Source§fn poll_shutdown(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_shutdown( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
poll_write, except that it writes from a slice of buffers. Read moreSource§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
poll_write_vectored
implementation. Read more