pub struct BytesHint(/* private fields */);Expand description
Returns the bounds on the remaining bytes of the stream.
Specifically, bytes_hint() returns a tuple where the first element is
the lower bound, and the second element is the upper bound.
The second half of the tuple that is returned is an Option<u64>.
A None here means that either there is no known upper bound,
or the upper bound is larger than u64.
Implementations§
Source§impl BytesHint
impl BytesHint
pub fn new(lower_bound: u64, upper_bound: Option<u64>) -> BytesHint
Sourcepub fn new_at_max(bytes: u64) -> BytesHint
pub fn new_at_max(bytes: u64) -> BytesHint
Create a hint of min=0 and max=bytes bytes
Sourcepub fn new_no_hint() -> BytesHint
pub fn new_no_hint() -> BytesHint
Creates a new hint which gives no hint at all.
(0, None)
Sourcepub fn lower_bound(&self) -> u64
pub fn lower_bound(&self) -> u64
Returns the lower bound
Sourcepub fn upper_bound(&self) -> Option<u64>
pub fn upper_bound(&self) -> Option<u64>
A None here means that either there is no known upper bound,
or the upper bound is larger than usize.
Sourcepub fn is_exact(&self) -> bool
pub fn is_exact(&self) -> bool
Returns true if this hint is an exact hint.
This means that the lower bound must equal the upper bound: (a, Some(a)).
Sourcepub fn exact(&self) -> Option<u64>
pub fn exact(&self) -> Option<u64>
Returns the exact bytes if size hint specifies an exact amount of bytes.
This means that the lower bound must equal the upper bound: (a, Some(a)).
Sourcepub fn reduce_by(&mut self, by: u64)
pub fn reduce_by(&mut self, by: u64)
Bytes have been send and by less will be received from now on
pub fn combine(self, other: BytesHint) -> BytesHint
Sourcepub fn into_inner(self) -> (u64, Option<u64>)
pub fn into_inner(self) -> (u64, Option<u64>)
Turns this into the inner tuple