Struct fluent_uri::Scheme
source · #[repr(transparent)]pub struct Scheme(_);
Expand description
The scheme component of URI reference.
Implementations§
source§impl Scheme
impl Scheme
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the scheme as a string slice.
Note that the scheme is case-insensitive. You should typically use
eq_lowercase
for testing if the scheme is a desired one.
Examples
use fluent_uri::Uri;
let uri = Uri::parse("HTTP://example.com/")?;
let scheme = uri.scheme().unwrap();
assert_eq!(scheme.as_str(), "HTTP");
sourcepub fn to_lowercase(&self) -> String
pub fn to_lowercase(&self) -> String
Returns the scheme as a string in lower case.
Examples
use fluent_uri::Uri;
let uri = Uri::parse("HTTP://example.com/")?;
let scheme = uri.scheme().unwrap();
assert_eq!(scheme.to_lowercase(), "http");
sourcepub fn eq_lowercase(&self, other: &str) -> bool
pub fn eq_lowercase(&self, other: &str) -> bool
Checks if the scheme equals case-insensitively with a lowercase string.
This method is slightly faster than str::eq_ignore_ascii_case
but will
always return false
if there is any uppercase letter in the given string.
Examples
use fluent_uri::Uri;
let uri = Uri::parse("HTTP://example.com/")?;
let scheme = uri.scheme().unwrap();
assert!(scheme.eq_lowercase("http"));
// Always return `false` if there's any uppercase letter in the given string.
assert!(!scheme.eq_lowercase("hTTp"));