pub struct Multipart<S> { /* fields omitted */ }
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.
Create a new Multipart
to wrap a request.
If req.open_stream()
returns an error.
pub fn write_text<N: AsRef<str>, V: AsRef<str>>( &mut self, name: N, val: V ) -> Result<&mut Self, S::Error> | [src] |
Write a text field to this multipart request.
name
and val
can be either owned String
or &str
.
If something went wrong with the HTTP stream.
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
.
If there was a problem opening the file (was a directory or didn't exist),
or if something went wrong with the HTTP stream.
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.
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.
If the reader returned an error, or if something went wrong with the HTTP stream.
Finalize the request and return the response from the server, or the last error if set.
Create a new Multipart
using the SizedRequest
wrapper around req
.
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
impl<T> Typeable for T where T: Any, | |
Get the TypeId
of this object.
impl<T> UnsafeAny for T where T: Any, | |