fluent_uri::component

Struct Scheme

source
pub struct Scheme { /* private fields */ }
Expand description

A scheme component.

§Comparison

Schemes are compared case-insensitively. You should do a case-insensitive comparison if the scheme specification allows both letter cases in the scheme name.

§Examples

use fluent_uri::{component::Scheme, Uri};

const SCHEME_HTTP: &Scheme = Scheme::new_or_panic("http");

let scheme = Uri::parse("HTTP://EXAMPLE.COM/")?.scheme();

// Case-insensitive comparison.
assert_eq!(scheme, SCHEME_HTTP);
// Case-sensitive comparison.
assert_eq!(scheme.as_str(), "HTTP");

Implementations§

source§

impl Scheme

source

pub const fn new_or_panic(s: &str) -> &Scheme

Converts a string slice to &Scheme.

§Panics

Panics if the string is not a valid scheme name according to Section 3.1 of RFC 3986. For a non-panicking variant, use new.

source

pub const fn new(s: &str) -> Option<&Scheme>

Converts a string slice to &Scheme, returning None if the conversion fails.

source

pub fn as_str(&self) -> &str

Returns the scheme component as a string slice.

§Examples
use fluent_uri::Uri;

let uri = Uri::parse("http://example.com/")?;
assert_eq!(uri.scheme().as_str(), "http");
let uri = Uri::parse("HTTP://EXAMPLE.COM/")?;
assert_eq!(uri.scheme().as_str(), "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
source§

impl PartialEq for Scheme

source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Eq for Scheme

Auto Trait Implementations§

§

impl Freeze for Scheme

§

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 T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

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

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more