pub struct KeyMap<Value: Debug + Clone> { /* private fields */ }
Expand description

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

Insert a value into the keymap

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.