Skip to main content

RawInput

Struct RawInput 

Source
pub struct RawInput<'a>(/* private fields */);
Expand description

The original, pre-decode bytes of a key press, borrowed from the caller’s read buffer, to be forwarded verbatim when no layer binds the input.

RawInput is a view, not a copy: it borrows the exact bytes[..consumed] span the decoder reported (see keymap_term::Decoded), so forwarding it to the sink is a byte-identity copy with no re-encoding. It is constructed only from real bytes via RawInput::from_bytes; there is deliberately no From<KeyInput>. Decode is lossy (SHIFT folding, BackTabshift+tab, ctrl+itab, and some keys produce no KeyInput at all), so re-encoding a decoded key would corrupt or inject bytes. The borrow representation makes that footgun structurally impossible — there is no owned buffer for a From impl to return a reference into:

use keymap_core::{Key, KeyInput, Modifiers, RawInput};

let decoded = KeyInput::new(Key::Char('a'), Modifiers::NONE);
// There is no way back from a decoded key to its raw bytes — decode is lossy.
let _raw: RawInput = RawInput::from(decoded); // ERROR: `From<KeyInput>` does not exist

Implementations§

Source§

impl<'a> RawInput<'a>

Source

pub fn from_bytes(bytes: &'a [u8]) -> Self

Wraps the verbatim bytes the caller read for this press (the bytes[..consumed] span the decoder reported).

Source

pub fn as_bytes(&self) -> &'a [u8]

The borrowed bytes, for forwarding verbatim to the sink.

Trait Implementations§

Source§

impl<'a> Clone for RawInput<'a>

Source§

fn clone(&self) -> RawInput<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for RawInput<'a>

Source§

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

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

impl<'a> PartialEq for RawInput<'a>

Source§

fn eq(&self, other: &RawInput<'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> Copy for RawInput<'a>

Source§

impl<'a> Eq for RawInput<'a>

Source§

impl<'a> StructuralPartialEq for RawInput<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for RawInput<'a>

§

impl<'a> RefUnwindSafe for RawInput<'a>

§

impl<'a> Send for RawInput<'a>

§

impl<'a> Sync for RawInput<'a>

§

impl<'a> Unpin for RawInput<'a>

§

impl<'a> UnsafeUnpin for RawInput<'a>

§

impl<'a> UnwindSafe for RawInput<'a>

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