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::{Responder, get, web::Bytes};
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>where
T: FromRequest + 'static,
T::Error: Debug + Display,
impl<T, const LIMIT: usize> FromRequest for BodyLimit<T, LIMIT>where T: FromRequest + 'static, T::Error: Debug + Display,
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<BodyLimit<T, LIMIT>> for BodyLimit<T, LIMIT>
impl<T: PartialEq, const LIMIT: usize> PartialEq<BodyLimit<T, LIMIT>> for BodyLimit<T, LIMIT>
impl<T: Eq, const LIMIT: usize> Eq for BodyLimit<T, LIMIT>
impl<T, const LIMIT: usize> StructuralEq for BodyLimit<T, LIMIT>
impl<T, const LIMIT: usize> StructuralPartialEq for BodyLimit<T, LIMIT>
Auto Trait Implementations§
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 Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
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<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.