modular_bitfield/private/
traits.rs

1use super::checks;
2
3/// Helper trait for underlying primitives handling of bitfields.
4///
5/// # Note
6///
7/// Must not and cannot be implemented by dependencies.
8#[doc(hidden)]
9pub trait PushBits: checks::private::Sealed {
10    fn push_bits(&mut self, amount: u32, bits: u8);
11}
12
13/// Helper trait for underlying primitives handling of bitfields.
14///
15/// # Note
16///
17/// Must not and cannot be implemented by dependencies.
18#[doc(hidden)]
19pub trait PopBits: checks::private::Sealed {
20    fn pop_bits(&mut self, amount: u32) -> u8;
21}
22
23/// Trait implemented by primitives that drive bitfield manipulations generically.
24#[doc(hidden)]
25pub trait SpecifierBytes: checks::private::Sealed {
26    /// The base type that the specifier is operating on.
27    type Bytes;
28}
29
30pub trait IsU8Compatible: checks::private::Sealed {}
31pub trait IsU16Compatible: checks::private::Sealed {}
32pub trait IsU32Compatible: checks::private::Sealed {}
33pub trait IsU64Compatible: checks::private::Sealed {}
34pub trait IsU128Compatible: checks::private::Sealed {}
35
36impl IsU8Compatible for [(); 8] {}
37impl IsU16Compatible for [(); 16] {}
38impl IsU32Compatible for [(); 32] {}
39impl IsU64Compatible for [(); 64] {}
40impl IsU128Compatible for [(); 128] {}