Trait input_linux::bitmask::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 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 Associated Constants§

source

const ZERO: Self::Array

Empty default data.

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl BitmaskTrait for Vec<u8>

§

type Array = Vec<u8>

§

type Index = u16

source§

const ZERO: Self = _

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

§

type Array = [u8; 8]

§

type Index = AbsoluteAxis

source§

const ZERO: Self::Array = _

source§

impl BitmaskTrait for AutorepeatKind

§

type Array = [u8; 1]

§

type Index = AutorepeatKind

source§

const ZERO: Self::Array = _

source§

impl BitmaskTrait for EventKind

§

type Array = [u8; 4]

§

type Index = EventKind

source§

const ZERO: Self::Array = _

source§

impl BitmaskTrait for ForceFeedbackKind

§

type Array = [u8; 16]

§

type Index = ForceFeedbackKind

source§

const ZERO: Self::Array = _

source§

impl BitmaskTrait for ForceFeedbackStatusKind

§

type Array = [u8; 1]

§

type Index = ForceFeedbackStatusKind

source§

const ZERO: Self::Array = _

source§

impl BitmaskTrait for InputProperty

§

type Array = [u8; 4]

§

type Index = InputProperty

source§

const ZERO: Self::Array = _

source§

impl BitmaskTrait for Key

§

type Array = [u8; 96]

§

type Index = Key

source§

const ZERO: Self::Array = _

source§

impl BitmaskTrait for LedKind

§

type Array = [u8; 2]

§

type Index = LedKind

source§

const ZERO: Self::Array = _

source§

impl BitmaskTrait for MiscKind

§

type Array = [u8; 1]

§

type Index = MiscKind

source§

const ZERO: Self::Array = _

source§

impl BitmaskTrait for RelativeAxis

§

type Array = [u8; 2]

§

type Index = RelativeAxis

source§

const ZERO: Self::Array = _

source§

impl BitmaskTrait for SoundKind

§

type Array = [u8; 1]

§

type Index = SoundKind

source§

const ZERO: Self::Array = _

source§

impl BitmaskTrait for SwitchKind

§

type Array = [u8; 3]

§

type Index = SwitchKind

source§

const ZERO: Self::Array = _

source§

impl BitmaskTrait for SynchronizeKind

§

type Array = [u8; 2]

§

type Index = SynchronizeKind

source§

const ZERO: Self::Array = _

source§

impl BitmaskTrait for UInputKind

§

type Array = [u8; 1]

§

type Index = UInputKind

source§

const ZERO: Self::Array = _