Struct asio::ip::IpAddrV4 [] [src]

pub struct IpAddrV4 {
    // some fields omitted
}

Implements IP version 4 style addresses.

Methods

impl IpAddrV4
[src]

fn new(a: u8, b: u8, c: u8, d: u8) -> IpAddrV4

Make a IpAddrV4. The result will represent the IP address a.b.c.d.

Examples

use asio::ip::IpAddrV4;

let ip = IpAddrV4::new(192,168,0,1);

fn from_bytes(addr: &[u8; 4]) -> IpAddrV4

Make a IpAddrV4 from [u8; 4]

Examples

use asio::ip::IpAddrV4;

let ip = IpAddrV4::from_bytes(&[172,16,0,1]);
assert_eq!(ip, IpAddrV4::new(172,16,0,1));

fn from_ulong(addr: u32) -> IpAddrV4

Make a IpAddrV4 from u32 in host byte order.

Examples

use asio::ip::IpAddrV4;

let ip = IpAddrV4::from_ulong(0x7F000001);
assert_eq!(ip, IpAddrV4::new(127,0,0,1));

fn any() -> IpAddrV4

Make a unspecified IpAddrV4.

Examples

use asio::ip::IpAddrV4;

let ip = IpAddrV4::any();
assert_eq!(ip, IpAddrV4::new(0,0,0,0));

fn loopback() -> IpAddrV4

Make a IpAddrV4 for a loopback address.

Examples

use asio::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 asio::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 asio::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 asio::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 asio::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 asio::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 asio::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 asio::ip::IpAddrV4;

assert!(IpAddrV4::new(224,0,0,1).is_multicast());

Returns true for if this is a link-local address.

The link-local address ranges:

  • 169.254.0.0/16

Examples

use asio::ip::IpAddrV4;

assert!(IpAddrV4::new(169,254,0,0).is_link_local());

fn to_bytes(&self) -> [u8; 4]

Returns 4 octets bytes.

Examples

use asio::ip::IpAddrV4;

assert_eq!(IpAddrV4::new(169,254,0,1).to_bytes(), [169,254,0,1]);

fn to_ulong(&self) -> u32

Returns u32 in host byte order.

Examples

use asio::ip::IpAddrV4;

assert_eq!(IpAddrV4::new(10,0,0,1).to_ulong(), 10*256*256*256+1);

Trait Implementations

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 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 Ord for IpAddrV4
[src]

fn cmp(&self, __arg_0: &IpAddrV4) -> Ordering

This method returns an Ordering between self and other. Read more

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 Eq 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 Default for IpAddrV4
[src]

fn default() -> IpAddrV4

Returns the "default value" for a type. Read more

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

impl Display for IpAddrV4
[src]

fn fmt(&self, f: &mut Formatter) -> Result

Formats the value using the given formatter.

impl Debug for IpAddrV4
[src]

fn fmt(&self, f: &mut Formatter) -> Result

Formats the value using the given formatter.

impl FromStr for IpAddrV4
[src]

type Err = Error

The associated error which can be returned from parsing.

fn from_str(s: &str) -> Result<IpAddrV4>

Parses a string s to return a value of this type. Read more