pub struct KeyContext(/* private fields */);Expand description
A datastructure for resolving whether an action should be dispatched at this point in the element tree. Contains a set of identifiers and/or key value pairs representing the current context for the keymap.
Implementations§
Source§impl KeyContext
impl KeyContext
Sourcepub fn new_with_defaults() -> Self
pub fn new_with_defaults() -> Self
Initialize a new KeyContext that contains an os key set to either macos, linux, windows or unknown.
Sourcepub fn primary(&self) -> Option<&ContextEntry>
pub fn primary(&self) -> Option<&ContextEntry>
Returns the primary context entry (usually the name of the component)
Sourcepub fn secondary(&self) -> impl Iterator<Item = &ContextEntry>
pub fn secondary(&self) -> impl Iterator<Item = &ContextEntry>
Returns everything except the primary context entry.
Sourcepub fn parse(source: &str) -> Result<Self>
pub fn parse(source: &str) -> Result<Self>
Parse a key context from a string. The key context format is very simple:
- either a single identifier, such as
StatusBar - or a key value pair, such as
mode = visible - separated by whitespace, such as
StatusBar mode = visible
Sourcepub fn add<I: Into<SharedString>>(&mut self, identifier: I)
pub fn add<I: Into<SharedString>>(&mut self, identifier: I)
Add an identifier to this context, if it’s not already in this context.
Sourcepub fn set<S1: Into<SharedString>, S2: Into<SharedString>>(
&mut self,
key: S1,
value: S2,
)
pub fn set<S1: Into<SharedString>, S2: Into<SharedString>>( &mut self, key: S1, value: S2, )
Set a key value pair in this context, if it’s not already set.
Sourcepub fn contains(&self, key: &str) -> bool
pub fn contains(&self, key: &str) -> bool
Check if this context contains a given identifier or key.
Sourcepub fn get(&self, key: &str) -> Option<&SharedString>
pub fn get(&self, key: &str) -> Option<&SharedString>
Get the associated value for a given identifier or key.
Trait Implementations§
Source§impl Clone for KeyContext
impl Clone for KeyContext
Source§fn clone(&self) -> KeyContext
fn clone(&self) -> KeyContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for KeyContext
impl Debug for KeyContext
Source§impl Default for KeyContext
impl Default for KeyContext
Source§fn default() -> KeyContext
fn default() -> KeyContext
Returns the “default value” for a type. Read more
Source§impl Hash for KeyContext
impl Hash for KeyContext
Source§impl PartialEq for KeyContext
impl PartialEq for KeyContext
Source§impl<'a> TryFrom<&'a str> for KeyContext
impl<'a> TryFrom<&'a str> for KeyContext
impl Eq for KeyContext
impl StructuralPartialEq for KeyContext
Auto Trait Implementations§
impl Freeze for KeyContext
impl RefUnwindSafe for KeyContext
impl Send for KeyContext
impl Sync for KeyContext
impl Unpin for KeyContext
impl UnwindSafe for KeyContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().