xinput/structures/
dsound_audio_device_guids.rs1#[cfg(doc)] use crate::*;
2use winapi::shared::guiddef::GUID;
3use bytemuck::*;
4
5use core::cmp::*;
6use core::fmt::{self, Debug, Display, Formatter};
7use core::hash::*;
8
9
10
11#[derive(Clone, Copy)]
14#[repr(transparent)] pub struct DSoundAudioDeviceGuid(pub(crate) GUID);
15
16impl DSoundAudioDeviceGuid {
17 pub const NULL : Self = Self(GUID { Data1: 0, Data2: 0, Data3: 0, Data4: [0; 8] });
19}
20
21unsafe impl Pod for DSoundAudioDeviceGuid {}
22unsafe impl Zeroable for DSoundAudioDeviceGuid {}
23impl Default for DSoundAudioDeviceGuid { fn default() -> Self { Self::zeroed() } }
24
25impl Debug for DSoundAudioDeviceGuid { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { self.fmt_impl(fmt) } }
26impl Display for DSoundAudioDeviceGuid { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { self.fmt_impl(fmt) } }
27
28impl AsRef<Self> for DSoundAudioDeviceGuid { fn as_ref(& self) -> & Self { self } }
29impl AsMut<Self> for DSoundAudioDeviceGuid { fn as_mut(&mut self) -> &mut Self { self } }
30
31impl Eq for DSoundAudioDeviceGuid {}
32impl PartialEq for DSoundAudioDeviceGuid { fn eq(&self, other: &Self) -> bool { self.as_bytes() == other.as_bytes() } }
33impl Ord for DSoundAudioDeviceGuid { fn cmp(&self, other: &Self) -> Ordering { self.as_bytes().cmp(other.as_bytes()) } }
34impl PartialOrd for DSoundAudioDeviceGuid { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { self.as_bytes().partial_cmp(other.as_bytes()) } }
35impl Hash for DSoundAudioDeviceGuid { fn hash<H: Hasher>(&self, state: &mut H) { self.as_bytes().hash(state) } }
36
37impl DSoundAudioDeviceGuid {
38 fn fmt_impl(&self, fmt: &mut Formatter) -> fmt::Result {
39 let GUID { Data1: a, Data2: b, Data3: c, Data4: [d0, d1, d2, d3, d4, d5, d6, d7] } = self.0;
40 write!(fmt, "{{{a:08X}-{b:04X}-{c:04X}-{d0:02X}{d1:02X}-{d2:02X}{d3:02X}{d4:02X}{d5:02X}{d6:02X}{d7:02X}}}")
41 }
42
43 fn as_bytes(&self) -> &[u8] { bytemuck::bytes_of(self) }
44}
45
46
47
48#[derive(Clone, Copy, Debug)]
51#[derive(Default, Pod, Zeroable)]
52#[repr(C)] pub struct DSoundAudioDeviceGuids {
53 pub dsound_render_guid: DSoundAudioDeviceGuid,
55
56 pub dsound_capture_guid: DSoundAudioDeviceGuid,
58}
59
60
61
62#[test] fn test_traits_for_coverage() {
63 let _audio = DSoundAudioDeviceGuids::default();
64 let _audio = DSoundAudioDeviceGuids::zeroed();
65 let _audio = _audio.clone();
66 dbg!(_audio);
67}
68
69#[test] fn test_display() {
70 assert_eq!("{6B29FC40-CA47-1067-B31D-00DD010662DA}", DSoundAudioDeviceGuid(GUID { Data1: 0x6B29FC40, Data2: 0xCA47, Data3: 0x1067, Data4: *b"\xB3\x1D\x00\xDD\x01\x06\x62\xDA" }).to_string());
71}
72
73