aboutsummaryrefslogtreecommitdiff
path: root/embassy-usb/src/msos.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-usb/src/msos.rs')
-rw-r--r--embassy-usb/src/msos.rs28
1 files changed, 12 insertions, 16 deletions
diff --git a/embassy-usb/src/msos.rs b/embassy-usb/src/msos.rs
index a285a3ccd..25936d084 100644
--- a/embassy-usb/src/msos.rs
+++ b/embassy-usb/src/msos.rs
@@ -226,27 +226,21 @@ pub mod windows_version {
226 pub const WIN10: u32 = 0x0A000000; 226 pub const WIN10: u32 = 0x0A000000;
227} 227}
228 228
229mod sealed { 229/// A trait for descriptors
230 use core::mem::size_of; 230trait Descriptor: Sized {
231 const TYPE: DescriptorType;
231 232
232 /// A trait for descriptors 233 /// The size of the descriptor's header.
233 pub trait Descriptor: Sized { 234 fn size(&self) -> usize {
234 const TYPE: super::DescriptorType; 235 size_of::<Self>()
235
236 /// The size of the descriptor's header.
237 fn size(&self) -> usize {
238 size_of::<Self>()
239 }
240
241 fn write_to(&self, buf: &mut [u8]);
242 } 236 }
243 237
244 pub trait DescriptorSet: Descriptor { 238 fn write_to(&self, buf: &mut [u8]);
245 const LENGTH_OFFSET: usize;
246 }
247} 239}
248 240
249use sealed::*; 241trait DescriptorSet: Descriptor {
242 const LENGTH_OFFSET: usize;
243}
250 244
251/// Copies the data of `t` into `buf`. 245/// Copies the data of `t` into `buf`.
252/// 246///
@@ -412,9 +406,11 @@ impl DescriptorSet for FunctionSubsetHeader {
412// Feature Descriptors 406// Feature Descriptors
413 407
414/// A marker trait for feature descriptors that are valid at the device level. 408/// A marker trait for feature descriptors that are valid at the device level.
409#[allow(private_bounds)]
415pub trait DeviceLevelDescriptor: Descriptor {} 410pub trait DeviceLevelDescriptor: Descriptor {}
416 411
417/// A marker trait for feature descriptors that are valid at the function level. 412/// A marker trait for feature descriptors that are valid at the function level.
413#[allow(private_bounds)]
418pub trait FunctionLevelDescriptor: Descriptor {} 414pub trait FunctionLevelDescriptor: Descriptor {}
419 415
420/// Table 13. Microsoft OS 2.0 compatible ID descriptor. 416/// Table 13. Microsoft OS 2.0 compatible ID descriptor.