#[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.
Trait Implementations§
impl Copy for Ipv4Addr
Auto Trait Implementations§
impl Freeze for Ipv4Addr
impl RefUnwindSafe for Ipv4Addr
impl Send for Ipv4Addr
impl Sync for Ipv4Addr
impl Unpin for Ipv4Addr
impl UnwindSafe for Ipv4Addr
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)