[−][src]Struct multipart::client::Multipart
The entry point of the client-side multipart API.
Though they perform I/O, the .write_*()
methods do not return io::Result<_>
in order to
facilitate method chaining. Upon the first error, all subsequent API calls will be no-ops until
.send()
is called, at which point the error will be reported.
Implementations
impl Multipart<()>
[src]
pub fn from_request<R: HttpRequest>(
req: R
) -> Result<Multipart<R::Stream>, R::Error>
[src]
req: R
) -> Result<Multipart<R::Stream>, R::Error>
impl<S: HttpStream> Multipart<S>
[src]
pub fn write_text<N: AsRef<str>, V: AsRef<str>>(
&mut self,
name: N,
val: V
) -> Result<&mut Self, S::Error>
[src]
&mut self,
name: N,
val: V
) -> Result<&mut Self, S::Error>
Write a text field to this multipart request.
name
and val
can be either owned String
or &str
.
Errors
If something went wrong with the HTTP stream.
pub fn write_file<N: AsRef<str>, P: AsRef<Path>>(
&mut self,
name: N,
path: P
) -> Result<&mut Self, S::Error>
[src]
&mut self,
name: N,
path: P
) -> Result<&mut Self, S::Error>
Open a file pointed to by path
and write its contents to the multipart request,
supplying its filename and guessing its Content-Type
from its extension.
If you want to set these values manually, or use another type that implements Read
,
use .write_stream()
.
name
can be either String
or &str
, and path
can be PathBuf
or &Path
.
Errors
If there was a problem opening the file (was a directory or didn't exist), or if something went wrong with the HTTP stream.
pub fn write_stream<N: AsRef<str>, St: Read>(
&mut self,
name: N,
stream: &mut St,
filename: Option<&str>,
content_type: Option<Mime>
) -> Result<&mut Self, S::Error>
[src]
&mut self,
name: N,
stream: &mut St,
filename: Option<&str>,
content_type: Option<Mime>
) -> Result<&mut Self, S::Error>
Write a byte stream to the multipart request as a file field, supplying filename
if given,
and content_type
if given or "application/octet-stream"
if not.
name
can be either String
or &str
, and read
can take the Read
by-value or
with an &mut
borrow.
Warning
The given Read
must be able to read to EOF (end of file/no more data), meaning
Read::read()
returns Ok(0)
. If it never returns EOF it will be read to infinity
and the request will never be completed.
When using SizedRequest
this also can cause out-of-control memory usage as the
multipart data has to be written to an in-memory buffer so its size can be calculated.
Use Read::take()
if you wish to send data from a Read
that will never return EOF otherwise.
Errors
If the reader returned an error, or if something went wrong with the HTTP stream.
pub fn send(self) -> Result<S::Response, S::Error>
[src]
Finalize the request and return the response from the server, or the last error if set.
impl<R: HttpRequest> Multipart<SizedRequest<R>> where
<R::Stream as HttpStream>::Error: From<R::Error>,
[src]
<R::Stream as HttpStream>::Error: From<R::Error>,
pub fn from_request_sized(req: R) -> Result<Self, R::Error>
[src]
Create a new Multipart
using the SizedRequest
wrapper around req
.
Auto Trait Implementations
impl<S> RefUnwindSafe for Multipart<S> where
S: RefUnwindSafe,
[src]
S: RefUnwindSafe,
impl<S> Send for Multipart<S> where
S: Send,
[src]
S: Send,
impl<S> Sync for Multipart<S> where
S: Sync,
[src]
S: Sync,
impl<S> Unpin for Multipart<S> where
S: Unpin,
[src]
S: Unpin,
impl<S> UnwindSafe for Multipart<S> where
S: UnwindSafe,
[src]
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,