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>
impl<'a, const LAYOUT_SIZE: usize> LayerLookup<'a, LAYOUT_SIZE>
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
Sourcepub fn trigger_list(
&self,
(layer, ttype, index): (u8, u8, u16),
) -> Option<&'a [u8]>
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.
Sourcepub fn lookup_guides<const LSIZE: usize>(
&self,
(layer, ttype, index): (u8, u8, u16),
) -> Vec<(u16, u16), LSIZE>
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.
Sourcepub fn trigger_guide(
&self,
(trigger, _result): (u16, u16),
offset: u16,
) -> Option<&[TriggerCondition]>
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
Sourcepub fn result_guide(
&self,
(_trigger, result): (u16, u16),
offset: u16,
) -> Option<&[Capability]>
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
Sourcepub fn next_trigger_combo(
&self,
(trigger, _result): (u16, u16),
offset: u16,
) -> Option<u16>
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)
Sourcepub fn next_result_combo(
&self,
(_trigger, result): (u16, u16),
offset: u16,
) -> Option<u16>
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)
Sourcepub fn layer_lookup(&self) -> &FnvIndexMap<(u8, u8, u16), usize, LAYOUT_SIZE>
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
Sourcepub fn max_layers(&self) -> u8
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>
impl<'a, const LAYOUT_SIZE: usize> Clone for LayerLookup<'a, LAYOUT_SIZE>
Source§fn clone(&self) -> LayerLookup<'a, LAYOUT_SIZE>
fn clone(&self) -> LayerLookup<'a, LAYOUT_SIZE>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<'a, const LAYOUT_SIZE: usize> Debug for LayerLookup<'a, LAYOUT_SIZE>
impl<'a, const LAYOUT_SIZE: usize> Debug for LayerLookup<'a, LAYOUT_SIZE>
Source§impl<'a, const LAYOUT_SIZE: usize> PartialEq for LayerLookup<'a, LAYOUT_SIZE>
impl<'a, const LAYOUT_SIZE: usize> PartialEq for LayerLookup<'a, LAYOUT_SIZE>
Source§fn eq(&self, other: &LayerLookup<'a, LAYOUT_SIZE>) -> bool
fn eq(&self, other: &LayerLookup<'a, LAYOUT_SIZE>) -> bool
self
and other
values to be equal, and is used by ==
.