#[repr(C)]pub struct Guid { /* private fields */ }
Expand description
Globally-unique identifier.
The format is described in Appendix A of the UEFI Specification. Note that the first three fields are little-endian.
This type is 4-byte aligned. The UEFI Specification says the type should be 8-byte aligned, but most C implementations have 4-byte alignment, so we do the same here for compatibility.
Implementations§
source§impl Guid
impl Guid
sourcepub const fn new(
time_low: [u8; 4],
time_mid: [u8; 2],
time_high_and_version: [u8; 2],
clock_seq_high_and_reserved: u8,
clock_seq_low: u8,
node: [u8; 6]
) -> Guid
pub const fn new( time_low: [u8; 4], time_mid: [u8; 2], time_high_and_version: [u8; 2], clock_seq_high_and_reserved: u8, clock_seq_low: u8, node: [u8; 6] ) -> Guid
Create a new GUID.
sourcepub const fn time_high_and_version(self) -> [u8; 2]
pub const fn time_high_and_version(self) -> [u8; 2]
The little-endian high field of the timestamp multiplexed with the version number.
sourcepub const fn clock_seq_high_and_reserved(self) -> u8
pub const fn clock_seq_high_and_reserved(self) -> u8
The high field of the clock sequence multiplexed with the variant.
sourcepub const fn clock_seq_low(self) -> u8
pub const fn clock_seq_low(self) -> u8
The low field of the clock sequence.
sourcepub const fn try_parse(s: &str) -> Result<Guid, GuidFromStrError>
pub const fn try_parse(s: &str) -> Result<Guid, GuidFromStrError>
Parse a GUID from a string.
This is functionally the same as Self::from_str
, but is
exposed separately to provide a const
method for parsing.
sourcepub const fn parse_or_panic(s: &str) -> Guid
pub const fn parse_or_panic(s: &str) -> Guid
Parse a GUID from a string, panicking on failure.
The input must be in “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”
format, where each x
is a hex digit (any of 0-9
, a-f
, or
A-F
).
This function is marked track_caller
so that error messages
point directly to the invalid GUID string.
Panics
This function will panic if the input is not in the format shown above. In particular, it will panic if the input is not exactly 36 bytes long, or if the input does not have separators at the expected positions, or if any of the remaining characters are not valid hex digits.
sourcepub const fn from_bytes(bytes: [u8; 16]) -> Guid
pub const fn from_bytes(bytes: [u8; 16]) -> Guid
Create a GUID from a 16-byte array. No changes to byte order are made.
sourcepub const fn to_ascii_hex_lower(self) -> [u8; 36]
pub const fn to_ascii_hex_lower(self) -> [u8; 36]
Convert to a lower-case hex ASCII string.
The output is in “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx” format.
Trait Implementations§
source§impl FromStr for Guid
impl FromStr for Guid
source§fn from_str(s: &str) -> Result<Guid, <Guid as FromStr>::Err>
fn from_str(s: &str) -> Result<Guid, <Guid as FromStr>::Err>
Parse a GUID from a string, panicking on failure.
The input must be in “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx”
format, where each x
is a hex digit (any of 0-9
, a-f
, or
A-F
).