pub struct Form { /* private fields */ }multipart only.Expand description
Implementations§
Source§impl Form
impl Form
Sourcepub fn content_type(&self) -> HeaderValue
pub fn content_type(&self) -> HeaderValue
The Content-Type header value (multipart/form-data; boundary=…).
Sourcepub async fn file<N, P>(self, name: N, path: P) -> Result<Self>
pub async fn file<N, P>(self, name: N, path: P) -> Result<Self>
Add a file part to the form. Reads the file asynchronously, infers the
MIME type from the file extension (falling back to
application/octet-stream), and sets filename from the path.
Sourcepub async fn with_field_spec(self, spec: &str) -> Result<Self, FieldSpecError>
pub async fn with_field_spec(self, spec: &str) -> Result<Self, FieldSpecError>
Add a part described by a compact name=value field-spec string.
See FieldSpec for the supported syntax (the same convention used
by curl -F, httpie, and similar tools). Performs the I/O implied by
=@ (file), =< (file-as-text), and =@- / =<- (stdin) sources;
the =value form is purely textual.
Sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Total content length of the encoded form, if every part has a known
size. Returns None otherwise (use chunked transfer encoding in that
case).
Computed analytically — no headers are rendered into a buffer.
Sourcepub fn into_stream(self) -> impl Stream<Item = Result<Bytes, BoxError>> + Send
pub fn into_stream(self) -> impl Stream<Item = Result<Bytes, BoxError>> + Send
Convert this form into a stream of body chunks.
Per-part overhead: one heap-allocated framing chunk (boundary delimiter + headers, prefixed with CRLF on all but the first part) and the part body. Bytes-bodied parts are emitted in a single chunk; streamed bodies pass through their underlying chunks unchanged.
Sourcepub fn into_body(self) -> Body
pub fn into_body(self) -> Body
Consume the form and produce a Body ready to be set on
a request. Use content_type and
content_length to set the relevant request
headers.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Form
impl !RefUnwindSafe for Form
impl !Sync for Form
impl !UnwindSafe for Form
impl Send for Form
impl Unpin for Form
impl UnsafeUnpin for Form
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