pub enum MediaType {
PlainText,
ApplicationJson,
}Expand description
Wrapper over supported Media Types.
Variants
PlainText
Media Type: “text/plain”.
ApplicationJson
Media Type: “application/json”.
Implementations
sourceimpl MediaType
impl MediaType
sourcepub fn try_from(bytes: &[u8]) -> Result<Self, RequestError>
pub fn try_from(bytes: &[u8]) -> Result<Self, RequestError>
Parses a byte slice into a MediaType structure for a HTTP request. MediaType must be ASCII, so also UTF-8 valid.
Errors
The function returns InvalidRequest when parsing the byte stream fails or
unsupported MediaType found.
Examples
use dbs_uhttp::MediaType;
assert!(MediaType::try_from(b"application/json").is_ok());
assert!(MediaType::try_from(b"application/json2").is_err());Trait Implementations
impl Copy for MediaType
impl StructuralPartialEq for MediaType
Auto Trait Implementations
impl RefUnwindSafe for MediaType
impl Send for MediaType
impl Sync for MediaType
impl Unpin for MediaType
impl UnwindSafe for MediaType
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more