pub trait BitFieldTrait<S>{
type Type: Copy + FromBitfield<S> + ToBitfield<S> + PartialEq + Eq;
const NEXT_BIT: usize;
// Required methods
fn mask() -> S;
fn mask_in_place() -> S;
fn shift() -> usize;
fn bitsize() -> usize;
fn encode(value: Self::Type) -> S;
fn decode(storage: S) -> Self::Type;
fn update(value: Self::Type, original: S) -> S;
fn is_valid(value: Self::Type) -> bool;
fn encode_unchecked(value: Self::Type) -> S;
}
Expand description
Bitfield trait implementation, this is used to allow easy generic storage/value usage.
Without it it’s hard to get working storage/value generics.
Required Associated Constants§
Required Associated Types§
Sourcetype Type: Copy + FromBitfield<S> + ToBitfield<S> + PartialEq + Eq
type Type: Copy + FromBitfield<S> + ToBitfield<S> + PartialEq + Eq
Type we encode/decode in bitfield
Required Methods§
Sourcefn mask_in_place() -> S
fn mask_in_place() -> S
In place mask of this bitfield
Sourcefn update(value: Self::Type, original: S) -> S
fn update(value: Self::Type, original: S) -> S
Updates the value in storage original
, returns updated storage
Sourcefn encode_unchecked(value: Self::Type) -> S
fn encode_unchecked(value: Self::Type) -> S
Unchecked encode of value
, all bits that can’t be encoded will be stripped down.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.