pub struct Multipart { /* private fields */ }multipart only.Expand description
Extractor for multipart/form-data request bodies.
Iterate fields with Multipart::next_field. Per-field limits are
configured via MultipartConfig, either inserted as a request
extension by a layer (the path the extractor reads) or passed to
from_body_with_config for direct use.
Combine multiple configs with MultipartConfig::merge_floor; the
lowest limit per field wins.
Multipart enforces field exclusivity at compile time: each Field
borrows from &mut self, so the previous field must be dropped before the
next is requested.
For producing multipart bodies on the client, see
crate::service::client::multipart.
Implementations§
Source§impl Multipart
impl Multipart
Sourcepub fn from_body(body: Body, boundary: impl Into<String>) -> Self
pub fn from_body(body: Body, boundary: impl Into<String>) -> Self
Build a Multipart from a body and boundary string with no per-field
limits.
Sourcepub fn from_body_with_config(
body: Body,
boundary: impl Into<String>,
config: Option<&MultipartConfig>,
) -> Self
pub fn from_body_with_config( body: Body, boundary: impl Into<String>, config: Option<&MultipartConfig>, ) -> Self
Build a Multipart from a body and boundary string, applying the
per-field limits in config. Pass None to skip building any
multer::Constraints and use parser defaults.
Sourcepub fn from_stream_with_config<S, O, E, B>(
stream: S,
boundary: B,
config: Option<&MultipartConfig>,
) -> Self
pub fn from_stream_with_config<S, O, E, B>( stream: S, boundary: B, config: Option<&MultipartConfig>, ) -> Self
Construct from any stream of Result<Bytes, _> and a boundary, with the
per-field limits in config. Pass None to skip building any
multer::Constraints and use parser defaults.
Sourcepub async fn next_field(&mut self) -> Result<Option<Field<'_>>, MultipartError>
pub async fn next_field(&mut self) -> Result<Option<Field<'_>>, MultipartError>
Yield the next Field in the multipart stream, or None if the
stream is exhausted.
The previous Field must be dropped before this returns; the borrow
checker enforces this.
Trait Implementations§
Source§impl FromRequest for Multipart
impl FromRequest for Multipart
Source§type Rejection = MultipartRejection
type Rejection = MultipartRejection
Auto Trait Implementations§
impl !RefUnwindSafe for Multipart
impl !UnwindSafe for Multipart
impl Freeze for Multipart
impl Send for Multipart
impl Sync for Multipart
impl Unpin for Multipart
impl UnsafeUnpin for Multipart
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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