Struct fluent_uri::Scheme

source ·
#[repr(transparent)]
pub struct Scheme(_);
Expand description

The scheme component of URI reference.

Implementations§

source§

impl Scheme

source

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");
source

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");
source

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"));

Trait Implementations§

source§

impl Debug for Scheme

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Scheme

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Scheme

§

impl Send for Scheme

§

impl !Sized for Scheme

§

impl Sync for Scheme

§

impl Unpin for Scheme

§

impl UnwindSafe for Scheme

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more