Struct actix_web_lab::extract::BodyLimit
source · pub struct BodyLimit<T, const LIMIT: usize = DEFAULT_BODY_LIMIT> { /* private fields */ }
Expand description
Extractor wrapper that limits size of payload used.
§Examples
use actix_web::{get, web::Bytes, Responder};
use actix_web_lab::extract::BodyLimit;
const BODY_LIMIT: usize = 1_048_576; // 1MB
#[get("/")]
async fn handler(body: BodyLimit<Bytes, BODY_LIMIT>) -> impl Responder {
let body = body.into_inner();
assert!(body.len() < BODY_LIMIT);
body
}
Implementations§
Trait Implementations§
source§impl<T, const LIMIT: usize> FromRequest for BodyLimit<T, LIMIT>
impl<T, const LIMIT: usize> FromRequest for BodyLimit<T, LIMIT>
source§fn from_request(req: &HttpRequest, payload: &mut Payload) -> Self::Future
fn from_request(req: &HttpRequest, payload: &mut Payload) -> Self::Future
Create a
Self
from request parts asynchronously.source§impl<T: PartialEq, const LIMIT: usize> PartialEq for BodyLimit<T, LIMIT>
impl<T: PartialEq, const LIMIT: usize> PartialEq for BodyLimit<T, LIMIT>
impl<T: Eq, const LIMIT: usize> Eq for BodyLimit<T, LIMIT>
impl<T, const LIMIT: usize> StructuralPartialEq for BodyLimit<T, LIMIT>
Auto Trait Implementations§
impl<T, const LIMIT: usize> Freeze for BodyLimit<T, LIMIT>where
T: Freeze,
impl<T, const LIMIT: usize> RefUnwindSafe for BodyLimit<T, LIMIT>where
T: RefUnwindSafe,
impl<T, const LIMIT: usize> Send for BodyLimit<T, LIMIT>where
T: Send,
impl<T, const LIMIT: usize> Sync for BodyLimit<T, LIMIT>where
T: Sync,
impl<T, const LIMIT: usize> Unpin for BodyLimit<T, LIMIT>where
T: Unpin,
impl<T, const LIMIT: usize> UnwindSafe for BodyLimit<T, LIMIT>where
T: UnwindSafe,
Blanket Implementations§
source§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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more