Skip to main content

Host

Trait Host 

Source
pub trait Host: Unpin + 'static {
    // Required method
    fn hostname(&self) -> &str;

    // Provided method
    fn port(&self) -> Option<u16> { ... }
}
Expand description

An interface for types where host parts (hostname and port) can be derived.

The WHATWG URL Standard defines the terminology used for this trait and its methods.

+------------------------+
|          host          |
+-----------------+------+
|    hostname     | port |
|                 |      |
| sub.example.com : 8080 |
+-----------------+------+

Required Methods§

Source

fn hostname(&self) -> &str

Extract hostname.

Provided Methods§

Source

fn port(&self) -> Option<u16>

Extract optional port.

Implementations on Foreign Types§

Source§

impl Host for &'static str

Source§

fn hostname(&self) -> &str

Source§

fn port(&self) -> Option<u16>

Source§

impl Host for Uri

Source§

fn hostname(&self) -> &str

Source§

fn port(&self) -> Option<u16>

Source§

impl Host for Uri

Source§

fn hostname(&self) -> &str

Source§

fn port(&self) -> Option<u16>

Source§

impl Host for String

Source§

fn hostname(&self) -> &str

Source§

fn port(&self) -> Option<u16>

Implementors§