Struct Port

pub struct Port<T> { /* private fields */ }

The port component of a URI.

Implementations

impl<T> Port<T>

const fn as_u16(&self) -> u16

Returns the port number as a u16.

Examples

Port as u16.

# use http::uri::Authority;
let authority: Authority = "example.org:80".parse().unwrap();

let port = authority.port().unwrap();
assert_eq!(port.as_u16(), 80);

impl<T> Port<T> where T: AsRef<str>,

fn as_str(&self) -> &str

Returns the port number as a str.

Examples

Port as str.

# use http::uri::Authority;
let authority: Authority = "example.org:80".parse().unwrap();

let port = authority.port().unwrap();
assert_eq!(port.as_str(), "80");

Trait Implementations

impl<T> AsRef<str> for Port<T> where T: AsRef<str>,

fn as_ref(&self) -> &str

impl<T> Debug for Port<T> where T: Debug,

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

impl<T> Display for Port<T>

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

impl<T> PartialEq<u16> for Port<T>

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

impl<T, U> PartialEq<Port<U>> for Port<T>

fn eq(&self, other: &Port<U>) -> bool

Auto Trait Implementations

impl<T> Freeze for Port<T> where T: Freeze,

impl<T> RefUnwindSafe for Port<T> where T: RefUnwindSafe,

impl<T> Send for Port<T> where T: Send,

impl<T> Sync for Port<T> where T: Sync,

impl<T> Unpin for Port<T> where T: Unpin,

impl<T> UnsafeUnpin for Port<T> where T: UnsafeUnpin,

impl<T> UnwindSafe for Port<T> where T: UnwindSafe,

Blanket Implementations

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

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Port<T> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Port<T> where T: ?Sized,

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

impl<T> From<T> for Port<T>

fn from(t: T) -> T

Returns the argument unchanged.

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

fn to_string(&self) -> String

impl<T, U> Into<U> for Port<T> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom<U> for Port<T> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Port<T> where U: TryFrom<T>,

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