Skip to main content

Resolution

Enum Resolution 

Source
pub enum Resolution<'a, A> {
    Action(&'a A),
    Passthrough(RawInput<'a>),
    Consume,
}
Expand description

What should happen to a key press, for a caller that forwards unbound input to a terminal sink (a PTY). The disposition counterpart to resolve_layered’s bare Option<&A>.

The three dispositions — run an action, forward the bytes verbatim, swallow the key — are the complete set, so this enum is exhaustive on purpose (the deliberate twin of keymap_seq::Match). Consume ships from day one rather than hiding behind #[non_exhaustive], whose “compiles but a key is silently misrouted” trap is exactly the failure to avoid when routing input. Callers match all three arms with the compiler checking coverage.

The 'a lifetime is shared by the borrowed action and the borrowed bytes: a Resolution is meant to be consumed within the event-loop turn that produced it (run the action, or write the bytes to the sink), so tying both borrows to one region is sufficient. A caller that needs to outlive the read buffer copies the bytes out at that boundary (raw.as_bytes().to_vec()).

Because the enum is exhaustive, a caller can match every arm with no wildcard — and this stays a compile-time guarantee. The day someone makes Resolution #[non_exhaustive], this very example stops compiling:

use keymap_core::Resolution;

fn describe(r: Resolution<'_, u8>) -> &'static str {
    match r {
        Resolution::Action(_) => "action",
        Resolution::Passthrough(_) => "passthrough",
        Resolution::Consume => "consume",
    }
}
assert_eq!(describe(Resolution::Consume), "consume");

Variants§

§

Action(&'a A)

A layer bound the input; run this action.

§

Passthrough(RawInput<'a>)

No layer bound the input; forward these original bytes to the sink verbatim.

§

Consume

Swallow the key with no action and do not forward it — a modal/input grab. resolve_passthrough never returns this; a grabbing caller assigns it from its own mode state (mapping what would be a Passthrough).

Trait Implementations§

Source§

impl<'a, A: Debug> Debug for Resolution<'a, A>

Source§

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

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

impl<'a, A: PartialEq> PartialEq for Resolution<'a, A>

Source§

fn eq(&self, other: &Resolution<'a, A>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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, A: Eq> Eq for Resolution<'a, A>

Source§

impl<'a, A> StructuralPartialEq for Resolution<'a, A>

Auto Trait Implementations§

§

impl<'a, A> Freeze for Resolution<'a, A>

§

impl<'a, A> RefUnwindSafe for Resolution<'a, A>
where A: RefUnwindSafe,

§

impl<'a, A> Send for Resolution<'a, A>
where A: Sync,

§

impl<'a, A> Sync for Resolution<'a, A>
where A: Sync,

§

impl<'a, A> Unpin for Resolution<'a, A>

§

impl<'a, A> UnsafeUnpin for Resolution<'a, A>

§

impl<'a, A> UnwindSafe for Resolution<'a, A>
where A: RefUnwindSafe,

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> 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, 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.