IpAddress

Union IpAddress 

Source
#[repr(C)]
pub union IpAddress { pub addr: [u32; 4], pub v4: Ipv4Address, pub v6: Ipv6Address, }
Expand description

An IPv4 or IPv6 internet protocol address that is ABI compatible with EFI.

Corresponds to the EFI_IP_ADDRESS type in the UEFI specification. This type is defined in the same way as edk2 for compatibility with C code. Note that this is an untagged union, so there’s no way to tell which type of address an IpAddress value contains without additional context.

§Conversions and Relation to core::net

The following From implementations exist:

Fields§

§addr: [u32; 4]

This member serves to align the whole type to a 4 bytes as required by the spec. Note that this is slightly different from repr(align(4)), which would prevent placing this type in a packed structure.

§v4: Ipv4Address

An IPv4 internet protocol address.

§v6: Ipv6Address

An IPv6 internet protocol address.

Implementations§

Source§

impl IpAddress

Source

pub const ZERO: Self

Zeroed variant where all bytes are guaranteed to be initialized to zero.

Source

pub const fn new_v4(octets: [u8; 4]) -> Self

Construct a new IPv4 address.

The type won’t know that it is an IPv6 address and additional context is needed.

§Safety

The constructor only initializes the bytes needed for IPv4 addresses.

Source

pub const fn new_v6(octets: [u8; 16]) -> Self

Construct a new IPv6 address.

The type won’t know that it is an IPv6 address and additional context is needed.

Source

pub unsafe fn into_core_addr(self, is_ipv6: bool) -> IpAddr

Transforms this EFI type to the Rust standard library’s type core::net::IpAddr.

§Arguments
  • is_ipv6: Whether the internal data should be interpreted as IPv6 or IPv4 address.
§Safety

Callers must ensure that the v4 field is valid if is_ipv6 is false, and that the v6 field is valid if is_ipv6 is true

Trait Implementations§

Source§

impl Clone for IpAddress

Source§

fn clone(&self) -> IpAddress

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IpAddress

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for IpAddress

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<[u8; 16]> for IpAddress

Source§

fn from(octets: [u8; 16]) -> Self

Converts to this type from the input type.
Source§

impl From<[u8; 4]> for IpAddress

Source§

fn from(octets: [u8; 4]) -> Self

Converts to this type from the input type.
Source§

impl From<IpAddr> for IpAddress

Source§

fn from(t: IpAddr) -> Self

Converts to this type from the input type.
Source§

impl From<Ipv4Addr> for IpAddress

Source§

fn from(value: Ipv4Addr) -> Self

Converts to this type from the input type.
Source§

impl From<Ipv6Addr> for IpAddress

Source§

fn from(value: Ipv6Addr) -> Self

Converts to this type from the input type.
Source§

impl Copy for IpAddress

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.