Struct rocket::config::Limits [−][src]
Mapping from data type to size limits.
A Limits
structure contains a mapping from a given data type ("forms",
"json", and so on) to the maximum size in bytes that should be accepted by a
Rocket application for that data type. For instance, if the limit for
"forms" is set to 256
, only 256 bytes from an incoming form request will
be read.
Defaults
As documented in config
, the default limits are as follows:
- forms: 32KiB
Usage
A Limits
structure is created following the builder pattern:
use rocket::config::Limits; // Set a limit of 64KiB for forms and 3MiB for JSON. let limits = Limits::new() .limit("forms", 64 * 1024) .limit("json", 3 * 1024 * 1024);
Implementations
impl Limits
[src]
pub fn new() -> Self
[src]
Construct a new Limits
structure with the default limits set.
Example
use rocket::config::Limits; let limits = Limits::new(); assert_eq!(limits.get("forms"), Some(32 * 1024));
pub fn limit<S: Into<String>>(mut self: Self, name: S, limit: u64) -> Self
[src]
Adds or replaces a limit in self
, consuming self
and returning a new
Limits
structure with the added or replaced limit.
Example
use rocket::config::Limits; let limits = Limits::new() .limit("json", 1 * 1024 * 1024); assert_eq!(limits.get("forms"), Some(32 * 1024)); assert_eq!(limits.get("json"), Some(1 * 1024 * 1024)); let new_limits = limits.limit("json", 64 * 1024 * 1024); assert_eq!(new_limits.get("json"), Some(64 * 1024 * 1024));
pub fn get(&self, name: &str) -> Option<u64>
[src]
Retrieve the set limit, if any, for the data type with name name
.
Example
use rocket::config::Limits; let limits = Limits::new() .limit("json", 64 * 1024 * 1024); assert_eq!(limits.get("forms"), Some(32 * 1024)); assert_eq!(limits.get("json"), Some(64 * 1024 * 1024)); assert!(limits.get("msgpack").is_none());
Trait Implementations
impl Clone for Limits
[src]
impl Debug for Limits
[src]
impl Default for Limits
[src]
impl Display for Limits
[src]
Auto Trait Implementations
impl RefUnwindSafe for Limits
[src]
impl Send for Limits
[src]
impl Sync for Limits
[src]
impl Unpin for Limits
[src]
impl UnwindSafe for Limits
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, I> AsResult<T, I> for T where
I: Input,
[src]
I: Input,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoCollection<T> for T
[src]
pub fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
[src]
A: Array<Item = T>,
pub fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
F: FnMut(T) -> U,
A: Array<Item = U>,
[src]
F: FnMut(T) -> U,
A: Array<Item = U>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Typeable for T where
T: Any,
T: Any,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,