pub unsafe trait AsyncBufReadWithFd: AsyncReadWithFd {
    // Required methods
    fn poll_fill_buf_until<'a>(
        self: Pin<&'a mut Self>,
        cx: &mut Context<'_>,
        len: usize
    ) -> Poll<Result<(), Error>>;
    fn fds(&self) -> &[i32];
    fn buffer(&self) -> &[u8] ;
    fn consume(self: Pin<&mut Self>, amt: usize, amt_fd: usize);

    // Provided methods
    fn fill_buf_until(&mut self, len: usize) -> FillBufUtil<'_, Self> 
       where Self: Unpin { ... }
    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>> + 'a
       where Self: Sized { ... }
}
Expand description

Buffered I/O object for a stream of bytes with file descriptors.

Safety

See crate::AsyncReadWithFd. Also, implementation cannot hold copies, or use any of the file descriptors after they are consumed by the caller.

Required Methods§

fn poll_fill_buf_until<'a>( self: Pin<&'a mut Self>, cx: &mut Context<'_>, len: usize ) -> Poll<Result<(), Error>>

Reads enough data to return a buffer at least the given size.

fn fds(&self) -> &[i32]

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)

Provided Methods§

fn fill_buf_until(&mut self, len: usize) -> FillBufUtil<'_, Self> where Self: Unpin,

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,

Implementors§