Struct async_read_length_limit::LengthLimit
source · pub struct LengthLimit<T> { /* private fields */ }
Expand description
[AsyncRead
] length limiter
Protects against a certain class of denial-of-service attacks wherein long chunked bodies are uploaded to web services.
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§
Trait Implementations§
source§impl<T: AsyncRead> AsyncRead for LengthLimit<T>
impl<T: AsyncRead> AsyncRead for LengthLimit<T>
impl<'__pin, T> Unpin for LengthLimit<T>where __Origin<'__pin, T>: Unpin,
Auto Trait Implementations§
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 Rwhere
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for Rwhere R: AsyncRead + ?Sized,
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, Global>
) -> ReadToEndFuture<'a, Self>where
Self: Unpin,
fn read_to_end<'a>( &'a mut self, buf: &'a mut Vec<u8, Global> ) -> 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 Twhere
T: AsyncRead + Unpin,
impl<T> LengthLimitExt for Twhere T: AsyncRead + Unpin,
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)