pub struct Ipv4Addr { /* private fields */ }Expand description
An IPv4 address
Implementations§
Source§impl Ipv4Addr
impl Ipv4Addr
Sourcepub const UNSPECIFIED: Self
pub const UNSPECIFIED: Self
An IPv4 address representing an unspecified address: 0.0.0.0
Sourcepub const fn from_octets(bytes: [u8; 4]) -> Self
pub const fn from_octets(bytes: [u8; 4]) -> Self
Builds a new address from bytes
Sourcepub const fn is_multicast(&self) -> bool
pub const fn is_multicast(&self) -> bool
Returns true if the address is a multicast address.
Sourcepub const fn is_broadcast(&self) -> bool
pub const fn is_broadcast(&self) -> bool
Returns true if the address is a local broadcast address.
Sourcepub const fn is_private(&self) -> bool
pub const fn is_private(&self) -> bool
Returns true if the address is a private address.
Sourcepub const fn is_loopback(&self) -> bool
pub const fn is_loopback(&self) -> bool
Returns true if the address is a loopback address.
Sourcepub const fn is_unicast(&self) -> bool
pub const fn is_unicast(&self) -> bool
Returns true if the address is a unicast address.
Sourcepub const fn is_link_local(&self) -> bool
pub const fn is_link_local(&self) -> bool
Returns true if the address is a link-local address.
Sourcepub const fn is_documentation(&self) -> bool
pub const fn is_documentation(&self) -> bool
Returns true if the address is a documentation address. There are three such unicast ranges IETF RFC 5737:
- 192.0.2.0/24
- 198.51.100.0/24
- 203.0.113.0/24
And one multicast (IETF RFC 5771 / IETF RFC 6676) one:
- 233.252.0.0/24
Sourcepub const fn is_reserved(&self) -> bool
pub const fn is_reserved(&self) -> bool
Returns true if the address is a reserved address.
Note: The underlying core::net version is not yet stable as
of Rust 1.84.1.
Trait Implementations§
Source§impl Emit for Ipv4Addr
impl Emit for Ipv4Addr
Source§fn emit_raw<V: ByteSliceMut>(&self, buf: V) -> usize
fn emit_raw<V: ByteSliceMut>(&self, buf: V) -> usize
Writes this packet’s contents into a target buffer without
performing length checks. Read more
Source§fn needs_emit(&self) -> bool
fn needs_emit(&self) -> bool
Returns whether this packet needs a full re-emit, and
has not been simply modified in-place. Read more
Source§fn emit<V: ByteSliceMut>(&self, buf: V) -> ParseResult<usize>
fn emit<V: ByteSliceMut>(&self, buf: V) -> ParseResult<usize>
Writes this packet’s contents into a target buffer.
Source§fn emit_prefix<V: SplitByteSliceMut>(&self, buf: V) -> ParseResult<V>
fn emit_prefix<V: SplitByteSliceMut>(&self, buf: V) -> ParseResult<V>
Writes this packet’s contents into the start of a target buffer.
Source§fn emit_suffix<V: SplitByteSliceMut>(&self, buf: V) -> ParseResult<V>
fn emit_suffix<V: SplitByteSliceMut>(&self, buf: V) -> ParseResult<V>
Writes this packet’s contents at the end of a target buffer.
Source§impl FromBytes for Ipv4Addr
impl FromBytes for Ipv4Addr
Source§fn ref_from_bytes(
source: &[u8],
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout + Immutable,
fn ref_from_bytes(
source: &[u8],
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout + Immutable,
Source§fn ref_from_prefix(
source: &[u8],
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout + Immutable,
fn ref_from_prefix(
source: &[u8],
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: KnownLayout + Immutable,
Source§fn ref_from_suffix(
source: &[u8],
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: Immutable + KnownLayout,
fn ref_from_suffix(
source: &[u8],
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, Infallible>>where
Self: Immutable + KnownLayout,
Interprets the suffix of the given bytes as a
&Self. Read moreSource§fn mut_from_bytes(
source: &mut [u8],
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
fn mut_from_bytes(
source: &mut [u8],
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
Source§fn mut_from_prefix(
source: &mut [u8],
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
fn mut_from_prefix(
source: &mut [u8],
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
Source§fn mut_from_suffix(
source: &mut [u8],
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
fn mut_from_suffix(
source: &mut [u8],
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, Infallible>>where
Self: IntoBytes + KnownLayout,
Source§impl HeaderLen for Ipv4Addr
impl HeaderLen for Ipv4Addr
Source§const MINIMUM_LENGTH: usize = 4usize
const MINIMUM_LENGTH: usize = 4usize
The minimum number of bytes a packet of this kind occupies
when serialised.
Source§fn packet_length(&self) -> usize
fn packet_length(&self) -> usize
The number of bytes which this packet would occupy when serialised. Read more
Source§impl IntoBytes for Ipv4Addr
impl IntoBytes for Ipv4Addr
Source§fn as_mut_bytes(&mut self) -> &mut [u8]where
Self: FromBytes,
fn as_mut_bytes(&mut self) -> &mut [u8]where
Self: FromBytes,
Gets the bytes of this value mutably. Read more
Source§fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>where
Self: Immutable,
fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>where
Self: Immutable,
Source§impl KnownLayout for Ipv4Addrwhere
Self: Sized,
impl KnownLayout for Ipv4Addrwhere
Self: Sized,
Source§type PointerMetadata = ()
type PointerMetadata = ()
The type of metadata stored in a pointer to
Self. Read moreSource§fn size_for_metadata(meta: Self::PointerMetadata) -> Option<usize>
fn size_for_metadata(meta: Self::PointerMetadata) -> Option<usize>
Computes the size of an object of type
Self with the given pointer
metadata. Read moreSource§impl Ord for Ipv4Addr
impl Ord for Ipv4Addr
Source§impl PartialOrd for Ipv4Addr
impl PartialOrd for Ipv4Addr
Source§impl TryFromBytes for Ipv4Addr
impl TryFromBytes for Ipv4Addr
Source§fn try_ref_from_bytes(
source: &[u8],
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
fn try_ref_from_bytes(
source: &[u8],
) -> Result<&Self, ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
Source§fn try_ref_from_prefix(
source: &[u8],
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
fn try_ref_from_prefix(
source: &[u8],
) -> Result<(&Self, &[u8]), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
Source§fn try_ref_from_suffix(
source: &[u8],
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
fn try_ref_from_suffix(
source: &[u8],
) -> Result<(&[u8], &Self), ConvertError<AlignmentError<&[u8], Self>, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: KnownLayout + Immutable,
Source§fn try_mut_from_bytes(
bytes: &mut [u8],
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
fn try_mut_from_bytes(
bytes: &mut [u8],
) -> Result<&mut Self, ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
Source§fn try_mut_from_prefix(
source: &mut [u8],
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
fn try_mut_from_prefix(
source: &mut [u8],
) -> Result<(&mut Self, &mut [u8]), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
Source§fn try_mut_from_suffix(
source: &mut [u8],
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
fn try_mut_from_suffix(
source: &mut [u8],
) -> Result<(&mut [u8], &mut Self), ConvertError<AlignmentError<&mut [u8], Self>, SizeError<&mut [u8], Self>, ValidityError<&mut [u8], Self>>>where
Self: KnownLayout + IntoBytes,
Source§fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Source§fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Source§fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<Infallible, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
impl Copy for Ipv4Addr
impl Eq for Ipv4Addr
impl Immutable for Ipv4Addr
impl StructuralPartialEq 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
Mutably borrows from an owned value. Read more