pub struct Scheme { /* private fields */ }
Expand description
Represents the scheme component of a URI
Implementations§
source§impl Scheme
impl Scheme
Attempt to convert a Scheme
from Bytes
This function will be replaced by a TryFrom
implementation once the
trait lands in stable.
Examples
extern crate bytes;
use bytes::Bytes;
let bytes = Bytes::from("http");
let scheme = Scheme::from_shared(bytes).unwrap();
assert_eq!(scheme.as_str(), "http");
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Return a str representation of the scheme
Examples
let scheme: Scheme = "http".parse().unwrap();
assert_eq!(scheme.as_str(), "http");
sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
Converts this Scheme
back to a sequence of bytes
Trait Implementations§
source§impl<'a> HttpTryFrom<&'a [u8]> for Scheme
impl<'a> HttpTryFrom<&'a [u8]> for Scheme
§type Error = InvalidUri
type Error = InvalidUri
Associated error with the conversion this implementation represents.
source§impl<'a> HttpTryFrom<&'a str> for Scheme
impl<'a> HttpTryFrom<&'a str> for Scheme
§type Error = InvalidUri
type Error = InvalidUri
Associated error with the conversion this implementation represents.
source§impl HttpTryFrom<Bytes> for Scheme
impl HttpTryFrom<Bytes> for Scheme
§type Error = InvalidUriBytes
type Error = InvalidUriBytes
Associated error with the conversion this implementation represents.
source§impl HttpTryFrom<Scheme> for Scheme
impl HttpTryFrom<Scheme> for Scheme
source§impl PartialEq<Scheme> for str
impl PartialEq<Scheme> for str
Case-insensitive equality
source§impl PartialEq<str> for Scheme
impl PartialEq<str> for Scheme
Case-insensitive equality
Examples
let scheme: Scheme = "HTTP".parse().unwrap();
assert_eq!(scheme, *"http");