Skip to main content

Authority

Struct Authority 

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

URL authority: [userinfo "@"] host [":" port].

Implementations§

Source§

impl Authority

Source

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

Returns the component as a string slice.

Source§

impl Authority

Source

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

Strictly validates an authority.

use urly::{Authority, ErrorKind};

let auth = Authority::new("user:[email protected]:8080").unwrap();
assert_eq!(auth.host(), "example.com");
assert_eq!(auth.port_u16(), Some(8080));
assert_eq!(auth.userinfo().unwrap().password(), Some("pw"));

let err = Authority::new("example.com:99999").unwrap_err();
assert_eq!(err.kind(), ErrorKind::PortOutOfRange);
Source

pub fn from_static(src: &'static str) -> &'static Authority

Converts a static string to an authority.

§Panics

Panics if the authority is not valid.

Source

pub fn userinfo(&self) -> Option<&UserInfo>

Returns the userinfo, if present.

Source

pub fn host(&self) -> &str

Returns the host. IPv6 addresses include the brackets.

Source

pub fn port(&self) -> Option<Port<&str>>

Returns the port, if present.

Source

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

Returns the port as a number, if present.

Source

pub fn host_port(&self) -> &str

Returns the authority without the userinfo.

use urly::Authority;

let auth = Authority::new("user:[email protected]:8080").unwrap();
assert_eq!(auth.host_port(), "example.com:8080");

Trait Implementations§

Source§

impl AsRef<str> for Authority

Source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Debug for Authority

Source§

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

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

impl Display for Authority

Source§

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

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

impl Eq for Authority

Source§

impl Hash for Authority

Source§

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

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

impl Ord for Authority

Source§

fn cmp(&self, other: &Authority) -> Ordering

This method returns an Ordering between self and other. Read more
Source§

impl PartialEq for Authority

Source§

fn eq(&self, other: &Authority) -> 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 Authority

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 PartialEq<Authority> for str

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl PartialEq<Authority> for &str

Source§

fn eq(&self, other: &Authority) -> 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 Authority

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 PartialOrd for Authority

Source§

fn partial_cmp(&self, other: &Authority) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

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

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