Scheme

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) -> &Self

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<&Self>

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

impl Scheme

Source

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

Returns the optional default port of the scheme if it is registered at IANA with a permanent status.

The following table lists all schemes concerned, their default ports, and references:

SchemePortReference
aaa3868RFC 6733
aaas5658RFC 6733
acap674RFC 2244
cap1026RFC 4324
coap5683RFC 7252
coap+tcp5683RFC 8323
coap+ws80RFC 8323
coaps5684RFC 7252
coaps+tcp5684RFC 8323
coaps+ws443RFC 8323
dict2628RFC 2229
dns53RFC 4501
ftp21RFC 1738
go1096RFC 3368
gopher70RFC 4266
http80RFC 9110
https443RFC 9110
icap1344RFC 3507
imap143RFC 5092
ipp631RFC 3510
ipps631RFC 7472
ldap389RFC 4516
mtqp1038RFC 3887
mupdate3905RFC 3656
nfs2049RFC 2224
nntp119RFC 5538
pop110RFC 2384
rtsp554RFC 7826
rtsps322RFC 7826
rtspu554RFC 2326
snmp161RFC 4088
stun3478RFC 7064
stuns5349RFC 7064
telnet23RFC 4248
tip3372RFC 2371
tn327023RFC 6270
turn3478RFC 7065
turns5349RFC 7065
vemmi575RFC 2122
vnc5900RFC 7869
ws80RFC 6455
wss443RFC 6455
z39.50r210RFC 2056
z39.50s210RFC 2056

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 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: &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§

fn to_string(&self) -> String

Converts the given value to a String. Read more