pub enum Host<'a> {
Domain(&'a str),
Ipv4(Ipv4Addr),
Ipv6(Ipv6Addr),
}Expand description
Parsed URL host.
use std::net::Ipv6Addr;
use urly::Host;
assert_eq!(Host::parse("example.com").unwrap(), Host::Domain("example.com"));
assert_eq!(Host::parse("[::1]").unwrap(), Host::Ipv6(Ipv6Addr::LOCALHOST));
assert!(Host::parse("exa mple.com").is_err());Variants§
Domain(&'a str)
Registered name
Ipv4(Ipv4Addr)
IPv4 address
Ipv6(Ipv6Addr)
IPv6 address, written in brackets
Implementations§
Source§impl<'a> Host<'a>
impl<'a> Host<'a>
Sourcepub fn parse(src: &'a str) -> Result<Host<'a>, InvalidUrl>
pub fn parse(src: &'a str) -> Result<Host<'a>, InvalidUrl>
Strictly validates and classifies a host.
Sourcepub fn to_unicode(&self) -> Cow<'a, str>
pub fn to_unicode(&self) -> Cow<'a, str>
Returns the host with punycode-encoded labels decoded.
use urly::Host;
let host = Host::parse("xn--mnchen-3ya.de").unwrap();
assert_eq!(host.to_unicode(), "münchen.de");Trait Implementations§
impl<'a> Copy for Host<'a>
impl<'a> Eq for Host<'a>
impl<'a> StructuralPartialEq for Host<'a>
Auto Trait Implementations§
impl<'a> Freeze for Host<'a>
impl<'a> RefUnwindSafe for Host<'a>
impl<'a> Send for Host<'a>
impl<'a> Sync for Host<'a>
impl<'a> Unpin for Host<'a>
impl<'a> UnsafeUnpin for Host<'a>
impl<'a> UnwindSafe for Host<'a>
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