Skip to main content

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 (const: unstable)§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for IpAddress

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<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 From<[u8; 4]> for IpAddress

Source§

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

Converts to this type from the input type.
Source§

impl From<[u8; 16]> for IpAddress

Source§

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

Converts to this type from the input type.

Auto Trait Implementations§

§

impl Freeze for IpAddress

§

impl RefUnwindSafe for IpAddress

§

impl Send for IpAddress

§

impl Sync for IpAddress

§

impl Unpin for IpAddress

§

impl UnsafeUnpin for IpAddress

§

impl UnwindSafe for IpAddress

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.