pub struct MultiPartParser {
pub max_file_size: Option<usize>,
pub max_total_size: Option<usize>,
}Expand description
MultiPart parser for multipart/form-data content type (file uploads)
By default, enforces sensible size limits to prevent denial-of-service via large uploads:
- Per-file limit: 10 MB
- Total upload limit: 50 MB
Use the builder methods to override these limits, or
MultiPartParser::unlimited() to remove all limits.
Fields§
§max_file_size: Option<usize>Maximum file size in bytes (None = unlimited)
max_total_size: Option<usize>Maximum total size in bytes (None = unlimited)
Implementations§
Source§impl MultiPartParser
impl MultiPartParser
Sourcepub fn new() -> MultiPartParser
pub fn new() -> MultiPartParser
Create a new MultiPartParser with default size limits.
Default limits:
- Per-file: 10 MB
- Total: 50 MB
§Examples
use reinhardt_core::parsers::multipart::MultiPartParser;
let parser = MultiPartParser::new();
assert_eq!(parser.max_file_size, Some(10 * 1024 * 1024));
assert_eq!(parser.max_total_size, Some(50 * 1024 * 1024));Sourcepub fn unlimited() -> MultiPartParser
pub fn unlimited() -> MultiPartParser
Create a new MultiPartParser with no size limits.
§Safety Note
Using unlimited uploads without external size controls (e.g., reverse proxy limits) may expose the server to denial-of-service attacks.
§Examples
use reinhardt_core::parsers::multipart::MultiPartParser;
let parser = MultiPartParser::unlimited();
assert!(parser.max_file_size.is_none());
assert!(parser.max_total_size.is_none());Sourcepub fn max_file_size(self, size: usize) -> MultiPartParser
pub fn max_file_size(self, size: usize) -> MultiPartParser
Set the maximum file size in bytes for individual files.
§Examples
use reinhardt_core::parsers::multipart::MultiPartParser;
let parser = MultiPartParser::new().max_file_size(1024 * 1024); // 1MB
assert_eq!(parser.max_file_size, Some(1024 * 1024));Sourcepub fn max_total_size(self, size: usize) -> MultiPartParser
pub fn max_total_size(self, size: usize) -> MultiPartParser
Set the maximum total size in bytes for all uploaded files combined.
§Examples
use reinhardt_core::parsers::multipart::MultiPartParser;
let parser = MultiPartParser::new().max_total_size(10 * 1024 * 1024); // 10MB
assert_eq!(parser.max_total_size, Some(10 * 1024 * 1024));Trait Implementations§
Source§impl Clone for MultiPartParser
impl Clone for MultiPartParser
Source§fn clone(&self) -> MultiPartParser
fn clone(&self) -> MultiPartParser
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MultiPartParser
impl Debug for MultiPartParser
Source§impl Default for MultiPartParser
impl Default for MultiPartParser
Source§fn default() -> MultiPartParser
fn default() -> MultiPartParser
Creates a parser with default size limits (10 MB per file, 50 MB total).
Source§impl Parser for MultiPartParser
impl Parser for MultiPartParser
Source§fn media_types(&self) -> Vec<String>
fn media_types(&self) -> Vec<String>
Source§fn parse<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
content_type: Option<&'life1 str>,
body: Bytes,
_headers: &'life2 HeaderMap,
) -> Pin<Box<dyn Future<Output = Result<ParsedData, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MultiPartParser: 'async_trait,
fn parse<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
content_type: Option<&'life1 str>,
body: Bytes,
_headers: &'life2 HeaderMap,
) -> Pin<Box<dyn Future<Output = Result<ParsedData, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
MultiPartParser: 'async_trait,
Auto Trait Implementations§
impl Freeze for MultiPartParser
impl RefUnwindSafe for MultiPartParser
impl Send for MultiPartParser
impl Sync for MultiPartParser
impl Unpin for MultiPartParser
impl UnsafeUnpin for MultiPartParser
impl UnwindSafe for MultiPartParser
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().