std:🥅:IpAddr - Rust (original) (raw)
Enum std::net::IpAddr1.7.0 [−] [src]
pub enum IpAddr { V4(Ipv4Addr), V6(Ipv6Addr), }
An IP address, either IPv4 or IPv6.
This enum can contain either an Ipv4Addr or an Ipv6Addr, see their respective documentation for more details.
use std:🥅:{IpAddr, Ipv4Addr, Ipv6Addr};
let localhost_v4 = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)); let localhost_v6 = IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1));
assert_eq!("127.0.0.1".parse(), Ok(localhost_v4)); assert_eq!("::1".parse(), Ok(localhost_v6));
assert_eq!(localhost_v4.is_ipv6(), false); assert_eq!(localhost_v4.is_ipv4(), true);Run
An IPv4 address.
An IPv6 address.
impl [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
[src]
pub fn [is_unspecified](#method.is%5Funspecified)(&self) -> [bool](../primitive.bool.html)
1.12.0
Returns true for the special 'unspecified' address.
See the documentation for Ipv4Addr::is_unspecified andIpv6Addr::is_unspecified for more details.
use std:🥅:{IpAddr, Ipv4Addr, Ipv6Addr};
assert_eq!(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)).is_unspecified(), true); assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0)).is_unspecified(), true);Run
pub fn [is_loopback](#method.is%5Floopback)(&self) -> [bool](../primitive.bool.html)
1.12.0
Returns true if this is a loopback address.
See the documentation for Ipv4Addr::is_loopback andIpv6Addr::is_loopback for more details.
use std:🥅:{IpAddr, Ipv4Addr, Ipv6Addr};
assert_eq!(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)).is_loopback(), true); assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 0x1)).is_loopback(), true);Run
pub fn [is_global](#method.is%5Fglobal)(&self) -> [bool](../primitive.bool.html)
[src]
🔬 This is a nightly-only experimental API. (ip
#27709)
extra functionality has not been scrutinized to the level that it should be to be stable
Returns true if the address appears to be globally routable.
See the documentation for Ipv4Addr::is_global andIpv6Addr::is_global for more details.
#![feature(ip)]
use std:🥅:{IpAddr, Ipv4Addr, Ipv6Addr};
fn main() { assert_eq!(IpAddr::V4(Ipv4Addr::new(80, 9, 12, 3)).is_global(), true); assert_eq!(IpAddr::V6(Ipv6Addr::new(0, 0, 0x1c9, 0, 0, 0xafc8, 0, 0x1)).is_global(), true); }Run
pub fn [is_multicast](#method.is%5Fmulticast)(&self) -> [bool](../primitive.bool.html)
1.12.0
Returns true if this is a multicast address.
See the documentation for Ipv4Addr::is_multicast andIpv6Addr::is_multicast for more details.
use std:🥅:{IpAddr, Ipv4Addr, Ipv6Addr};
assert_eq!(IpAddr::V4(Ipv4Addr::new(224, 254, 0, 0)).is_multicast(), true); assert_eq!(IpAddr::V6(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0)).is_multicast(), true);Run
pub fn [is_documentation](#method.is%5Fdocumentation)(&self) -> [bool](../primitive.bool.html)
[src]
🔬 This is a nightly-only experimental API. (ip
#27709)
extra functionality has not been scrutinized to the level that it should be to be stable
Returns true if this address is in a range designated for documentation.
See the documentation for Ipv4Addr::is_documentation andIpv6Addr::is_documentation for more details.
#![feature(ip)]
use std:🥅:{IpAddr, Ipv4Addr, Ipv6Addr};
fn main() { assert_eq!(IpAddr::V4(Ipv4Addr::new(203, 0, 113, 6)).is_documentation(), true); assert_eq!(IpAddr::V6(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0)) .is_documentation(), true); }Run
pub fn [is_ipv4](#method.is%5Fipv4)(&self) -> [bool](../primitive.bool.html)
1.16.0
Returns true if this address is an IPv4 address, and false otherwise.
use std:🥅:{IpAddr, Ipv4Addr, Ipv6Addr};
fn main() { assert_eq!(IpAddr::V4(Ipv4Addr::new(203, 0, 113, 6)).is_ipv4(), true); assert_eq!(IpAddr::V6(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0)).is_ipv4(), false); }Run
pub fn [is_ipv6](#method.is%5Fipv6)(&self) -> [bool](../primitive.bool.html)
1.16.0
Returns true if this address is an IPv6 address, and false otherwise.
use std:🥅:{IpAddr, Ipv4Addr, Ipv6Addr};
fn main() { assert_eq!(IpAddr::V4(Ipv4Addr::new(203, 0, 113, 6)).is_ipv6(), false); assert_eq!(IpAddr::V6(Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 0)).is_ipv6(), true); }Run
impl [Copy](../../std/marker/trait.Copy.html "trait std:📑:Copy") for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
[src]
impl [Clone](../../std/clone/trait.Clone.html "trait std::clone::Clone") for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
[src]
impl [Eq](../../std/cmp/trait.Eq.html "trait std::cmp::Eq") for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
[src]
impl [PartialEq](../../std/cmp/trait.PartialEq.html "trait std::cmp::PartialEq") for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
[src]
impl [Debug](../../std/fmt/trait.Debug.html "trait std::fmt::Debug") for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
[src]
impl [Hash](../../std/hash/trait.Hash.html "trait std::hash::Hash") for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
[src]
impl [PartialOrd](../../std/cmp/trait.PartialOrd.html "trait std::cmp::PartialOrd") for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
[src]
impl [Ord](../../std/cmp/trait.Ord.html "trait std::cmp::Ord") for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
[src]
impl [Display](../../std/fmt/trait.Display.html "trait std::fmt::Display") for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
[src]
impl [From](../../std/convert/trait.From.html "trait std::convert::From")<[Ipv4Addr](../../std/net/struct.Ipv4Addr.html "struct std:🥅:Ipv4Addr")> for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
1.16.0
impl [From](../../std/convert/trait.From.html "trait std::convert::From")<[Ipv6Addr](../../std/net/struct.Ipv6Addr.html "struct std:🥅:Ipv6Addr")> for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
1.16.0
impl [PartialEq](../../std/cmp/trait.PartialEq.html "trait std::cmp::PartialEq")<[Ipv4Addr](../../std/net/struct.Ipv4Addr.html "struct std:🥅:Ipv4Addr")> for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
1.16.0
impl [PartialEq](../../std/cmp/trait.PartialEq.html "trait std::cmp::PartialEq")<[IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")> for [Ipv4Addr](../../std/net/struct.Ipv4Addr.html "struct std:🥅:Ipv4Addr")
1.16.0
fn [eq](../../std/cmp/trait.PartialEq.html#tymethod.eq)(&self, other: &[IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")) -> [bool](../primitive.bool.html)
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn [ne](../../std/cmp/trait.PartialEq.html#method.ne)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests for !=
.
impl [PartialOrd](../../std/cmp/trait.PartialOrd.html "trait std::cmp::PartialOrd")<[Ipv4Addr](../../std/net/struct.Ipv4Addr.html "struct std:🥅:Ipv4Addr")> for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
1.16.0
fn [partial_cmp](../../std/cmp/trait.PartialOrd.html#tymethod.partial%5Fcmp)(&self, other: &[Ipv4Addr](../../std/net/struct.Ipv4Addr.html "struct std:🥅:Ipv4Addr")) -> [Option](../../std/option/enum.Option.html "enum std::option::Option")<[Ordering](../../std/cmp/enum.Ordering.html "enum std::cmp::Ordering")>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn [lt](../../std/cmp/trait.PartialOrd.html#method.lt)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn [le](../../std/cmp/trait.PartialOrd.html#method.le)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn [gt](../../std/cmp/trait.PartialOrd.html#method.gt)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn [ge](../../std/cmp/trait.PartialOrd.html#method.ge)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl [PartialOrd](../../std/cmp/trait.PartialOrd.html "trait std::cmp::PartialOrd")<[IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")> for [Ipv4Addr](../../std/net/struct.Ipv4Addr.html "struct std:🥅:Ipv4Addr")
1.16.0
fn [partial_cmp](../../std/cmp/trait.PartialOrd.html#tymethod.partial%5Fcmp)(&self, other: &[IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")) -> [Option](../../std/option/enum.Option.html "enum std::option::Option")<[Ordering](../../std/cmp/enum.Ordering.html "enum std::cmp::Ordering")>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn [lt](../../std/cmp/trait.PartialOrd.html#method.lt)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn [le](../../std/cmp/trait.PartialOrd.html#method.le)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn [gt](../../std/cmp/trait.PartialOrd.html#method.gt)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn [ge](../../std/cmp/trait.PartialOrd.html#method.ge)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl [From](../../std/convert/trait.From.html "trait std::convert::From")<[[](../primitive.array.html)[u8](../primitive.u8.html)[; 4]](../primitive.array.html)> for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
1.17.0
impl [PartialEq](../../std/cmp/trait.PartialEq.html "trait std::cmp::PartialEq")<[IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")> for [Ipv6Addr](../../std/net/struct.Ipv6Addr.html "struct std:🥅:Ipv6Addr")
1.16.0
fn [eq](../../std/cmp/trait.PartialEq.html#tymethod.eq)(&self, other: &[IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")) -> [bool](../primitive.bool.html)
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn [ne](../../std/cmp/trait.PartialEq.html#method.ne)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests for !=
.
impl [PartialEq](../../std/cmp/trait.PartialEq.html "trait std::cmp::PartialEq")<[Ipv6Addr](../../std/net/struct.Ipv6Addr.html "struct std:🥅:Ipv6Addr")> for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
1.16.0
impl [PartialOrd](../../std/cmp/trait.PartialOrd.html "trait std::cmp::PartialOrd")<[Ipv6Addr](../../std/net/struct.Ipv6Addr.html "struct std:🥅:Ipv6Addr")> for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
1.16.0
fn [partial_cmp](../../std/cmp/trait.PartialOrd.html#tymethod.partial%5Fcmp)(&self, other: &[Ipv6Addr](../../std/net/struct.Ipv6Addr.html "struct std:🥅:Ipv6Addr")) -> [Option](../../std/option/enum.Option.html "enum std::option::Option")<[Ordering](../../std/cmp/enum.Ordering.html "enum std::cmp::Ordering")>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn [lt](../../std/cmp/trait.PartialOrd.html#method.lt)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn [le](../../std/cmp/trait.PartialOrd.html#method.le)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn [gt](../../std/cmp/trait.PartialOrd.html#method.gt)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn [ge](../../std/cmp/trait.PartialOrd.html#method.ge)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl [PartialOrd](../../std/cmp/trait.PartialOrd.html "trait std::cmp::PartialOrd")<[IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")> for [Ipv6Addr](../../std/net/struct.Ipv6Addr.html "struct std:🥅:Ipv6Addr")
1.16.0
fn [partial_cmp](../../std/cmp/trait.PartialOrd.html#tymethod.partial%5Fcmp)(&self, other: &[IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")) -> [Option](../../std/option/enum.Option.html "enum std::option::Option")<[Ordering](../../std/cmp/enum.Ordering.html "enum std::cmp::Ordering")>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn [lt](../../std/cmp/trait.PartialOrd.html#method.lt)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn [le](../../std/cmp/trait.PartialOrd.html#method.le)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn [gt](../../std/cmp/trait.PartialOrd.html#method.gt)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn [ge](../../std/cmp/trait.PartialOrd.html#method.ge)(&self, other: [&](../primitive.reference.html)Rhs) -> [bool](../primitive.bool.html)
1.0.0
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl [From](../../std/convert/trait.From.html "trait std::convert::From")<[[](../primitive.array.html)[u8](../primitive.u8.html)[; 16]](../primitive.array.html)> for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
1.17.0
impl [From](../../std/convert/trait.From.html "trait std::convert::From")<[[](../primitive.array.html)[u16](../primitive.u16.html)[; 8]](../primitive.array.html)> for [IpAddr](../../std/net/enum.IpAddr.html "enum std:🥅:IpAddr")
1.17.0