Multipart

Struct Multipart 

Source
pub struct Multipart<'m> { /* private fields */ }
Expand description

A struct representing a multipart form.

Implementations§

Source§

impl<'m> Multipart<'m>

Source

pub fn new() -> Self

Creates a new Multipart form with a randomly generated boundary.

Source

pub fn add_text( &mut self, name: impl Into<Cow<'m, str>>, value: impl AsRef<str>, )

Adds a text field to the form.

Source

pub async fn add_file( &mut self, name: impl Into<Cow<'m, str>>, path: impl AsRef<Path>, encoding: Option<Encoding>, ) -> Result<()>

Adds a file field to the form from path.

Source

pub fn add_async_read( &mut self, name: impl Into<Cow<'m, str>>, filename: impl Into<Cow<'m, str>>, content_type: &str, encoding: Option<Encoding>, data: impl AsyncBufRead + Unpin + Send + Sync + 'static, data_len: Option<usize>, ) -> Result<()>

Adds a file field to the form wrapping a async reader.

Source

pub fn add_sync_read( &mut self, name: impl Into<Cow<'m, str>>, filename: impl Into<Cow<'m, str>>, content_type: &str, encoding: Option<Encoding>, data: impl Read + Seek + Send + 'static, ) -> Result<()>

Adds a file field to the form wrapping a sync reader.

Source

pub fn set_request(self, req: &mut Request)

Sets the request body to the multipart form data.

Source

pub async fn into_bytes(self) -> Result<Vec<u8>>

Converts the multipart form to a Body.

Source

pub fn into_stream( self, buf_size: Option<usize>, ) -> impl Stream<Item = StreamChunk>

Source

pub fn into_reader( self, buf_size: Option<usize>, ) -> impl AsyncBufRead + Send + Sync

Trait Implementations§

Source§

impl<'m> Debug for Multipart<'m>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Multipart<'_>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'m> Freeze for Multipart<'m>

§

impl<'m> !RefUnwindSafe for Multipart<'m>

§

impl<'m> Send for Multipart<'m>

§

impl<'m> Sync for Multipart<'m>

§

impl<'m> Unpin for Multipart<'m>

§

impl<'m> !UnwindSafe for Multipart<'m>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V