Skip to main content

Crate use_ip

Crate use_ip 

Source
Expand description

§use-ip

use-ip provides small helpers for parsing, normalizing, and classifying IP address literals.

Experimental: this crate is below 0.3.0 and the API may change.

§Example Usage

use use_ip::{detect_ip_kind, is_private_ip, normalize_ip, IpKind};

assert_eq!(detect_ip_kind("192.168.1.20"), IpKind::V4);
assert!(is_private_ip("fd00::1"));
assert_eq!(normalize_ip("2001:0db8::0001"), Some("2001:db8::1".to_string()));

§Scope

  • IP address validation and normalization.
  • Basic IP classifications such as loopback, private, link-local, and multicast.

§Non-goals

  • Geolocation.
  • Network interface inspection.
  • Packet parsing.

§License

Licensed under MIT OR Apache-2.0.

Structs§

IpParts
Stores an original IP-like input with its detected kind.

Enums§

IpKind
Classifies a parsed IP literal.

Functions§

detect_ip_kind
Detects whether the input is IPv4, IPv6, or unknown.
is_ip
Returns true when the input is a valid IPv4 or IPv6 literal.
is_ipv4
Returns true when the input is a valid IPv4 literal.
is_ipv6
Returns true when the input is a valid IPv6 literal.
is_link_local_ip
Returns true when the input is a link-local IPv4 or IPv6 literal.
is_loopback_ip
Returns true when the input is a loopback IP literal.
is_multicast_ip
Returns true when the input is a multicast IP literal.
is_private_ip
Returns true when the input is a private IPv4 or unique-local IPv6 literal.
is_unspecified_ip
Returns true when the input is an unspecified IP literal.
normalize_ip
Normalizes a valid IP literal to Rust’s canonical string form.