Struct async_read_length_limit::LengthLimit 
source · pub struct LengthLimit<T> { /* private fields */ }Expand description
§AsyncRead length limiter
The number of bytes will never be more than the provided byte limit. If the byte limit is exactly the length of the contained AsyncRead, it is considered an error.
§Errors
This will return an error if the underlying AsyncRead does so or if the read length meets (or
would exceed) the provided length limit. The returned std::io::Error will have an error kind
of ErrorKind::InvalidData and a contained error of LengthLimitExceeded.
Implementations§
source§impl<T> LengthLimit<T>where
    T: AsyncRead,
 
impl<T> LengthLimit<T>where
    T: AsyncRead,
sourcepub fn new(reader: T, max_bytes: usize) -> Self
 
pub fn new(reader: T, max_bytes: usize) -> Self
Constructs a new LengthLimit with provided AsyncRead reader and max_bytes byte
length
sourcepub fn bytes_remaining(&self) -> usize
 
pub fn bytes_remaining(&self) -> usize
Returns the number of additional bytes before the limit is reached
sourcepub fn into_inner(self) -> T
 
pub fn into_inner(self) -> T
Unwraps the contained AsyncRead, allowing it to be read to completion. bytes remaining data are discarded
Trait Implementations§
source§impl<T> AsRef<T> for LengthLimit<T>
 
impl<T> AsRef<T> for LengthLimit<T>
source§impl<T: AsyncRead> AsyncRead for LengthLimit<T>
 
impl<T: AsyncRead> AsyncRead for LengthLimit<T>
source§impl<T: Clone> Clone for LengthLimit<T>
 
impl<T: Clone> Clone for LengthLimit<T>
source§fn clone(&self) -> LengthLimit<T>
 
fn clone(&self) -> LengthLimit<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
 
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from 
source. Read moresource§impl<T: Debug> Debug for LengthLimit<T>
 
impl<T: Debug> Debug for LengthLimit<T>
impl<T: Copy> Copy for LengthLimit<T>
impl<'__pin, T> Unpin for LengthLimit<T>where
    __Origin<'__pin, T>: Unpin,
Auto Trait Implementations§
impl<T> Freeze for LengthLimit<T>where
    T: Freeze,
impl<T> RefUnwindSafe for LengthLimit<T>where
    T: RefUnwindSafe,
impl<T> Send for LengthLimit<T>where
    T: Send,
impl<T> Sync for LengthLimit<T>where
    T: Sync,
impl<T> UnwindSafe for LengthLimit<T>where
    T: UnwindSafe,
Blanket Implementations§
source§impl<R> AsyncReadExt for R
 
impl<R> AsyncReadExt for R
source§fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
    Self: Unpin,
 
fn read<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>where
    Self: Unpin,
Reads some bytes from the byte stream. Read more
source§fn read_vectored<'a>(
    &'a mut self,
    bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self>where
    Self: Unpin,
 
fn read_vectored<'a>(
    &'a mut self,
    bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self>where
    Self: Unpin,
source§fn read_to_end<'a>(
    &'a mut self,
    buf: &'a mut Vec<u8>
) -> ReadToEndFuture<'a, Self>where
    Self: Unpin,
 
fn read_to_end<'a>(
    &'a mut self,
    buf: &'a mut Vec<u8>
) -> ReadToEndFuture<'a, Self>where
    Self: Unpin,
source§fn read_to_string<'a>(
    &'a mut self,
    buf: &'a mut String
) -> ReadToStringFuture<'a, Self>where
    Self: Unpin,
 
fn read_to_string<'a>(
    &'a mut self,
    buf: &'a mut String
) -> ReadToStringFuture<'a, Self>where
    Self: Unpin,
source§fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
    Self: Unpin,
 
fn read_exact<'a>(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>where
    Self: Unpin,
Reads the exact number of bytes required to fill 
buf. Read moresource§fn take(self, limit: u64) -> Take<Self>where
    Self: Sized,
 
fn take(self, limit: u64) -> Take<Self>where
    Self: Sized,
Creates an adapter which will read at most 
limit bytes from it. Read moresource§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> LengthLimitExt for T
 
impl<T> LengthLimitExt for T
source§fn limit_bytes(self, max_bytes: usize) -> LengthLimit<Self>
 
fn limit_bytes(self, max_bytes: usize) -> LengthLimit<Self>
Applies a LengthLimit to self with an exclusive maxiumum of 
max_bytes bytessource§fn limit_kb(self, max_kb: usize) -> LengthLimit<Self>
 
fn limit_kb(self, max_kb: usize) -> LengthLimit<Self>
Applies a LengthLimit to self with an exclusive maxiumum of 
max_kb kilobytes (defined as
1024 bytes)source§fn limit_mb(self, max_mb: usize) -> LengthLimit<Self>
 
fn limit_mb(self, max_mb: usize) -> LengthLimit<Self>
Applies a LengthLimit to self with an exclusive maxiumum of 
max_mb megabytes (defined as
1024 kilobytes, or 1,048,576 bytes)source§fn limit_gb(self, max_gb: usize) -> LengthLimit<Self>
 
fn limit_gb(self, max_gb: usize) -> LengthLimit<Self>
Applies a LengthLimit to self with an exclusive maxiumum of 
max_gb kilobytes (defined as
1024 megabytes, or 1,073,741,824 bytes)