pub struct Multipart<'m> { /* private fields */ }Expand description
A struct representing a multipart form.
Implementations§
Source§impl<'m> Multipart<'m>
impl<'m> Multipart<'m>
Sourcepub fn add_text(
&mut self,
name: impl Into<Cow<'m, str>>,
value: impl AsRef<str>,
)
pub fn add_text( &mut self, name: impl Into<Cow<'m, str>>, value: impl AsRef<str>, )
Adds a text field to the form.
Sourcepub async fn add_file(
&mut self,
name: impl Into<Cow<'m, str>>,
path: impl AsRef<Path>,
encoding: Option<Encoding>,
) -> Result<()>
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.
Sourcepub 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<()>
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.
Sourcepub 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<()>
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.
Sourcepub fn set_request(self, req: &mut Request)
pub fn set_request(self, req: &mut Request)
Sets the request body to the multipart form data.
Sourcepub async fn into_bytes(self) -> Result<Vec<u8>>
pub async fn into_bytes(self) -> Result<Vec<u8>>
Converts the multipart form to a Body.
pub fn into_stream( self, buf_size: Option<usize>, ) -> impl Stream<Item = StreamChunk>
pub fn into_reader( self, buf_size: Option<usize>, ) -> impl AsyncBufRead + Send + Sync
Trait Implementations§
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> 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
Mutably borrows from an owned value. Read more