pub struct ContentType(/* private fields */);Expand description
A part’s Content-Type field: its media type, which RFC 2046 defaults to text/plain; charset=us-ascii and RFC 7578 to text/plain for form data when the field is absent.
use base_web_multipart::ContentType;
use base_message::FieldType;
use base_web_media_type::MediaType;
let content_type = ContentType::parse(b"image/png")?;
assert_eq!(content_type.media_type(), &MediaType::IMAGE_PNG);Implementations§
Source§impl ContentType
impl ContentType
Sourcepub fn media_type(&self) -> &MediaType
pub fn media_type(&self) -> &MediaType
The media type.
Sourcepub fn into_media_type(self) -> MediaType
pub fn into_media_type(self) -> MediaType
The media type, taken from the field.
Trait Implementations§
Source§impl Clone for ContentType
impl Clone for ContentType
Source§impl Debug for ContentType
impl Debug for ContentType
Source§impl Display for ContentType
Writes the media type as a field value.
impl Display for ContentType
Writes the media type as a field value.
impl Eq for ContentType
Source§impl FieldType<'_> for ContentType
impl FieldType<'_> for ContentType
Source§type Combination = Singleton
type Combination = Singleton
Source§fn parse(value: &[u8]) -> Result<Self, FieldValueError>
fn parse(value: &[u8]) -> Result<Self, FieldValueError>
Parse one instance, or one element of a list, with surrounding spaces and tabs already removed. Read more
Source§const INVALID: InvalidValue = InvalidValue::Error
const INVALID: InvalidValue = InvalidValue::Error
What an invalid value means, unless a declaration overrides it with
invalid = "...". A required declaration always treats an invalid value as an error.Source§impl From<ContentType> for MediaType
impl From<ContentType> for MediaType
Source§fn from(content_type: ContentType) -> Self
fn from(content_type: ContentType) -> Self
Converts to this type from the input type.
Source§impl From<MediaType> for ContentType
impl From<MediaType> for ContentType
Source§impl Hash for ContentType
impl Hash for ContentType
Source§impl PartialEq for ContentType
impl PartialEq for ContentType
impl StructuralPartialEq for ContentType
Auto Trait Implementations§
impl Forget for ContentType
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