Trait SocketAddrExt

Source
pub trait SocketAddrExt:
    Sized
    + ToSocketAddrs
    + Copy
    + Display
    + Debug
    + Send
    + Eq
    + Hash {
    // Required methods
    fn is_multicast(&self) -> bool;
    fn port(&self) -> u16;
    fn addr_to_string(&self) -> String;

    // Provided methods
    fn conforming_to(&self, local: Self) -> Option<Self> { ... }
    fn as_uri_buf(&self, scheme: &str) -> UriBuf { ... }
}
Expand description

Extension trait for SocketAddr types that allows the local endpoint get the information it needs.

Required Methods§

Source

fn is_multicast(&self) -> bool

Determines if the address in this SocketAddr is a multicast/broadcast address or not.

Source

fn port(&self) -> u16

Returns the port number for this socket.

A value of zero indicates no specific value.

Source

fn addr_to_string(&self) -> String

Renders the address portion to a string.

Provided Methods§

Source

fn conforming_to(&self, local: Self) -> Option<Self>

Returns a version of this socket address that conforms to the address type of local, or None if such a conversion is not possible.

This method is useful in mixed ipv6/ipv4 environments.

Source

fn as_uri_buf(&self, scheme: &str) -> UriBuf

Creates a URI from this SocketAddr using the given scheme.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SocketAddrExt for SocketAddr

Source§

fn is_multicast(&self) -> bool

Source§

fn port(&self) -> u16

Source§

fn conforming_to(&self, local: Self) -> Option<Self>

Source§

fn addr_to_string(&self) -> String

Source§

fn as_uri_buf(&self, scheme: &str) -> UriBuf

Implementors§