#[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
impl Guid
sourcepub 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
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.
sourcepub const fn as_fields(&self) -> (u32, u16, u16, u8, u8, &[u8; 6])
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.
sourcepub fn from_bytes(bytes: &[u8; 16]) -> Self
pub 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.
Trait Implementations§
source§impl Ord for Guid
impl Ord for Guid
source§impl PartialOrd for Guid
impl PartialOrd for Guid
impl Copy for Guid
impl Eq for Guid
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> 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)