Trait runa_io_traits::AsyncReadWithFd
source · pub trait AsyncReadWithFd {
// Required method
fn poll_read_with_fds<Fds: OwnedFds>(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8],
fds: &mut Fds
) -> Poll<Result<usize>>;
}
Expand description
A extension trait of AsyncRead
that supports receiving file descriptors
along with data.
Required Methods§
sourcefn poll_read_with_fds<Fds: OwnedFds>(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8],
fds: &mut Fds
) -> Poll<Result<usize>>
fn poll_read_with_fds<Fds: OwnedFds>( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8], fds: &mut Fds ) -> Poll<Result<usize>>
Reads data and file descriptors from the stream. This is generic over how you store the file descriptors. Use something like tinyvec if you want to avoid heap allocations.
This cumbersome interface mainly originates from the fact kernel would drop file descriptors if you don’t give it a buffer big enough. Otherwise it would be easy to have read_data and read_fd be separate functions.
Arguments
fds
: Storage for the file descriptors.fd_limit
: Maximum number of file descriptors to receive. If more are received, they could be closed or stored in a buffer, depends on the implementation. None means no limit.
Note
If the fds
buffer is too small to hold all the file descriptors, the
extra file descriptors MAY BE CLOSED (see OwnedFds
). Some
implementation might hold a buffer of file descriptors to prevent
this from happening. You should check the documentation of the
implementor.
Returns
The number of bytes read.
Implementations on Foreign Types§
source§impl<T: AsyncReadWithFd + Unpin> AsyncReadWithFd for &mut T
impl<T: AsyncReadWithFd + Unpin> AsyncReadWithFd for &mut T
Forward impl of AsyncReadWithFd
for &mut T
where T: AsyncReadWithFd
.