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>
impl<'a, A: Debug> Debug for Resolution<'a, A>
Source§impl<'a, A: PartialEq> PartialEq for Resolution<'a, A>
impl<'a, A: PartialEq> PartialEq for Resolution<'a, A>
Source§fn eq(&self, other: &Resolution<'a, A>) -> bool
fn eq(&self, other: &Resolution<'a, A>) -> bool
self and other values to be equal, and is used by ==.