[][src]Enum rcgen::CidrSubnet

pub enum CidrSubnet {
    V4([u8; 4][u8; 4]),
    V6([u8; 16][u8; 16]),
}

CIDR subnet, as per RFC 4632

You might know CIDR subnets better by their textual representation where they consist of an ip address followed by a slash and a prefix number, for example 192.168.99.0/24.

The first field in the enum is the address, the second is the mask. Both are specified in network byte order.

Variants

Implementations

impl CidrSubnet[src]

pub fn from_str(s: &str) -> Result<Self, ()>[src]

Obtains the CidrSubnet from the well-known addr/prefix notation.

// The "192.0.2.0/24" example from
// https://tools.ietf.org/html/rfc5280#page-42
let subnet = CidrSubnet::from_str("192.0.2.0/24").unwrap();
assert_eq!(subnet, CidrSubnet::V4([0xC0, 0x00, 0x02, 0x00], [0xFF, 0xFF, 0xFF, 0x00]));

pub fn from_addr_prefix(addr: IpAddr, prefix: u8) -> Self[src]

Obtains the CidrSubnet from an ip address as well as the specified prefix number.

// The "192.0.2.0/24" example from
// https://tools.ietf.org/html/rfc5280#page-42
let addr = IpAddr::from_str("192.0.2.0").unwrap();
let subnet = CidrSubnet::from_addr_prefix(addr, 24);
assert_eq!(subnet, CidrSubnet::V4([0xC0, 0x00, 0x02, 0x00], [0xFF, 0xFF, 0xFF, 0x00]));

pub fn from_v4_prefix(addr: [u8; 4], prefix: u8) -> Self[src]

Obtains the CidrSubnet from an IPv4 address in network byte order as well as the specified prefix.

pub fn from_v6_prefix(addr: [u8; 16], prefix: u8) -> Self[src]

Obtains the CidrSubnet from an IPv6 address in network byte order as well as the specified prefix.

Trait Implementations

impl Clone for CidrSubnet[src]

impl Debug for CidrSubnet[src]

impl Eq for CidrSubnet[src]

impl Hash for CidrSubnet[src]

impl PartialEq<CidrSubnet> for CidrSubnet[src]

impl StructuralEq for CidrSubnet[src]

impl StructuralPartialEq for CidrSubnet[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> Conv for T

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T where
    T: ?Sized

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Tap for T

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.