# Trait ipnet::IpBitAnd [−] [src]

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

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

### `type Output` [src]

Loading content...

## Required methods

### `fn bitand(self, rhs: RHS) -> Self::Output` [src]

Loading content...

## Implementations on Foreign Types

### `impl IpBitAnd<Ipv4Addr> for Ipv4Addr` [src]

#### `type Output = Ipv4Addr`

#### `fn bitand(self, rhs: Ipv4Addr) -> Ipv4Addr` [src]

### `impl IpBitAnd<u32> for Ipv4Addr` [src]

#### `type Output = Ipv4Addr`

#### `fn bitand(self, rhs: u32) -> Ipv4Addr` [src]

### `impl IpBitAnd<Ipv6Addr> for Ipv6Addr` [src]

#### `type Output = Ipv6Addr`

#### `fn bitand(self, rhs: Ipv6Addr) -> Ipv6Addr` [src]

### `impl IpBitAnd<u128> for Ipv6Addr` [src]

#### `type Output = Ipv6Addr`

#### `fn bitand(self, rhs: u128) -> Ipv6Addr` [src]

Loading content...

## Implementors

Loading content...