pub struct Guid {
pub data1: u32,
pub data2: u16,
pub data3: u16,
pub data4: [u8; 8],
}Expand description
Canonical 128-bit globally-unique identifier. Layout matches
the MIDL GUID struct in guiddef.h:
typedef struct _GUID {
unsigned long Data1;
unsigned short Data2;
unsigned short Data3;
unsigned char Data4[8];
} GUID;Stored canonically (little-endian on Data1..3, raw bytes on
Data4) so that Self::write_le / Self::read_le
round-trip with the in-memory layout the codec sees.
Fields§
§data1: u32§data2: u16§data3: u16§data4: [u8; 8]Implementations§
Source§impl Guid
impl Guid
Sourcepub const fn new(data1: u32, data2: u16, data3: u16, data4: [u8; 8]) -> Self
pub const fn new(data1: u32, data2: u16, data3: u16, data4: [u8; 8]) -> Self
Build a Guid from its four wire-form fields.
Sourcepub fn parse(s: &str) -> Result<Self, GuidParseError>
pub fn parse(s: &str) -> Result<Self, GuidParseError>
Parse the canonical MIDL string form
{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}. Both the curly
braces and the hyphens at the standard positions are
required; case-insensitive on hex digits. Returns
GuidParseError on any deviation.
This is a const-style parser used in tests to stage
canned IIDs without writing out the four-field struct
literal. The hardcoded IID constants below use
Self::new for readability + const evaluability.
Sourcepub fn to_braced_string(self) -> String
pub fn to_braced_string(self) -> String
Format back into the canonical MIDL string form, in
upper-case hex (which is what StringFromGUID2 emits).
Sourcepub fn write_le(self) -> [u8; 16]
pub fn write_le(self) -> [u8; 16]
Encode the GUID into 16 bytes in the wire layout (LE on
the first three fields, raw on Data4). Suitable for
staging the GUID into guest memory before passing the
pointer to a vtable method.
Sourcepub fn read_le(bytes: &[u8]) -> Option<Self>
pub fn read_le(bytes: &[u8]) -> Option<Self>
Decode 16 bytes laid out per Self::write_le. Returns
None if bytes.len() < 16.