#[repr(C)]pub struct Ipv4Addr { /* private fields */ }
Expand description
Representation of an IPv4 host address.
Note that this isn’t an IPv4 socket address type; use SockAddrIpv4
to represent both the host address and port number for an IPv4 socket.
Implementations§
Source§impl Ipv4Addr
impl Ipv4Addr
Sourcepub const UNSPEC_GROUP: Self
pub const UNSPEC_GROUP: Self
Equivalent to the constant INADDR_UNSPEC_GROUP
in C.
Sourcepub const ALLHOSTS_GROUP: Self
pub const ALLHOSTS_GROUP: Self
Equivalent to the constant INADDR_ALLHOSTS_GROUP
in C.
Sourcepub const ALLRTRS_GROUP: Self
pub const ALLRTRS_GROUP: Self
Equivalent to the constant INADDR_ALLRTRS_GROUP
in C.
Sourcepub const ALLSNOOPERS_GROUP: Self
pub const ALLSNOOPERS_GROUP: Self
Equivalent to the constant INADDR_ALLSNOOPERS_GROUP
in C.
Sourcepub const fn from_u32(raw: u32) -> Self
pub const fn from_u32(raw: u32) -> Self
Constructs an Ipv4Addr
directly from a u32 value written in the
host byte order.
For example, the standard loopback address 127.0.0.1
should be
provided as 0x7f000001
on all platforms, which would be encoded as
[0x01, 0x00, 0x00, 0x7f]
on a little-endian system but this
function will then convert it to network byte order automatically.
Sourcepub const fn from_octets(raw: [u8; 4]) -> Self
pub const fn from_octets(raw: [u8; 4]) -> Self
Constructs an Ipv4Addr
from the given octets which are interpreted
in network byte order, meaning that the first element corresponds with
the first decimal digit in the conventional four-segment dotted decimal
IP address representation.
Sourcepub const fn as_u32(&self) -> u32
pub const fn as_u32(&self) -> u32
Returns the raw u32 value of the address in host (not network) byte order.
Sourcepub const fn as_octets(&self) -> [u8; 4]
pub const fn as_octets(&self) -> [u8; 4]
Returns the raw octets of the address in network byte order.
Sourcepub const fn to_ipv6_mapped(&self) -> Ipv6Addr
pub const fn to_ipv6_mapped(&self) -> Ipv6Addr
Returns the same IP address in the “IPv6 mapped” form.