Struct fluent_uri::Authority

source ·
#[repr(transparent)]
pub struct Authority<T: Storage> { /* private fields */ }
Expand description

The authority component of URI reference.

Implementations§

source§

impl<'i, 'o, T: Io<'i, 'o>> Authority<T>

source

pub fn as_str(&'i self) -> &'o str

Returns the authority as a string slice.

Panics

Panics if the host subcomponent is already taken.

Examples
use fluent_uri::Uri;

let uri = Uri::parse("ftp://user@[fe80::abcd]:6780/")?;
let authority = uri.authority().unwrap();
assert_eq!(authority.as_str(), "user@[fe80::abcd]:6780");
source

pub fn userinfo(&'i self) -> Option<&'o EStr>

Returns the userinfo subcomponent.

Examples
use fluent_uri::Uri;

let uri = Uri::parse("ftp://user@192.168.1.24/")?;
let authority = uri.authority().unwrap();
assert_eq!(authority.userinfo().unwrap(), "user");
source

pub fn host(&self) -> &Host<T>

Returns the host subcomponent.

Panics

Panics if the host subcomponent is already taken.

source

pub fn port(&'i self) -> Option<&'o str>

Returns the port subcomponent.

Note that in the generic URI syntax, the port may be empty, with leading zeros, or very large. It is up to you to decide whether to deny such a port, fallback to the scheme’s default if it is empty, ignore the leading zeros, or use a different addressing mechanism that allows a large port.

Examples
use fluent_uri::Uri;

let uri = Uri::parse("ssh://device.local:4673/")?;
let authority = uri.authority().unwrap();
assert_eq!(authority.port(), Some("4673"));

let uri = Uri::parse("ssh://device.local:/")?;
let authority = uri.authority().unwrap();
assert_eq!(authority.port(), Some(""));

let uri = Uri::parse("ssh://device.local/")?;
let authority = uri.authority().unwrap();
assert_eq!(authority.port(), None);

Trait Implementations§

source§

impl Debug for Authority<&mut [u8]>

source§

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

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

impl Debug for Authority<&str>

source§

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

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

impl Debug for Authority<String>

source§

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

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

impl Display for Authority<&str>

source§

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

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

impl Display for Authority<String>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for Authority<T>

§

impl<T> Send for Authority<T>

§

impl<T> Sync for Authority<T>

§

impl<T> Unpin for Authority<T>where T: Unpin, <T as Storage>::Ptr: Unpin,

§

impl<T> UnwindSafe for Authority<T>where T: UnwindSafe, <T as Storage>::Ptr: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

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

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.