pub struct Multipart { /* private fields */ }Expand description
Streaming multipart/form-data extractor. Parts arrive in wire order and
must be consumed sequentially; next_part discards
any unread remainder of the previous part. Requires
content-type: multipart/form-data with a valid boundary — anything else is
415 JC0415.
Single-consumer: the extractor takes ownership of the body, so extracting it twice in one handler is a programming error (500 on stream routes).
Implementations§
Source§impl Multipart
impl Multipart
Sourcepub fn from_buffered(
content_type: &str,
body: impl Into<Bytes>,
) -> Option<Multipart>
pub fn from_buffered( content_type: &str, body: impl Into<Bytes>, ) -> Option<Multipart>
Build a buffered Multipart from an already-read body and its
Content-Type header value, or None if the content type is not
multipart/form-data with a valid boundary.
The Multipart extractor (FromRequest) is the normal path and is
415 on a non-multipart request. This constructor exists for handlers
that must accept either a multipart upload or some other content type
on the same route (e.g. a CSV import endpoint whose generated success
probe posts an empty JSON body): take Headers + RawBody, then
Multipart::from_buffered when the type matches. The parsing is
identical to the extractor’s buffered path.
Sourcepub fn set_part_cap(&mut self, bytes: usize)
pub fn set_part_cap(&mut self, bytes: usize)
Per-part byte cap enforced by Part::bytes/Part::text
(default 8 MiB).
Trait Implementations§
Source§impl FromRequest for Multipart
impl FromRequest for Multipart
async fn from_request(ctx: &mut RequestCtx) -> Result<Multipart, Error>
Auto Trait Implementations§
impl !RefUnwindSafe for Multipart
impl !Sync for Multipart
impl !UnwindSafe for Multipart
impl Freeze for Multipart
impl Send for Multipart
impl Unpin for Multipart
impl UnsafeUnpin for Multipart
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 more