Struct Limit

pub struct Limit<T> { /* private fields */ }

A BufMut adapter which limits the amount of bytes that can be written to an underlying buffer.

Implementations

impl<T> Limit<T>

fn into_inner(self) -> T

Consumes this Limit, returning the underlying value.

fn get_ref(&self) -> &T

Gets a reference to the underlying BufMut.

It is inadvisable to directly write to the underlying BufMut.

fn get_mut(&mut self) -> &mut T

Gets a mutable reference to the underlying BufMut.

It is inadvisable to directly write to the underlying BufMut.

fn limit(&self) -> usize

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.

fn set_limit(&mut self, lim: usize)

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.

Trait Implementations

impl<T: BufMut> BufMut for Limit<T>

fn remaining_mut(&self) -> usize
fn chunk_mut(&mut self) -> &mut UninitSlice
unsafe fn advance_mut(&mut self, cnt: usize)

impl<T: Debug> Debug for Limit<T>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<T> Freeze for Limit<T> where T: Freeze,

impl<T> RefUnwindSafe for Limit<T> where T: RefUnwindSafe,

impl<T> Send for Limit<T> where T: Send,

impl<T> Sync for Limit<T> where T: Sync,

impl<T> Unpin for Limit<T> where T: Unpin,

impl<T> UnsafeUnpin for Limit<T> where T: UnsafeUnpin,

impl<T> UnwindSafe for Limit<T> where T: UnwindSafe,

Blanket Implementations

impl<T> Any for Limit<T> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Limit<T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Limit<T> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for Limit<T>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into<U> for Limit<T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Limit<T> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Limit<T> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>