5 /// The default implementation returns:
8 /// * `None` for `upper`.
9 #[derive(Debug, Default, Clone)]
16 /// Returns a new `SizeHint` with default values
18 pub fn new() -> SizeHint {
22 /// Returns a new `SizeHint` with both upper and lower bounds set to the
25 pub fn with_exact(value: u64) -> SizeHint {
32 /// Returns the lower bound of data that the `Body` will yield before
35 pub fn lower(&self) -> u64 {
39 /// Set the value of the `lower` hint.
43 /// The function panics if `value` is greater than `upper`.
45 pub fn set_lower(&mut self, value: u64) {
46 assert!(value <= self.upper.unwrap_or(u64::MAX));
50 /// Returns the upper bound of data the `Body` will yield before
51 /// completing, or `None` if the value is unknown.
53 pub fn upper(&self) -> Option<u64> {
57 /// Set the value of the `upper` hint value.
61 /// This function panics if `value` is less than `lower`.
63 pub fn set_upper(&mut self, value: u64) {
64 assert!(value >= self.lower, "`value` is less than than `lower`");
66 self.upper = Some(value);
69 /// Returns the exact size of data that will be yielded **if** the
70 /// `lower` and `upper` bounds are equal.
72 pub fn exact(&self) -> Option<u64> {
73 if Some(self.lower) == self.upper {
80 /// Set the value of the `lower` and `upper` bounds to exactly the same.
82 pub fn set_exact(&mut self, value: u64) {
84 self.upper = Some(value);