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
sourceimpl PartialEq<MediaType> for MediaType
impl PartialEq<MediaType> for MediaType
impl Copy for MediaType
impl Eq for MediaType
impl StructuralEq 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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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