pub struct BodyPart { /* private fields */ }Expand description
A single part of a multipart/form-data body.
A part carries the form field name declared by its Content-Disposition
header, the file name of an uploaded file when the part is a file, the
headers that belong to the part alone, and its raw content.
Storage is pub(super) (§17.14): a caller never touches the fields
directly. The public read surface is the try_get_* family below,
which follows the same Option-returning convention as
crate::Request and crate::Response and therefore never fails
loudly on a part that lacks an optional attribute.
Implementations§
Source§impl BodyPart
impl BodyPart
Sourcepub fn try_get_name(&self) -> Option<&String>
pub fn try_get_name(&self) -> Option<&String>
Tries to get the form field name of this part.
§Returns
Option<&BodyPartName>- The declared field name, orNonewhen the part declares none.
Sourcepub fn try_get_file_name(&self) -> Option<&String>
pub fn try_get_file_name(&self) -> Option<&String>
Tries to get the uploaded file name of this part.
§Returns
Option<&BodyPartFileName>- The declared file name, orNonewhen this part is a plain field rather than a file upload.
Sourcepub fn try_get_content_type(&self) -> Option<&String>
pub fn try_get_content_type(&self) -> Option<&String>
Tries to get the media type declared by this part.
§Returns
Option<&BodyPartContentType>- The declared media type, orNonewhen the part declares none.
Sourcepub fn try_get_header<K>(&self, key: K) -> Option<&String>
pub fn try_get_header<K>(&self, key: K) -> Option<&String>
Sourcepub fn try_get_data(&self) -> Option<&[u8]>
pub fn try_get_data(&self) -> Option<&[u8]>
Tries to get this part’s raw content.
§Returns
Option<&[u8]>- The raw bytes, orNonewhen the part is empty.
Sourcepub fn try_get_text(&self) -> Option<String>
pub fn try_get_text(&self) -> Option<String>
Tries to get this part’s raw content as UTF-8 text.
Invalid UTF-8 is replaced rather than rejected, so a binary upload
read as text yields its readable bytes instead of None.
§Returns
Option<BodyFormValue>- The decoded text, orNonewhen the part is empty.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for BodyPart
impl<'de> Deserialize<'de> for BodyPart
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<BodyPart, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<BodyPart, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for BodyPart
Source§impl Serialize for BodyPart
impl Serialize for BodyPart
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for BodyPart
Auto Trait Implementations§
impl Freeze for BodyPart
impl RefUnwindSafe for BodyPart
impl Send for BodyPart
impl Sync for BodyPart
impl Unpin for BodyPart
impl UnsafeUnpin for BodyPart
impl UnwindSafe for BodyPart
Blanket Implementations§
impl<T> AnySend for T
impl<T> AnySendClone for T
impl<T> AnySendSync for T
impl<T> AnySendSyncClone for T
impl<T> AnySync for T
impl<T> AnySyncClone for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.