BindingContext

Trait BindingContext 

Source
pub trait BindingContext:
    Clone
    + Copy
    + Eq
    + Hash {
    // Required methods
    fn name(&self) -> &'static str;
    fn from_name(name: &str) -> Option<Self>;
    fn all() -> &'static [Self];
}
Expand description

Trait for user-defined keybinding contexts

Implement this trait for your own context enum, or use #[derive(BindingContext)] from tui-dispatch-macros to auto-generate the implementation.

§Example

#[derive(BindingContext, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MyContext {
    Default,
    Search,
    Modal,
}

Required Methods§

Source

fn name(&self) -> &'static str

Get the context name as a string (for config file lookup)

Source

fn from_name(name: &str) -> Option<Self>

Parse a context from its name

Source

fn all() -> &'static [Self]

Get all possible context values (for iteration/config loading)

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§