Skip to main content

Context

Trait Context 

Source
pub trait Context: Clone + Copy {
    type Event;

    // Required methods
    fn handle_event(
        &mut self,
        event: Event<Self::Event>,
    ) -> KeyEvents<Self::Event>;
    fn reset(&mut self);
}
Expand description

Used to provide state that may affect behaviour when pressing the key.

e.g. the behaviour of layered::LayeredKey depends on which layers are active in layered::Context.

Required Associated Types§

Source

type Event

The type of Event the context handles.

Required Methods§

Source

fn handle_event(&mut self, event: Event<Self::Event>) -> KeyEvents<Self::Event>

Used to update the Context’s state.

Source

fn reset(&mut self)

Restore runtime state from this context’s keymap config.

Config data (timeouts, chords, …) is preserved; ephemeral state (active layers, sticky mods, queues, …) is cleared.

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.

Implementors§

Source§

impl Context for smart_keymap_core::key::caps_word::Context

Source§

impl Context for smart_keymap_core::key::history::Context

Source§

impl Context for smart_keymap_core::key::keyboard::Context

Source§

impl Context for smart_keymap_core::key::sticky::Context

Source§

impl<const INSTRUCTION_COUNT: usize> Context for smart_keymap_core::key::automation::Context<INSTRUCTION_COUNT>

Source§

impl<const LAYER_COUNT: usize, const CONDITIONAL_LAYER_COUNT: usize> Context for smart_keymap_core::key::layered::Context<LAYER_COUNT, CONDITIONAL_LAYER_COUNT>

Source§

impl<const MAX_CHORDS: usize, const MAX_CHORD_SIZE: usize, const MAX_PRESSED_INDICES: usize> Context for smart_keymap_core::key::chorded::Context<MAX_CHORDS, MAX_CHORD_SIZE, MAX_PRESSED_INDICES>