[−][src]Struct termwiz::keymap::KeyMap
The KeyMap
struct is intended to hold the text sequences
generated by unix terminal programs. Those sequences have
overlapping/ambiguous meaning which requires having more
data to correctly interpret the sequence.
The lookup
operation returns an enum describing the
confidence of a match rather than a simple map lookup.
Implementations
impl<Value: Debug + Clone> KeyMap<Value>
[src]
pub fn new() -> Self
[src]
pub fn insert<K: AsRef<[u8]>>(&mut self, key: K, value: Value)
[src]
Insert a value into the keymap
pub fn lookup<S: AsRef<[u8]>>(&self, key: S) -> Found<Value>
[src]
Perform a lookup for key
.
key
can be a string consisting of a sequence of bytes.
The lookup
operation considers the prefix of key
and searches
for a match.
If Found::None
is returned then the prefix for key has no matching
keymap entry.
If Found::Exact
is returned then the returned value informs the caller
of the length of the key that was matched; the remainder of the key
was not considered and is something that should be considered again
in a subsequent lookup operation.
If Found::Ambiguous
is returned then the key matched a valid
entry (which is returned as the value), but there is at least one
other entry that could match if more data were available. If the caller
knows that no more data is available immediately then it may be valid
to treat this result as equivalent to Found::Exact
. The intended
use for this variant is to handle the case where a sequence straddles
a buffer boundary (eg: fixed size buffer receives a partial sequence,
and the remainder is immediately available on the next read) without
misinterpreting the read data.
If Found::NeedData
is returned it indicates that key
is too short
to determine a match. The purpose is similar to the Found::Ambiguous
case; if the caller knows that no more data is available this can be
treated as Found::None
, but otherwise it would be best to read more
data from the stream and retry with a longer input.
Trait Implementations
impl<Value: Clone + Debug> Clone for KeyMap<Value>
[src]
impl<Value: Debug + Clone> Debug for KeyMap<Value>
[src]
impl<Value: Debug + Clone> Default for KeyMap<Value>
[src]
Auto Trait Implementations
impl<Value> RefUnwindSafe for KeyMap<Value> where
Value: RefUnwindSafe,
Value: RefUnwindSafe,
impl<Value> Send for KeyMap<Value> where
Value: Send,
Value: Send,
impl<Value> Sync for KeyMap<Value> where
Value: Sync,
Value: Sync,
impl<Value> Unpin for KeyMap<Value> where
Value: Unpin,
Value: Unpin,
impl<Value> UnwindSafe for KeyMap<Value> where
Value: UnwindSafe,
Value: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,