Trait ipnet::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

§

type Output = Ipv4Addr

source§

fn bitor(self, rhs: u32) -> Ipv4Addr

source§

impl IpBitOr<u128> for Ipv6Addr

§

type Output = Ipv6Addr

source§

fn bitor(self, rhs: u128) -> Ipv6Addr

Implementors§