Trait BitmaskTrait

Source
pub trait BitmaskTrait {
    type Array: Sized;
    type Index: Copy + IterableEnum;

    const ZERO: Self::Array;

    // Required methods
    fn array_default() -> Self::Array;
    fn array_slice(array: &Self::Array) -> &[u8] ;
    fn array_slice_mut(array: &mut Self::Array) -> &mut [u8] ;
    fn index(index: Self::Index) -> usize;

    // Provided method
    fn index_valid(_array: &Self::Array, _index: Self::Index) -> bool { ... }
}
Expand description

A generic trait that can be used to index by a given type into a set of bits.

Required Associated Constants§

Source

const ZERO: Self::Array

Empty default data.

Required Associated Types§

Source

type Array: Sized

The underlying array storage data type.

Source

type Index: Copy + IterableEnum

The type that the bitmask can be indexed by.

Required Methods§

Source

fn array_default() -> Self::Array

The default empty state of the bitmask.

Source

fn array_slice(array: &Self::Array) -> &[u8]

A representation of the bitmask as a slice of bytes.

Source

fn array_slice_mut(array: &mut Self::Array) -> &mut [u8]

A mutable representation of the bitmask as a slice of bytes.

Source

fn index(index: Self::Index) -> usize

Computes a normalized index value.

Provided Methods§

Source

fn index_valid(_array: &Self::Array, _index: Self::Index) -> bool

Validates whether a given index is valid and in range for the bitmask.

Dynamically allocated bitmasks may not be large enough to contain all indices.

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.

Implementations on Foreign Types§

Source§

impl BitmaskTrait for Vec<u8>

Source§

const ZERO: Self

Source§

type Array = Vec<u8>

Source§

type Index = u16

Source§

fn array_default() -> Self::Array

Source§

fn array_slice(array: &Self::Array) -> &[u8]

Source§

fn array_slice_mut(array: &mut Self::Array) -> &mut [u8]

Source§

fn index(index: Self::Index) -> usize

Source§

fn index_valid(array: &Self::Array, index: Self::Index) -> bool

Implementors§

Source§

impl BitmaskTrait for AbsoluteAxis

Source§

impl BitmaskTrait for AutorepeatKind

Source§

impl BitmaskTrait for EventKind

Source§

impl BitmaskTrait for ForceFeedbackKind

Source§

impl BitmaskTrait for ForceFeedbackStatusKind

Source§

impl BitmaskTrait for InputProperty

Source§

impl BitmaskTrait for Key

Source§

const ZERO: Self::Array

Source§

type Array = [u8; 96]

Source§

type Index = Key

Source§

impl BitmaskTrait for LedKind

Source§

impl BitmaskTrait for MiscKind

Source§

impl BitmaskTrait for RelativeAxis

Source§

impl BitmaskTrait for SoundKind

Source§

impl BitmaskTrait for SwitchKind

Source§

impl BitmaskTrait for SynchronizeKind

Source§

impl BitmaskTrait for UInputKind