Skip to main content

Binding

Enum Binding 

Source
pub enum Binding {
    CharRange(Bound<char>, Bound<char>, KeyMod),
    FnRange(Bound<u8>, Bound<u8>, KeyMod),
    AnyModifier(KeyMod),
    AnyMedia(KeyMod),
    Any(Option<KeyMod>),
    Event(KeyCode, KeyMod),
}
Expand description

Possible ways to map keys

This struct serves the purpose of allowing the use of pattern-like syntax in order to match keys in the bindings! macro, while still creating a finitely known list of keys, which can then be used for documentation.

Variants§

§

CharRange(Bound<char>, Bound<char>, KeyMod)

A range of KeyEvents with KeyCode::Char, like KeyCode::Char('0'..='9')

§

FnRange(Bound<u8>, Bound<u8>, KeyMod)

A range of KeyEvents with KeyCode::F, like KeyCode::F(1..=3)

§

AnyModifier(KeyMod)

Any modifier key, like ModifierKeyCode::LeftShift

Unlikely to be bound

§

AnyMedia(KeyMod)

Any media key, like MediaKeyCode::MuteVolume

§

Any(Option<KeyMod>)

Any KeyCode, might match anything, given the optional KeyMod

§

Event(KeyCode, KeyMod)

A specific KeyCode/KeyMod combo

Implementations§

Source§

impl Binding

Source

pub fn new(code: KeyCode, modif: KeyMod) -> Self

Returns a new concrete Binding

Source

pub fn anything() -> Self

Returns a Binding that could match anything

Source

pub fn as_text(&self) -> Text

The default Text formatting for a Binding

This function makes use of the key.char, key.mod, key.special, key.range and key.any Forms.

Source

pub fn modifier(&self) -> Option<KeyMod>

The KeyMod for this Binding

Can be None in case the Binding accepts any KeyEvent whatsoever.

Source

pub fn as_key_event(&self) -> Option<KeyEvent>

A KeyEvent, with assumptions about less used options

Only returns Some if this is Binding::Event with a concrete KeyCode and KeyMod.

Source

pub fn matches(&self, key_event: KeyEvent) -> bool

Wether a KeyEvent would be matched by this Binding

Trait Implementations§

Source§

impl Clone for Binding

Source§

fn clone(&self) -> Binding

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

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Binding

Source§

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

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

impl From<(MediaKeyCode, KeyModifiers)> for Binding

Source§

fn from((media, modif): (MediaKeyCode, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl From<(ModifierKeyCode, KeyModifiers)> for Binding

Source§

fn from((modifier, modif): (ModifierKeyCode, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl From<(Range<char>, KeyModifiers)> for Binding

Source§

fn from((chars, modif): (Range<char>, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl From<(Range<u8>, KeyModifiers)> for Binding

Source§

fn from((fns, modif): (Range<u8>, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl From<(RangeFrom<char>, KeyModifiers)> for Binding

Source§

fn from((chars, modif): (RangeFrom<char>, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl From<(RangeFrom<u8>, KeyModifiers)> for Binding

Source§

fn from((fns, modif): (RangeFrom<u8>, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl From<(RangeInclusive<char>, KeyModifiers)> for Binding

Source§

fn from((chars, modif): (RangeInclusive<char>, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl From<(RangeInclusive<u8>, KeyModifiers)> for Binding

Source§

fn from((fns, modif): (RangeInclusive<u8>, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl From<(RangeTo<char>, KeyModifiers)> for Binding

Source§

fn from((chars, modif): (RangeTo<char>, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl From<(RangeTo<u8>, KeyModifiers)> for Binding

Source§

fn from((fns, modif): (RangeTo<u8>, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl From<(RangeToInclusive<char>, KeyModifiers)> for Binding

Source§

fn from((chars, modif): (RangeToInclusive<char>, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl From<(RangeToInclusive<u8>, KeyModifiers)> for Binding

Source§

fn from((fns, modif): (RangeToInclusive<u8>, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl From<(char, KeyModifiers)> for Binding

Source§

fn from((char, modif): (char, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl From<(u8, KeyModifiers)> for Binding

Source§

fn from((num, modif): (u8, KeyMod)) -> Self

Converts to this type from the input type.
Source§

impl Copy for Binding

Auto Trait Implementations§

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> TryClone for T
where T: Clone,

Source§

fn try_clone(&self) -> Result<T, Error>

Clones self, possibly returning an error.
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.