1use std::fmt::Debug;
4use uuid::Uuid;
5use zerocopy::{FromBytes, Immutable, IntoBytes, KnownLayout, LE, U16, U32, Unaligned};
6
7#[repr(C)]
9#[derive(Clone, Eq, PartialEq, IntoBytes, FromBytes, KnownLayout, Immutable, Unaligned, Debug)]
10#[allow(missing_docs)]
11pub struct GuidLe {
12 pub data1: U32<LE>,
13 pub data2: U16<LE>,
14 pub data3: U16<LE>,
15 pub data4: [u8; 8],
16}
17
18impl GuidLe {
19 pub fn get(&self) -> Uuid {
21 Uuid::from_fields(
22 self.data1.get(),
23 self.data2.get(),
24 self.data3.get(),
25 &self.data4,
26 )
27 }
28}
29
30impl From<&Uuid> for GuidLe {
31 fn from(uuid: &Uuid) -> Self {
32 let f = uuid.as_fields();
33 GuidLe {
34 data1: U32::new(f.0),
35 data2: U16::new(f.1),
36 data3: U16::new(f.2),
37 data4: *f.3,
38 }
39 }
40}