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§

source§

impl<T> BufReaderWithFd<T>

source

pub fn new(inner: T) -> Self

source

pub fn shrink(self: Pin<&mut Self>)

source

pub fn with_capacity(inner: T, cap_data: usize, cap_fd: usize) -> Self

Trait Implementations§

source§

impl<T: AsyncReadWithFd> AsyncBufReadWithFd for BufReaderWithFd<T>

source§

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]

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.
source§

fn buffer(&self) -> &[u8]

source§

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>

source§

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
source§

impl<T: Debug> Debug for BufReaderWithFd<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'__pin, T> Unpin for BufReaderWithFd<T>where __Origin<'__pin, T>: Unpin,

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for BufReaderWithFd<T>where T: RefUnwindSafe,

§

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

§

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

§

impl<T> UnwindSafe for BufReaderWithFd<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more