diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-03-23 01:44:46 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-03-23 01:45:19 +0100 |
| commit | 4aa4ea99c2c860d3c3012fee55db9b824d2ad2ef (patch) | |
| tree | 604387d49c688c998bb548dd85b12baa2f839bdc /embassy-usb/src | |
| parent | cb1e4e684e6767ba5bcaa018d60ab5c566b19490 (diff) | |
use private_bounds for sealed traits.
Diffstat (limited to 'embassy-usb/src')
| -rw-r--r-- | embassy-usb/src/msos.rs | 28 |
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 | ||
| 229 | mod sealed { | 229 | /// A trait for descriptors |
| 230 | use core::mem::size_of; | 230 | trait 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 | ||
| 249 | use sealed::*; | 241 | trait 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)] | ||
| 415 | pub trait DeviceLevelDescriptor: Descriptor {} | 410 | pub 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)] | ||
| 418 | pub trait FunctionLevelDescriptor: Descriptor {} | 414 | pub 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. |
