/// A `BufMut` adapter which limits the amount of bytes that can be written /// to an underlying buffer. #[derive(Debug)] pubstruct Limit<T> {
inner: T,
limit: usize,
}
impl<T> Limit<T> { /// Consumes this `Limit`, returning the underlying value. pubfn into_inner(self) -> T { self.inner
}
/// Gets a reference to the underlying `BufMut`. /// /// It is inadvisable to directly write to the underlying `BufMut`. pubfn get_ref(&self) -> &T {
&self.inner
}
/// Gets a mutable reference to the underlying `BufMut`. /// /// It is inadvisable to directly write to the underlying `BufMut`. pubfn get_mut(&mutself) -> &mut T {
&mutself.inner
}
/// Returns the maximum number of bytes that can be written /// /// # Note /// /// If the inner `BufMut` has fewer bytes than indicated by this method then /// that is the actual number of available bytes. pubfn limit(&self) -> usize { self.limit
}
/// Sets the maximum number of bytes that can be written. /// /// # Note /// /// If the inner `BufMut` has fewer bytes than `lim` then that is the actual /// number of available bytes. pubfn set_limit(&mutself, lim: usize) { self.limit = lim
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.