Struct tracelogging::Guid
source · [−]#[repr(C)]pub struct Guid { /* private fields */ }
Expand description
Implementations
sourceimpl Guid
impl Guid
sourcepub fn from_name(event_provider_name: &str) -> Self
pub fn from_name(event_provider_name: &str) -> Self
Returns a GUID generated from a case-insensitive hash of the specified trace provider name. The hash uses the same algorithm as many other ETW tools and APIs. Given the same name, it will always generate the same GUID.
assert_eq!(
Guid::from_name("MyProvider"),
Guid::from_u128(&0xb3864c38_4273_58c5_545b_8b3608343471));
sourcepub const fn from_fields(
data1: u32,
data2: u16,
data3: u16,
data4: [u8; 8]
) -> Self
pub const fn from_fields(
data1: u32,
data2: u16,
data3: u16,
data4: [u8; 8]
) -> Self
Creates a GUID from field values.
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]),
Guid::from_bytes_be(&[0xa3, 0xa2, 0xa1, 0xa0, 0xb1, 0xb0, 0xc1, 0xc0, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]));
sourcepub const fn from_bytes_be(bytes_be: &[u8; 16]) -> Self
pub const fn from_bytes_be(bytes_be: &[u8; 16]) -> Self
Creates a GUID from bytes in RFC (big-endian) byte order.
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]),
Guid::from_bytes_be(&[0xa3, 0xa2, 0xa1, 0xa0, 0xb1, 0xb0, 0xc1, 0xc0, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]));
sourcepub const fn from_bytes_le(bytes_le: &[u8; 16]) -> Self
pub const fn from_bytes_le(bytes_le: &[u8; 16]) -> Self
Creates a GUID from bytes in Windows (little-endian) byte order.
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]),
Guid::from_bytes_le(&[0xa0, 0xa1, 0xa2, 0xa3, 0xb0, 0xb1, 0xc0, 0xc1, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]));
sourcepub const fn from_u128(value: &u128) -> Self
pub const fn from_u128(value: &u128) -> Self
Creates a GUID from a u128 value.
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]),
Guid::from_u128(&0xa3a2a1a0_b1b0_c1c0_d7d6d5d4d3d2d1d0));
sourcepub fn try_parse(value: &str) -> Option<Self>
pub fn try_parse(value: &str) -> Option<Self>
Creates a GUID from a string with optional {} and optional ‘-’. Returns None if GUID could not be parsed from the input.
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]),
Guid::try_parse("{a3a2a1a0-b1b0-c1c0-d7d6-d5d4d3d2d1d0}").unwrap());
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]),
Guid::try_parse("a3a2a1a0-b1b0-c1c0-d7d6-d5d4d3d2d1d0").unwrap());
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]),
Guid::try_parse("a3a2a1a0b1b0c1c0d7d6d5d4d3d2d1d0").unwrap());
sourcepub fn try_parse_ascii(value: &[u8]) -> Option<Self>
pub fn try_parse_ascii(value: &[u8]) -> Option<Self>
Creates a GUID from a string with optional {} and optional ‘-’. Returns None if GUID could not be parsed from the input.
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]),
Guid::try_parse_ascii(b"{a3a2a1a0-b1b0-c1c0-d7d6-d5d4d3d2d1d0}").unwrap());
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]),
Guid::try_parse_ascii(b"a3a2a1a0-b1b0-c1c0-d7d6-d5d4d3d2d1d0").unwrap());
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]),
Guid::try_parse_ascii(b"a3a2a1a0b1b0c1c0d7d6d5d4d3d2d1d0").unwrap());
sourcepub const fn to_fields(&self) -> (u32, u16, u16, [u8; 8])
pub const fn to_fields(&self) -> (u32, u16, u16, [u8; 8])
Returns the field values of the GUID as a tuple.
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]).to_fields(),
(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]));
sourcepub const fn to_bytes_be(&self) -> [u8; 16]
pub const fn to_bytes_be(&self) -> [u8; 16]
Returns the bytes of the GUID in RFC byte order (big-endian).
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]).to_bytes_be(),
[0xa3, 0xa2, 0xa1, 0xa0, 0xb1, 0xb0, 0xc1, 0xc0, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]);
sourcepub const fn to_bytes_le(&self) -> [u8; 16]
pub const fn to_bytes_le(&self) -> [u8; 16]
Returns the bytes of the GUID in Windows byte order (little-endian).
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]).to_bytes_le(),
[0xa0, 0xa1, 0xa2, 0xa3, 0xb0, 0xb1, 0xc0, 0xc1, 0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]);
sourcepub const fn to_u128(&self) -> u128
pub const fn to_u128(&self) -> u128
Returns the GUID as a u128 value.
use tracelogging::Guid;
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]).to_u128(),
0xa3a2a1a0_b1b0_c1c0_d7d6d5d4d3d2d1d0);
sourcepub const fn to_utf8_bytes(&self) -> [u8; 36]
pub const fn to_utf8_bytes(&self) -> [u8; 36]
Convert GUID to utf8 string bytes.
To get a &str, use: str::from_utf8(&guid.to_utf8_bytes()).unwrap()
.
use tracelogging::Guid;
assert_eq!(
Guid::from_fields(0xa3a2a1a0, 0xb1b0, 0xc1c0, [0xd7, 0xd6, 0xd5, 0xd4, 0xd3, 0xd2, 0xd1, 0xd0]).to_utf8_bytes(),
*b"a3a2a1a0-b1b0-c1c0-d7d6-d5d4d3d2d1d0");
Trait Implementations
sourceimpl Ord for Guid
impl Ord for Guid
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<Guid> for Guid
impl PartialEq<Guid> for Guid
sourceimpl PartialOrd<Guid> for Guid
impl PartialOrd<Guid> for Guid
sourcefn partial_cmp(&self, other: &Guid) -> Option<Ordering>
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 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for Guid
impl Eq for Guid
impl StructuralEq for Guid
impl StructuralPartialEq for Guid
Auto Trait Implementations
impl RefUnwindSafe for Guid
impl Send for Guid
impl Sync for Guid
impl Unpin for Guid
impl UnwindSafe for Guid
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more