Thanks to visit codestin.com
Credit goes to docs.rs

Skip to main content

Crate use_host

Crate use_host 

Source
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§

HostKind
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 true when the input is a domain or hostname-like host.
is_ip_host
Returns true when the input is an IP literal host.
is_localhost
Returns true when the input is localhost.
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.