#[non_exhaustive]pub struct PartHeaders<'a> {
pub content_type: Option<ContentType>,
pub content_disposition: Option<ContentDisposition<'a>>,
pub content_transfer_encoding: Option<ContentTransferEncoding>,
}Expand description
The header fields of a part that this crate understands, as a FieldSection to interpret a PartHead with. Other fields are ignored.
Each is a singleton, so a second Content-Type or Content-Disposition is an error rather than a choice between them. A transfer encoding other than an identity one is an invalid value, since the content would otherwise be misread. Flatten this section into one of your own to read other fields too.
use base_web_multipart::{ParameterRules, PartHead, PartHeaders};
use base_message::FieldSection;
let headers = PartHeaders::interpret([("Content-Disposition", "form-data; name=\"a\""), ("Content-Type", "text/plain")])?;
let disposition = headers.content_disposition.as_ref().expect("a disposition");
assert_eq!(disposition.name(ParameterRules::FormData)?.as_deref(), Some("a"));
assert!(PartHeaders::interpret([("Content-Transfer-Encoding", "base64")]).is_err());Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.content_type: Option<ContentType>The part’s media type, if it has one.
content_disposition: Option<ContentDisposition<'a>>The part’s disposition, such as a form field’s name and a file’s name.
content_transfer_encoding: Option<ContentTransferEncoding>The part’s transfer encoding, which can only be an identity encoding.
Trait Implementations§
Source§impl<'a> Clone for PartHeaders<'a>
impl<'a> Clone for PartHeaders<'a>
Source§impl<'a> Debug for PartHeaders<'a>
impl<'a> Debug for PartHeaders<'a>
impl<'a> Eq for PartHeaders<'a>
Source§impl<'a> FieldSection<'a> for PartHeaders<'a>
impl<'a> FieldSection<'a> for PartHeaders<'a>
Source§const NAMES: FieldNames
const NAMES: FieldNames
The names this section declares and forbids, including those of sections it flattens.
Source§fn interpret<I>(fields: I) -> Result<Self, FieldError>
fn interpret<I>(fields: I) -> Result<Self, FieldError>
Interpret a section from its fields in wire order, taking those it declares and discarding the rest. Read more
Source§fn partition<I, R>(fields: I) -> Result<(Self, R), FieldError>where
I: IntoIterator,
<I as IntoIterator>::Item: IntoField<'a, Self>,
R: Default + Extend<FieldRef<'a>>,
fn partition<I, R>(fields: I) -> Result<(Self, R), FieldError>where
I: IntoIterator,
<I as IntoIterator>::Item: IntoField<'a, Self>,
R: Default + Extend<FieldRef<'a>>,
Interpret a section from its fields in wire order, taking those it declares and returning the rest, with their original positions, for another section to interpret. Read more
Source§impl<'a> PartialEq for PartHeaders<'a>
impl<'a> PartialEq for PartHeaders<'a>
impl<'a> StructuralPartialEq for PartHeaders<'a>
Auto Trait Implementations§
impl<'a> Forget for PartHeaders<'a>
impl<'a> Freeze for PartHeaders<'a>
impl<'a> RefUnwindSafe for PartHeaders<'a>
impl<'a> Send for PartHeaders<'a>
impl<'a> Sync for PartHeaders<'a>
impl<'a> Unpin for PartHeaders<'a>
impl<'a> UnsafeUnpin for PartHeaders<'a>
impl<'a> UnwindSafe for PartHeaders<'a>
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