pub struct HostPort { /* private fields */ }Expand description
Represents a host and port combination.
Implementations§
Source§impl HostPort
impl HostPort
Sourcepub fn new<S: Into<String>>(host: S, port: u16) -> Result<HostPort, ParseError>
pub fn new<S: Into<String>>(host: S, port: u16) -> Result<HostPort, ParseError>
Creates a new HostPort instance.
§Examples
use hostport::HostPort;
let hostport = HostPort::new("localhost", 8080).unwrap();
assert_eq!(hostport.host(), "localhost");
assert_eq!(hostport.port(), 8080);
assert_eq!(hostport.to_string(), "localhost:8080");Trait Implementations§
Source§impl From<&SocketAddrV4> for HostPort
impl From<&SocketAddrV4> for HostPort
Source§fn from(socket_addr: &SocketAddrV4) -> Self
fn from(socket_addr: &SocketAddrV4) -> Self
Converts to this type from the input type.
Source§impl From<SocketAddrV4> for HostPort
impl From<SocketAddrV4> for HostPort
Source§fn from(socket_addr: SocketAddrV4) -> Self
fn from(socket_addr: SocketAddrV4) -> Self
Converts to this type from the input type.
Source§impl Ord for HostPort
impl Ord for HostPort
Source§impl PartialOrd for HostPort
impl PartialOrd for HostPort
Source§impl TryFrom<&str> for HostPort
Implements the From trait for converting a HostPort to a string.
impl TryFrom<&str> for HostPort
Implements the From trait for converting a HostPort to a string.
§Examples
use hostport::HostPort;
let domain = HostPort::try_from("quake.se:28000").unwrap();
assert_eq!(domain.host(), "quake.se");
assert_eq!(domain.port(), 28000);
let ip = HostPort::try_from("10.10.10.10:28000").unwrap();
assert_eq!(ip.host(), "10.10.10.10");
assert_eq!(ip.port(), 28000);
let network_alias = HostPort::try_from("localhost:28000").unwrap();
assert_eq!(network_alias.host(), "localhost");
assert_eq!(network_alias.port(), 28000);impl Eq for HostPort
impl StructuralPartialEq for HostPort
Auto Trait Implementations§
impl Freeze for HostPort
impl RefUnwindSafe for HostPort
impl Send for HostPort
impl Sync for HostPort
impl Unpin for HostPort
impl UnwindSafe for HostPort
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more