pub struct IpTree { /* private fields */ }
Expand description
A radix tree for fast IP lookups.
use std::net::Ipv6Addr;
use caracat::IpTree;
use caracat::utilities::parse_as_ipv6;
let mut tree = IpTree::default();
tree.insert_string("8.8.8.0/24");
tree.insert_string("2001:4860:4860::/64");
assert!(tree.contains(parse_as_ipv6("8.8.8.1").unwrap()));
assert!(!tree.contains(parse_as_ipv6("8.8.9.1").unwrap()));
assert!(tree.contains(parse_as_ipv6("2001:4860:4860::8888").unwrap()));
assert!(!tree.contains(parse_as_ipv6("2001:4860:4861::8888").unwrap()));