pub enum Host<'a> {
Name(&'a [u8]),
V4(Ipv4Addr),
V6(Ipv6Addr),
Future(&'a [u8]),
}Expand description
A host: a registered name, an IP address, or a future IP literal.
Variants§
Name(&'a [u8])
A registered name (reg-name), as sent: case and a trailing dot are
kept, %XX triples are not decoded. Empty when the field was empty.
V4(Ipv4Addr)
A dotted-decimal IPv4 address.
V6(Ipv6Addr)
A bracketed IPv6 address.
Future(&'a [u8])
A bracketed IPvFuture literal (vX.yyy), without the brackets.
Implementations§
Source§impl Host<'_>
impl Host<'_>
Sourcepub fn eq_ignore_ascii_case(&self, other: &Host<'_>) -> bool
pub fn eq_ignore_ascii_case(&self, other: &Host<'_>) -> bool
Whether two hosts are the same: names compared ASCII case-insensitively, IP literals by value.
§Examples
use parse_net::host::parse_host;
assert!(parse_host(b"Example.com")?.eq_ignore_ascii_case(&parse_host(b"example.COM")?));
assert!(parse_host(b"[::1]")?.eq_ignore_ascii_case(&parse_host(b"[0:0::1]")?));Sourcepub fn write_to(&self, out: &mut impl Sink) -> Result<(), WriteError>
pub fn write_to(&self, out: &mut impl Sink) -> Result<(), WriteError>
Writes the host: names as given, IPv6 bracketed in its RFC 5952 form.
§Errors
WriteError::Full; nothing is written when the sink reports its
room.
§Examples
use parse_net::{host::parse_host, SliceSink};
let mut buf = [0u8; 64];
let mut out = SliceSink::new(&mut buf);
parse_host(b"[2001:DB8:0:0:0:0:0:1]")?.write_to(&mut out).expect("room");
assert_eq!(out.written(), b"[2001:db8::1]");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