Struct runa_io::buf::BufReaderWithFd
source · pub struct BufReaderWithFd<T> { /* private fields */ }
Expand description
A buffered reader for reading data with file descriptors.
#Note
Because of the special treatment of file descriptors, i.e. they are closed if we don’t call
recvmsg
with a big enough buffer, so every time we read, we have to read all of them, whehter
there are spare buffer left or not. This means the file descriptors buffer will grow
indefinitely if they are not read from BufWithFd.
Also, users are encouraged to use up all the available data before calling poll_fill_buf/poll_fill_buf_until again, otherwise there is potential for causing a lot of allocations and memcpys.
Implementations§
Trait Implementations§
source§impl<T: AsyncReadWithFd> AsyncBufReadWithFd for BufReaderWithFd<T>
impl<T: AsyncReadWithFd> AsyncBufReadWithFd for BufReaderWithFd<T>
source§fn poll_fill_buf_until(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
len: usize
) -> Poll<Result<()>>
fn poll_fill_buf_until( self: Pin<&mut Self>, cx: &mut Context<'_>, len: usize ) -> Poll<Result<()>>
Reads enough data to return a buffer at least the given size.
source§fn fds(&self) -> &[RawFd]
fn fds(&self) -> &[RawFd]
Pop 1 file descriptor from the buffer, return None if the buffer is
empty. This takes shared references, mainly because we want to have
the deserialized value borrow from the BufReader, but while
deserializing, we also need to pop file descriptors. As a
compromise, we have to pop file descriptors using a shared
reference. Implementations would have to use a RefCell, a
Mutex, or something similar.
fn buffer(&self) -> &[u8] ⓘ
fn consume(self: Pin<&mut Self>, amt: usize, amt_fd: usize)
fn poll_next_message<'a>( self: Pin<&'a mut Self>, cx: &mut Context<'_> ) -> Poll<Result<Message<'a>, Error>>
fn next_message<'a>( self: Pin<&'a mut Self> ) -> impl Future<Output = Result<Message<'a>, Error>> + 'awhere Self: Sized,
source§impl<T: AsyncReadWithFd> AsyncReadWithFd for BufReaderWithFd<T>
impl<T: AsyncReadWithFd> AsyncReadWithFd for BufReaderWithFd<T>
source§fn 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. Read more