Module scope
Available on crate feature
net only.Expand description
Classify IP addresses into special-use IpScopes and enumerate the CIDR
ranges that make up a scope.
super::private::is_private_ip collapses every non-global range into a
single bool. ip_scope keeps the categories apart, so callers can compose
them with ordinary set algebra — the “a / b / a+b” question:
use rama_net::address::ip::scope::{ip_scope, IpScopes};
let ip = [127, 0, 0, 1];
// loopback only
assert_eq!(ip_scope(ip), IpScopes::LOOPBACK);
// "private but not loopback" — PRIVATE and LOOPBACK are distinct bits
assert!(!ip_scope(ip).contains(IpScopes::PRIVATE));
// "private OR loopback"
assert!(ip_scope(ip).intersects(IpScopes::PRIVATE | IpScopes::LOOPBACK));References:
Structs§
- IpScopes
- Special-use scope an IP address belongs to.
Functions§
- ip_
scope - Classify
addrinto the special-useIpScopesit belongs to. - ipv4_
scope - Classify an IPv4 address. See
ip_scope. - ipv6_
scope - Classify an IPv6 address. See
ip_scope. - scope_
cidrs - The CIDR ranges that make up the given
scopesmask, across IPv4 and IPv6.