Struct asyncio::ip::PrefixIpAddrV4
[−]
[src]
pub struct PrefixIpAddrV4 { /* fields omitted */ }
Implements Prefix IP version 4 style addresses.
Methods
impl PrefixIpAddrV4
[src]
fn new(addr: IpAddrV4, netmask: IpAddrV4) -> Option<PrefixIpAddrV4>
Returns new PrefixIpAddrV4.
Examples
use asyncio::ip::{IpAddrV4, PrefixIpAddrV4}; assert!(PrefixIpAddrV4::new(IpAddrV4::new(192,168,100,1), IpAddrV4::new(255,255,255,0)).is_some()); assert!(PrefixIpAddrV4::new(IpAddrV4::new(192,168,100,1), IpAddrV4::new(0,0,0,255)).is_none());
fn from(addr: IpAddrV4, len: u8) -> PrefixIpAddrV4
Returns new PrefixIpAddrV4.
Panics
Panics if len == 0 or len > 32
use asyncio::ip::{IpAddrV4, PrefixIpAddrV4}; PrefixIpAddrV4::from(IpAddrV4::any(), 0); // panic!
fn network(&self) -> IpAddrV4
Returns a network address.
Examples
use asyncio::ip::{IpAddrV4, PrefixIpAddrV4}; let lo = PrefixIpAddrV4::from(IpAddrV4::loopback(), 8); assert_eq!(lo.network(), IpAddrV4::new(127,0,0,0));
fn netmask(&self) -> IpAddrV4
Returns a subnet mask.
Examples
use asyncio::ip::{IpAddrV4, PrefixIpAddrV4}; let lo = PrefixIpAddrV4::from(IpAddrV4::loopback(), 8); assert_eq!(lo.netmask(), IpAddrV4::new(255,0,0,0));
fn netmask_len(&self) -> u8
Returns a length of subnet mask.