Expand description
§use-host
use-host provides lightweight helpers for parsing hosts such as localhost, IP literals, and domain-style host names.
Experimental: this crate is below 0.3.0 and the API may change.
§Example Usage
use use_host::{bracket_ipv6_host, parse_host, HostKind};
let host = parse_host("[::1]").unwrap();
assert_eq!(host.kind, HostKind::Ip);
assert_eq!(host.value, "::1");
assert_eq!(bracket_ipv6_host(&host.value), "[::1]");§Scope
- Localhost, IP-literal, and hostname-style host detection.
- Simple host normalization and IPv6 bracket helpers.
§Non-goals
- DNS lookup.
- Public suffix validation.
- Host reachability testing.
§License
Licensed under MIT OR Apache-2.0.
Structs§
- Host
- Stores a normalized host and its detected kind.
Enums§
- Host
Kind - Classifies a host-like input.
Functions§
- bracket_
ipv6_ host - Adds brackets around an IPv6 host and leaves other hosts unchanged.
- detect_
host_ kind - Detects the host kind for a host-like input.
- is_
domain_ host - Returns
truewhen the input is a domain or hostname-like host. - is_
ip_ host - Returns
truewhen the input is an IP literal host. - is_
localhost - Returns
truewhen the input islocalhost. - normalize_
host - Normalizes a host-like input.
- parse_
host - Parses and normalizes a host-like input.
- strip_
brackets - Removes surrounding IPv6-style brackets when present.