pub struct ContentType(/* private fields */);Expand description
Content-Type header, defined in RFC 9110 §8.3.
Implementations§
Source§impl ContentType
impl ContentType
Sourcepub const fn form_url_encoded() -> Self
pub const fn form_url_encoded() -> Self
Content-Type: application/x-www-form-urlencoded header.
Sourcepub const fn octet_stream() -> Self
pub const fn octet_stream() -> Self
Content-Type: application/octet-stream header.
Sourcepub const fn plaintext_utf8() -> Self
pub const fn plaintext_utf8() -> Self
Content-Type: text/plain; charset=utf-8 header.
Sourcepub const fn to_header_value(&self) -> HeaderValue
pub const fn to_header_value(&self) -> HeaderValue
Returns a HeaderValue from self’s top level media type with its subtype
and charset if there’s any.
§Example
use worker_route::http::ContentType;
let html_utf8 = ContentType::html_utf8();
let header_value = html_utf8.to_header_value();
assert_eq!(header_value, "text/html; charset=utf-8");Trait Implementations§
Source§impl Debug for ContentType
impl Debug 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 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