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
truewhen the input is a valid IPv4 or IPv6 literal. - is_ipv4
- Returns
truewhen the input is a valid IPv4 literal. - is_ipv6
- Returns
truewhen the input is a valid IPv6 literal. - is_
link_ local_ ip - Returns
truewhen the input is a link-local IPv4 or IPv6 literal. - is_
loopback_ ip - Returns
truewhen the input is a loopback IP literal. - is_
multicast_ ip - Returns
truewhen the input is a multicast IP literal. - is_
private_ ip - Returns
truewhen the input is a private IPv4 or unique-local IPv6 literal. - is_
unspecified_ ip - Returns
truewhen the input is an unspecified IP literal. - normalize_
ip - Normalizes a valid IP literal to Rust’s canonical string form.