Trait Source

Source
pub trait Source {
    type Item;

    // Required method
    fn next(&mut self) -> Self::Item;

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

This trait allows receiving items from somewhere.

Types implementing this trait are called “sources”.

Required Associated Types§

Source

type Item

The type of items the source receives.

Required Methods§

Source

fn next(&mut self) -> Self::Item

Get the next item.

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> Source for FramedRead<R, D>
where R: Read, D: Decoder,

Available on crate feature alloc only.