Struct rhymuri::Authority[][src]

pub struct Authority { /* fields omitted */ }

This is the optional part of a URI which governs the URI’s namespace. It typically contains a host name or IP address, and may also include a port number and/or userinfo component.

Examples

Parsing an Authority into its components

use rhymuri::Authority;

let authority = Authority::parse("nobody@www.example.com:8080")?;
assert_eq!(Some("nobody".as_bytes()), authority.userinfo());
assert_eq!("www.example.com".as_bytes(), authority.host());
assert_eq!(Some(8080), authority.port());

Generating a URI from its components

use rhymuri::Authority;

let mut authority = Authority::default();
authority.set_userinfo(Some("nobody").map(Into::into));
authority.set_host("www.example.com");
authority.set_port(Some(8080));
assert_eq!("nobody@www.example.com:8080", authority.to_string());

Implementations

impl Authority[src]

#[must_use = "why u no use host return value?"]pub fn host(&self) -> &[u8][src]

Borrow the host name part of the Authority.

#[must_use = "why did you get the port number and then throw it away?"]pub fn port(&self) -> Option<u16>[src]

Borrow the port number part of the Authority.

pub fn set_userinfo<T>(&mut self, userinfo: T) where
    T: Into<Option<Vec<u8>>>, 
[src]

Change the userinfo part of the Authority.

pub fn set_host<T>(&mut self, host: T) where
    T: Into<Vec<u8>>, 
[src]

Change the host name part of the Authority.

pub fn set_port(&mut self, port: Option<u16>)[src]

Change the port number part of the Authority.

#[must_use = "security breach... security breach... userinfo not used"]pub fn userinfo(&self) -> Option<&[u8]>[src]

Borrow the userinfo part of the Authority.

#[must_use = "you parsed it; don't you want the results?"]pub fn parse<T>(authority_string: T) -> Result<Self, Error> where
    T: AsRef<str>, 
[src]

Interpret the given string as the Authority component of a URI, separating its various subcomponents, returning an Authority value containing them.

Errors

There are many ways to screw up the Authority part of URI string, and this function will let you know what’s up by returning a variant of the Error type.

Trait Implementations

impl Clone for Authority[src]

impl Debug for Authority[src]

impl Default for Authority[src]

impl Display for Authority[src]

impl PartialEq<Authority> for Authority[src]

impl StructuralPartialEq for Authority[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.