pub struct ContentType(/* private fields */);Expand description
MIME content type.
§Equality and hashing
PartialEq / Eq / Hash are derived. To make derived equality
match RFC 2045 §5.1 semantics (type, subtype, and parameter names
are case-insensitive), construction lowercases those tokens. Parameter
values are preserved as-is because their case sensitivity depends on
the parameter (boundary is case-sensitive per RFC 2046 §5.1.1;
charset is case-insensitive per RFC 2046 §4.1.2 but the kernel
leaves the caller’s bytes intact for round-trip fidelity).
Implementations§
Source§impl ContentType
impl ContentType
pub fn as_str(&self) -> &str
Sourcepub fn media_type(&self) -> MediaType<'_>
pub fn media_type(&self) -> MediaType<'_>
Borrowed type/subtype view, with no parameters.
Cheap: it slices the stored string; no allocation. Validation guarantees
a well-formed type/subtype prefix exists.
Sourcepub fn parameters(&self) -> impl Iterator<Item = (&str, ParameterValue<'_>)>
pub fn parameters(&self) -> impl Iterator<Item = (&str, ParameterValue<'_>)>
Iterate (name, value) parameter pairs in declaration order.
Quoted values are returned with surrounding quotes stripped and backslash escapes resolved.
Sourcepub fn parameter(&self, name: &str) -> Option<ParameterValue<'_>>
pub fn parameter(&self, name: &str) -> Option<ParameterValue<'_>>
Look up a parameter by case-insensitive name.
Sourcepub fn boundary(&self) -> Option<ParameterValue<'_>>
pub fn boundary(&self) -> Option<ParameterValue<'_>>
Convenience accessor for the boundary parameter (multipart only).
Sourcepub fn charset(&self) -> Option<ParameterValue<'_>>
pub fn charset(&self) -> Option<ParameterValue<'_>>
Convenience accessor for the charset parameter.
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for ContentType
Available on crate feature arbitrary only.
impl<'a> Arbitrary<'a> for ContentType
arbitrary only.Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl Clone for ContentType
impl Clone for ContentType
Source§fn clone(&self) -> ContentType
fn clone(&self) -> ContentType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContentType
impl Debug for ContentType
Source§impl<'de> Deserialize<'de> for ContentType
Available on crate feature serde only.
impl<'de> Deserialize<'de> for ContentType
serde only.Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Display for ContentType
impl Display for ContentType
Source§impl From<ContentType> for String
impl From<ContentType> for String
Source§fn from(value: ContentType) -> Self
fn from(value: ContentType) -> Self
Source§impl FromStr for ContentType
impl FromStr for ContentType
Source§impl Hash for ContentType
impl Hash for ContentType
Source§impl JsonSchema for ContentType
impl JsonSchema for ContentType
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for ContentType
impl PartialEq for ContentType
Source§impl Serialize for ContentType
Available on crate feature serde only.
impl Serialize for ContentType
serde only.