Skip to main content

Scheme

Struct Scheme 

Source
pub struct Scheme(/* private fields */);
Expand description

URL scheme, e.g. https.

Comparison and hashing are ASCII case-insensitive. Schemes of a parsed Url are always lowercase.

Implementations§

Source§

impl Scheme

Source

pub const fn as_str(&self) -> &str

Returns the component as a string slice.

Source§

impl Scheme

Source

pub const HTTP: &'static Scheme

http

Source

pub const HTTPS: &'static Scheme

https

Source

pub const WS: &'static Scheme

ws

Source

pub const WSS: &'static Scheme

wss

Source

pub const AMQP: &'static Scheme

amqp

Source

pub const AMQPS: &'static Scheme

amqps

Source

pub const MQTT: &'static Scheme

mqtt

Source

pub const MQTTS: &'static Scheme

mqtts

Source

pub fn new(src: &str) -> Result<&Scheme, InvalidUrl>

Validates a scheme: ALPHA *( ALPHA / DIGIT / "+" / "-" / "." ).

use urly::{ErrorKind, Scheme};

assert_eq!(Scheme::new("HTTPS").unwrap(), Scheme::HTTPS);
assert_eq!(Scheme::new("1http").unwrap_err().kind(), ErrorKind::InvalidScheme);
Source

pub fn default_port(&self) -> Option<u16>

Returns the default port of well-known schemes.

use urly::Scheme;

assert_eq!(Scheme::HTTPS.default_port(), Some(443));
assert_eq!(Scheme::MQTTS.default_port(), Some(8883));
assert_eq!(Scheme::new("foo").unwrap().default_port(), None);

Trait Implementations§

Source§

impl AsRef<str> for Scheme

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
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 Eq for Scheme

Source§

impl Hash for Scheme

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl PartialEq for Scheme

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialEq<Scheme> for str

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialEq<str> for Scheme

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<'a> TryFrom<&'a str> for &'a Scheme

Source§

type Error = InvalidUrl

The type returned in the event of a conversion error.
Source§

fn try_from(s: &'a str) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

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§

fn to_string(&self) -> String

Converts the given value to a String. Read more