Trait AsyncSource

Source
pub trait AsyncSource {
    type Item;

    // Required method
    fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Item>;

    // Provided method
    fn size_hint(&self) -> (usize, Option<usize>) { ... }
}
Expand description

The asynchronous version of Source.

Required Associated Types§

Source

type Item

The type of items the source receives.

Required Methods§

Source

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Item>

Attempt to receive the next item from the source.

Provided Methods§

Source

fn size_hint(&self) -> (usize, Option<usize>)

Get an estimation of the number of items yet to be received.

Returns a tuple where the 2 elements are the lower and upper bounds of the number of items expected to be received. The upper bound is an Option<usize> to account for cases where the upper bound is not known. In such cases, implementations should return None as the upper bound.

The default implementation returns (0, None).

Implementors§

Source§

impl<R, D> AsyncSource for FramedRead<R, D>
where R: AsyncRead, D: Decoder,

Available on crate feature alloc only.