Struct Multipart
pub struct Multipart { /* private fields */ }http and std 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.
An error ends the stream: every later read fails the same way.
For producing multipart bodies on the client, see
crate::service::client::multipart.
Implementations§
§impl Multipart
impl Multipart
pub fn from_body(body: Body, boundary: impl AsRef<[u8]>) -> Multipart
Available on crate feature multipart only.
pub fn from_body(body: Body, boundary: impl AsRef<[u8]>) -> Multipart
multipart only.Build a Multipart from a body and boundary string with no per-field
limits and the default part limit.
pub fn from_body_with_config(
body: Body,
boundary: impl AsRef<[u8]>,
config: Option<&MultipartConfig>,
) -> Multipart
Available on crate feature multipart only.
pub fn from_body_with_config( body: Body, boundary: impl AsRef<[u8]>, config: Option<&MultipartConfig>, ) -> Multipart
multipart only.Build a Multipart from a body and boundary string, applying the
limits in config. Pass None for no per-field limits and the
default part limit.
A boundary that cannot frame a body fails the first read.
pub fn from_stream_with_config<S, O, E>(
stream: S,
boundary: impl AsRef<[u8]>,
config: Option<&MultipartConfig>,
) -> Multipart
Available on crate feature multipart only.
pub fn from_stream_with_config<S, O, E>( stream: S, boundary: impl AsRef<[u8]>, config: Option<&MultipartConfig>, ) -> Multipart
multipart only.Construct from any stream of Result<Bytes, _> and a boundary, with the
limits in config. Pass None for no per-field limits and the
default part limit.
A boundary that cannot frame a body fails the first read.
pub async fn next_field(&mut self) -> Result<Option<Field<'_>>, MultipartError>
Available on crate feature multipart only.
pub async fn next_field(&mut self) -> Result<Option<Field<'_>>, MultipartError>
multipart only.Yield the next Field in the multipart stream, or None if the
stream is exhausted.
What is left unread of the previous field is skipped, and still counts toward its byte limit.
Fails once the stream holds more parts than the configured maximum, and keeps failing on later calls.
The previous Field must be dropped before this returns; the borrow
checker enforces this.
Trait Implementations§
§impl FromRequest for Multipart
impl FromRequest for Multipart
§type Rejection = MultipartRejection
type Rejection = MultipartRejection
§async fn from_request(
req: Request,
) -> Result<Multipart, <Multipart as FromRequest>::Rejection>
async fn from_request( req: Request, ) -> Result<Multipart, <Multipart as FromRequest>::Rejection>
§impl FromRequestBody for Multipart
impl FromRequestBody for Multipart
Auto Trait Implementations§
impl !Freeze for Multipart
impl !RefUnwindSafe for Multipart
impl !UnwindSafe for Multipart
impl Forget for Multipart
impl Move for Multipart
impl Send for Multipart
impl Sync for Multipart
impl Unpin for Multipart
impl UnsafeUnpin for Multipart
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more