Struct Guid

Source
#[repr(C, align(4))]
pub struct Guid { /* private fields */ }
Expand description

Globally Unique Identifiers

The Guid type represents globally unique identifiers as defined by RFC-4122 (i.e., only the 10x variant is used), with the caveat that LE is used instead of BE.

Note that only the binary representation of Guids is stable. You are highly recommended to interpret Guids as 128bit integers.

The UEFI specification requires the type to be 64-bit aligned, yet EDK2 uses a mere 32-bit alignment. Hence, for compatibility, a 32-bit alignment is used.

UEFI uses the Microsoft-style Guid format. Hence, a lot of documentation and code refers to these Guids. If you thusly cannot treat Guids as 128-bit integers, this Guid type allows you to access the individual fields of the Microsoft-style Guid. A reminder of the Guid encoding:

   0                   1                   2                   3
   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                          time_low                             |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |       time_mid                |         time_hi_and_version   |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |clk_seq_hi_res |  clk_seq_low  |         node (0-1)            |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                         node (2-5)                            |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

The individual fields are encoded as little-endian. Accessors are provided for the Guid structure allowing access to these fields in native endian byte order.

Implementations§

Source§

impl Guid

Source

pub const fn from_fields( time_low: u32, time_mid: u16, time_hi_and_version: u16, clk_seq_hi_res: u8, clk_seq_low: u8, node: &[u8; 6], ) -> Guid

Initialize a Guid from its individual fields

This function initializes a Guid object given the individual fields as specified in the UEFI specification. That is, if you simply copy the literals from the specification into your code, this function will correctly initialize the Guid object.

In other words, this takes the individual fields in native endian and converts them to the correct endianness for a UEFI Guid.

Due to the fact that UEFI Guids use variant 2 of the UUID specification in a little-endian (or even mixed-endian) format, the following transformation is likely applied from text representation to binary representation:

00112233-4455-6677-8899-aabbccddeeff => 33 22 11 00 55 44 77 66 88 99 aa bb cc dd ee ff

(Note that UEFI protocols often use 88-99 instead of 8899) The first 3 parts use little-endian notation, the last 2 use big-endian.

Source

pub const fn as_fields(&self) -> (u32, u16, u16, u8, u8, &[u8; 6])

Access a Guid as individual fields

This decomposes a Guid back into the individual fields as given in the specification. The individual fields are returned in native-endianness.

Source

pub const fn from_bytes(bytes: &[u8; 16]) -> Self

Initialize a Guid from its byte representation

Create a new Guid object from its byte representation. This reinterprets the bytes as a Guid and copies them into a new Guid instance. Note that you can safely transmute instead.

See as_bytes() for the inverse operation.

Source

pub const fn as_bytes(&self) -> &[u8; 16]

Access a Guid as raw byte array

This provides access to a Guid through a byte array. It is a simple re-interpretation of the Guid value as a 128-bit byte array. No conversion is performed. This is a simple cast.

Trait Implementations§

Source§

impl Clone for Guid

Source§

fn clone(&self) -> Guid

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 Guid

Source§

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

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

impl Hash for Guid

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Guid

Source§

fn cmp(&self, other: &Guid) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Guid

Source§

fn eq(&self, other: &Guid) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Guid

Source§

fn partial_cmp(&self, other: &Guid) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Guid

Source§

impl Eq for Guid

Source§

impl StructuralPartialEq for Guid

Auto Trait Implementations§

§

impl Freeze for Guid

§

impl RefUnwindSafe for Guid

§

impl Send for Guid

§

impl Sync for Guid

§

impl Unpin for Guid

§

impl UnwindSafe for Guid

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.