Struct asyncio::ip::IpAddrV4
[−]
[src]
pub struct IpAddrV4 { /* fields omitted */ }
Implements IP version 4 style addresses.
Methods
impl IpAddrV4
[src]
fn new(a: u8, b: u8, c: u8, d: u8) -> IpAddrV4
Returns a IP-v4 address.
The result will represent the IP address a
.b
.c
.d
.
Examples
use asyncio::ip::IpAddrV4; let ip = IpAddrV4::new(192,168,0,1);
fn any() -> IpAddrV4
Returns a unspecified IP-v4 address.
Examples
use asyncio::ip::IpAddrV4; let ip = IpAddrV4::any(); assert_eq!(ip, IpAddrV4::new(0,0,0,0));
fn loopback() -> IpAddrV4
Returns a IP-v4 address for a loopback address.
Examples
use asyncio::ip::IpAddrV4; let ip = IpAddrV4::loopback(); assert_eq!(ip, IpAddrV4::new(127,0,0,1));
fn is_unspecified(&self) -> bool
Returns true for if this is a unspecified address 0.0.0.0.
Examples
use asyncio::ip::IpAddrV4; assert!(IpAddrV4::any().is_unspecified());
fn is_loopback(&self) -> bool
Return true for if this is a loopback address 127.0.0.1.
Examples
use asyncio::ip::IpAddrV4; assert!(IpAddrV4::loopback().is_loopback());
fn is_class_a(&self) -> bool
Returns true for if this is a class A address.
The class A address ranges:
- 10.0.0.0/8
Examples
use asyncio::ip::IpAddrV4; assert!(IpAddrV4::new(10,0,0,1).is_class_a());
fn is_class_b(&self) -> bool
Returns true for if this is a class B address.
The class B address ranges:
- 172.16.0.0/12
Examples
use asyncio::ip::IpAddrV4; assert!(IpAddrV4::new(172,16,0,1).is_class_b());
fn is_class_c(&self) -> bool
Returns true for if this is a class C address.
The class c address ranges:
- 192.168.0.0/16
Examples
use asyncio::ip::IpAddrV4; assert!(IpAddrV4::new(192,168,0,1).is_class_c());
fn is_private(&self) -> bool
Returns true for if this is a private address.
The private address ranges:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
Examples
use asyncio::ip::IpAddrV4; assert!(IpAddrV4::new(192,168,0,1).is_private());
fn is_multicast(&self) -> bool
Returns true for if this is a class D address.
The class D address ranges:
- 224.0.0.0/4
Examples
use asyncio::ip::IpAddrV4; assert!(IpAddrV4::new(224,0,0,1).is_multicast());
fn is_link_local(&self) -> bool
Returns true for if this is a link-local address.
The link-local address ranges:
- 169.254.0.0/16
Examples
use asyncio::ip::IpAddrV4; assert!(IpAddrV4::new(169,254,0,0).is_link_local());
fn as_bytes(&self) -> &[u8; 4]
Returns 4 octets bytes.
Examples
use asyncio::ip::IpAddrV4; assert_eq!(IpAddrV4::new(169,254,0,1).as_bytes(), &[169,254,0,1]);
fn to_u32(&self) -> u32
Returns u32
in host byte order.
Examples
use asyncio::ip::IpAddrV4; assert_eq!(IpAddrV4::new(10,0,0,1).to_u32(), 10*256*256*256+1);
Trait Implementations
impl Default for IpAddrV4
[src]
impl Clone for IpAddrV4
[src]
fn clone(&self) -> IpAddrV4
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Eq for IpAddrV4
[src]
impl PartialEq for IpAddrV4
[src]
fn eq(&self, __arg_0: &IpAddrV4) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &IpAddrV4) -> bool
This method tests for !=
.
impl Ord for IpAddrV4
[src]
fn cmp(&self, __arg_0: &IpAddrV4) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl PartialOrd for IpAddrV4
[src]
fn partial_cmp(&self, __arg_0: &IpAddrV4) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &IpAddrV4) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &IpAddrV4) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &IpAddrV4) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &IpAddrV4) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Hash for IpAddrV4
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl AddAssign<i64> for IpAddrV4
[src]
fn add_assign(&mut self, rhs: i64)
The method for the +=
operator
impl SubAssign<i64> for IpAddrV4
[src]
fn sub_assign(&mut self, rhs: i64)
The method for the -=
operator