ipnet

Trait IpBitOr

Source
pub trait IpBitOr<RHS = Self> {
    type Output;

    // Required method
    fn bitor(self, rhs: RHS) -> Self::Output;
}
Expand description

Provides a bitor() method for Ipv4Addr and Ipv6Addr.

§Examples

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

let ip: Ipv4Addr = "10.1.1.1".parse().unwrap();
let mask: Ipv4Addr = "0.0.0.255".parse().unwrap();
let res: Ipv4Addr = "10.1.1.255".parse().unwrap();

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

assert_eq!(ip.bitor(mask), res);
assert_eq!(ip.bitor(u128::from(0xffffffffu32)), res);

Required Associated Types§

Required Methods§

Source

fn bitor(self, rhs: RHS) -> Self::Output

Implementations on Foreign Types§

Source§

impl IpBitOr for Ipv4Addr

Source§

impl IpBitOr for Ipv6Addr

Source§

impl IpBitOr<u32> for Ipv4Addr

Source§

impl IpBitOr<u128> for Ipv6Addr

Implementors§