pub trait IpBitAnd<RHS = Self> {
    type Output;
    fn bitand(self, rhs: RHS) -> Self::Output;
}
Expand description

Provides a bitand() method for Ipv4Addr and Ipv6Addr.

Examples

use std::net::{Ipv4Addr, Ipv6Addr};
use ipnet::IpBitAnd;

let ip: Ipv4Addr = "192.168.1.1".parse().unwrap();
let mask: Ipv4Addr = "255.255.0.0".parse().unwrap();
let res: Ipv4Addr = "192.168.0.0".parse().unwrap();

assert_eq!(ip.bitand(mask), res);
assert_eq!(ip.bitand(0xffff0000), res);
 
let ip: Ipv6Addr = "fd00:1234::1".parse().unwrap();
let mask: Ipv6Addr = "ffff::".parse().unwrap();
let res: Ipv6Addr = "fd00::".parse().unwrap();

assert_eq!(ip.bitand(mask), res);
assert_eq!(ip.bitand(0xffff_0000_0000_0000_0000_0000_0000_0000u128), res);

Associated Types

Required methods

Implementations on Foreign Types

Implementors