pub struct ContentType {
pub type_: String,
pub parameters: Vec<(String, String)>,
}Expand description
A parsed Content-Type: a media type plus its parameters.
type_ is the lower-cased media type (e.g. text/html). parameters are
(lower-cased name, value) pairs in header order; values keep their original case.
Fields§
§type_: StringThe media type, lower-cased (e.g. text/html).
parameters: Vec<(String, String)>The parameters as (lower-cased name, value) pairs, in order.
Implementations§
Source§impl ContentType
impl ContentType
Sourcepub fn new(type_: impl Into<String>) -> Self
pub fn new(type_: impl Into<String>) -> Self
Create a ContentType with the given media type and no parameters.
Sourcepub fn with_parameter(
self,
name: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_parameter( self, name: impl Into<String>, value: impl Into<String>, ) -> Self
Builder: add a parameter (consuming and returning self).
Sourcepub fn get_parameter(&self, name: &str) -> Option<&str>
pub fn get_parameter(&self, name: &str) -> Option<&str>
Look up a parameter value by name, case-insensitively.
Matches regardless of how the ContentType was built — parse stores
lower-cased names, but a name added via with_parameter
keeps its case, so both the query and the stored name are lower-cased here.
Trait Implementations§
Source§impl Clone for ContentType
impl Clone for ContentType
Source§fn clone(&self) -> ContentType
fn clone(&self) -> ContentType
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContentType
impl Debug for ContentType
Source§impl Default for ContentType
impl Default for ContentType
Source§fn default() -> ContentType
fn default() -> ContentType
Returns the “default value” for a type. Read more
impl Eq for ContentType
Source§impl PartialEq for ContentType
impl PartialEq for ContentType
Source§fn eq(&self, other: &ContentType) -> bool
fn eq(&self, other: &ContentType) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ContentType
Auto Trait Implementations§
impl Freeze for ContentType
impl RefUnwindSafe for ContentType
impl Send for ContentType
impl Sync for ContentType
impl Unpin for ContentType
impl UnsafeUnpin for ContentType
impl UnwindSafe for ContentType
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