Skip to main content

PartHeaders

Struct PartHeaders 

Source
#[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>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for PartHeaders<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Eq for PartHeaders<'a>

Source§

impl<'a> FieldSection<'a> for PartHeaders<'a>

Source§

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>
where I: IntoIterator, <I as IntoIterator>::Item: IntoField<'a, Self>,

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>>,

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>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.