Struct postgres_inet::MaskedIpAddr [] [src]

pub struct MaskedIpAddr { /* fields omitted */ }

An IP address with a netmask.

Methods

impl MaskedIpAddr
[src]

[src]

Creates a new MaskedIpAddr from components.

Panics

Panics if the netmask is greater than 32 for an IPv4 address, or is greater than 128 for an IPv6 address.

Examples

To represent an address:

let ip = Ipv4Addr::new(192, 0, 2, 142);
MaskedIpAddr::new(ip, 32);

To represent a network:

let network = Ipv6Addr::new(0x2001, 0x0DB8, 0, 0, 0, 0, 0, 0);
MaskedIpAddr::new(network, 32);

[src]

Returns true for the special 'unspecified' address.

Examples

assert!(MaskedIpAddr::new(Ipv4Addr::new(0, 0, 0, 0), 32).is_unspecified());
assert!(MaskedIpAddr::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0), 128).is_unspecified());

[src]

Returns true if this is a loopback address.

Examples

assert!(MaskedIpAddr::new(Ipv4Addr::new(127, 0, 0, 1), 32).is_loopback());
assert!(MaskedIpAddr::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), 128).is_loopback());

[src]

Returns true if this is a multicast address.

Examples

assert!(MaskedIpAddr::new(Ipv4Addr::new(224, 254, 0, 0), 32).is_multicast());
assert!(MaskedIpAddr::new(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0), 128).is_multicast());

[src]

Consumes the MaskedIpAddr, returning the IP address and netmask.

Examples

let network = Ipv4Addr::new(198, 51, 100, 0);
let (network_b, netmask) = MaskedIpAddr::new(network.clone(), 24).into_inner();
assert_eq!(network, network_b);
assert_eq!(netmask, 24);

Trait Implementations

impl Clone for MaskedIpAddr
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Eq for MaskedIpAddr
[src]

impl PartialEq for MaskedIpAddr
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Hash for MaskedIpAddr
[src]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl PartialOrd for MaskedIpAddr
[src]

[src]

This method returns an ordering between self and other values if one exists. Read more

[src]

This method tests less than (for self and other) and is used by the < operator. Read more

[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Ord for MaskedIpAddr
[src]

[src]

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

1.22.0
[src]

Compares and returns the maximum of two values. Read more

1.22.0
[src]

Compares and returns the minimum of two values. Read more

impl From<Ipv4Addr> for MaskedIpAddr
[src]

[src]

Performs the conversion.

impl From<Ipv6Addr> for MaskedIpAddr
[src]

[src]

Performs the conversion.

impl From<IpAddr> for MaskedIpAddr
[src]

[src]

Performs the conversion.

impl Display for MaskedIpAddr
[src]

[src]

Formats the value using the given formatter. Read more

impl Debug for MaskedIpAddr
[src]

[src]

Formats the value using the given formatter.

impl FromSql for MaskedIpAddr
[src]

[src]

Creates a new value of this type from a buffer of data of the specified Postgres Type in its binary format. Read more

[src]

Determines if a value of this type can be created from the specified Postgres Type. Read more

Creates a new value of this type from a NULL SQL value. Read more

A convenience function that delegates to from_sql and from_sql_null depending on the value of raw. Read more

impl ToSql for MaskedIpAddr
[src]

[src]

Converts the value of self into the binary format of the specified Postgres Type, appending it to out. Read more

Determines if a value of this type can be converted to the specified Postgres Type. Read more

An adaptor method used internally by Rust-Postgres. Read more