Struct LayerLookup

Source
pub struct LayerLookup<'a, const LAYOUT_SIZE: usize> { /* private fields */ }
Expand description

The LayerLookup struct is used as a guide for the KLL state machine It is a (mostly) constant lookup table which can give you all possible TriggerGuides for a specified input. Each TriggerGuide has a connected ResultGuide which is also stored in this datastructure.

In most cases a (layer, ttype, index) tuple is provided and a list of TriggerGuide:ResultGuide mappings is provided. See lookup_guides().

Implementations§

Source§

impl<'a, const LAYOUT_SIZE: usize> LayerLookup<'a, LAYOUT_SIZE>

Source

pub fn new( raw_layer_lookup: &'a [u8], trigger_guides: &'a [u8], result_guides: &'a [u8], trigger_result_mapping: &'a [u16], loop_condition_lookup: &'a [u32], ) -> Self

Source

pub fn trigger_list( &self, (layer, ttype, index): (u8, u8, u16), ) -> Option<&'a [u8]>

Retrieves a TriggerList A TriggerList is a list of indices that correspond to a specific TriggerGuide -> ResultGuide mapping.

Source

pub fn lookup_guides<const LSIZE: usize>( &self, (layer, ttype, index): (u8, u8, u16), ) -> Vec<(u16, u16), LSIZE>

Retrieves a list of TriggerGuide:ResultGuide mappings Will need to be called for every new TriggerEvent.

Source

pub fn trigger_guide( &self, (trigger, _result): (u16, u16), offset: u16, ) -> Option<&[TriggerCondition]>

Retrieves the TriggerGuide for a given TriggerGuide:ResultGuide pair

offset indicates the number of u8 positions the sequence is currently at. trigger + offset will always point to the start of a combination

Source

pub fn result_guide( &self, (_trigger, result): (u16, u16), offset: u16, ) -> Option<&[Capability]>

Retrieves the ResultGuide for a given TriggerGuide:ResultGuide pair

offset indicates the number of u8 positions the sequence is currently at. result + offset will always point to the start of a combination

Source

pub fn next_trigger_combo( &self, (trigger, _result): (u16, u16), offset: u16, ) -> Option<u16>

Determines the next trigger guide combo offset Returns Some if there is a next offset, None if the next combo is 0 length Will also return None if the current offset is also 0 (shouldn’t be a common use case)

Source

pub fn next_result_combo( &self, (_trigger, result): (u16, u16), offset: u16, ) -> Option<u16>

Determine the next result guide combo offset Returns Some if there is a next offset, None if the next combo is 0 length Will also return None if the current offset is also 0 (shouldn’t be a common use case)

Source

pub fn layer_lookup(&self) -> &FnvIndexMap<(u8, u8, u16), usize, LAYOUT_SIZE>

Convience access for layer_lookup Useful when trying to get a list of all possible triggers

Source

pub fn max_layers(&self) -> u8

Determine the max number of layers

Trait Implementations§

Source§

impl<'a, const LAYOUT_SIZE: usize> Clone for LayerLookup<'a, LAYOUT_SIZE>

Source§

fn clone(&self) -> LayerLookup<'a, LAYOUT_SIZE>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, const LAYOUT_SIZE: usize> Debug for LayerLookup<'a, LAYOUT_SIZE>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, const LAYOUT_SIZE: usize> PartialEq for LayerLookup<'a, LAYOUT_SIZE>

Source§

fn eq(&self, other: &LayerLookup<'a, LAYOUT_SIZE>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, const LAYOUT_SIZE: usize> Eq for LayerLookup<'a, LAYOUT_SIZE>

Source§

impl<'a, const LAYOUT_SIZE: usize> StructuralPartialEq for LayerLookup<'a, LAYOUT_SIZE>

Auto Trait Implementations§

§

impl<'a, const LAYOUT_SIZE: usize> Freeze for LayerLookup<'a, LAYOUT_SIZE>

§

impl<'a, const LAYOUT_SIZE: usize> RefUnwindSafe for LayerLookup<'a, LAYOUT_SIZE>

§

impl<'a, const LAYOUT_SIZE: usize> Send for LayerLookup<'a, LAYOUT_SIZE>

§

impl<'a, const LAYOUT_SIZE: usize> Sync for LayerLookup<'a, LAYOUT_SIZE>

§

impl<'a, const LAYOUT_SIZE: usize> Unpin for LayerLookup<'a, LAYOUT_SIZE>

§

impl<'a, const LAYOUT_SIZE: usize> UnwindSafe for LayerLookup<'a, LAYOUT_SIZE>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.