pub struct Field<'f> { /* private fields */ }
multipart
only.Expand description
Represent a form-data field Only the data needed to construct the field will be read into memory
Implementations§
source§impl<'f> Field<'f>
impl<'f> Field<'f>
sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the name
param of the Content-Disposition
header.
Currently return ""
if the name is missing.
This will return an Option<*str>
in saphir 4.0.0
sourcepub fn filename(&self) -> Option<&str>
pub fn filename(&self) -> Option<&str>
Returns the optional filename
param of the Content-Disposition
header
sourcepub fn content_type(&self) -> &Mime
pub fn content_type(&self) -> &Mime
Returns the optional Content-Type
Mime and is defaulted to
text/plain
as specified by the spec
sourcepub async fn as_raw(&mut self) -> Result<Vec<u8>, MultipartError>
👎Deprecated since 3.1.0: Use to_raw()
instead.
pub async fn as_raw(&mut self) -> Result<Vec<u8>, MultipartError>
to_raw()
instead.Deprecated;
Use to_raw()
instead.
Loads the entire field into memory and returns it as raw bytes
This will be removed in saphir 4.0.0
sourcepub async fn to_raw(self) -> Result<Vec<u8>, MultipartError>
pub async fn to_raw(self) -> Result<Vec<u8>, MultipartError>
Loads the entire field into memory and returns it as raw bytes
sourcepub async fn as_text(&mut self) -> Result<String, MultipartError>
👎Deprecated since 3.1.0: use to_text()
instead
pub async fn as_text(&mut self) -> Result<String, MultipartError>
to_text()
insteadDeprecated;
Use to_raw()
instead.
Loads the entire field into memory and returns it as plain text
This will be removed in saphir 4.0.0
sourcepub async fn to_text(self) -> Result<String, MultipartError>
pub async fn to_text(self) -> Result<String, MultipartError>
Loads the entire field into memory and returns it as plain text
sourcepub async fn as_json<T>(&mut self) -> Result<Option<T>, MultipartError>where
T: for<'a> Deserialize<'a>,
👎Deprecated since 3.1.0: use to_json()
insteadAvailable on crate feature json
only.
pub async fn as_json<T>(&mut self) -> Result<Option<T>, MultipartError>where T: for<'a> Deserialize<'a>,
to_json()
insteadjson
only.Deprecated;
Use to_raw()
instead.
Loads the entire field into memory and parses it as JSON data
IF the content-type is application/json
.
Return Ok(None)
if the content-type was incorrect.
This will be removed in saphir 4.0.0
sourcepub async fn to_json<T>(self) -> Result<Option<T>, MultipartError>where
T: for<'a> Deserialize<'a>,
👎Deprecated since 3.1.0: use to_json()
insteadAvailable on crate feature json
only.
pub async fn to_json<T>(self) -> Result<Option<T>, MultipartError>where T: for<'a> Deserialize<'a>,
to_json()
insteadjson
only.Loads the entire field into memory and parses it as JSON data
IF the content-type is application/json
.
Return Ok(None)
if the content-type was incorrect.
sourcepub async fn as_form<T>(&mut self) -> Result<Option<T>, MultipartError>where
T: for<'a> Deserialize<'a>,
👎Deprecated since 3.1.0: use to_form()
insteadAvailable on crate feature form
only.
pub async fn as_form<T>(&mut self) -> Result<Option<T>, MultipartError>where T: for<'a> Deserialize<'a>,
to_form()
insteadform
only.Deprecated;
Use to_raw()
instead.
Loads the entire field into memory and parses it as Form urlencoded data
IF the content-type is application/x-www-form-urlencoded
.
Return Ok(None)
if the content-type was incorrect.
This will be removed in saphir 4.0.0
sourcepub async fn to_form<T>(self) -> Result<Option<T>, MultipartError>where
T: for<'a> Deserialize<'a>,
Available on crate feature form
only.
pub async fn to_form<T>(self) -> Result<Option<T>, MultipartError>where T: for<'a> Deserialize<'a>,
form
only.Loads the entire field into memory and parses it as Form urlencoded data
IF the content-type is application/x-www-form-urlencoded
.
Return Ok(None)
if the content-type was incorrect.