pub enum MediaType {
PlainText,
ApplicationJson,
}
Expand description
Wrapper over supported Media Types.
Variants§
Implementations§
Source§impl 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 Eq for MediaType
impl StructuralPartialEq for MediaType
Auto Trait Implementations§
impl Freeze for MediaType
impl RefUnwindSafe for MediaType
impl Send for MediaType
impl Sync for MediaType
impl Unpin for MediaType
impl UnwindSafe for MediaType
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