#[non_exhaustive]pub struct Command {
pub id: CommandId,
pub title: String,
pub category: String,
pub icon: Option<String>,
pub description: Option<String>,
pub keywords: Vec<String>,
pub default_shortcut: Option<KeySequence>,
pub when: When,
pub state: CommandState,
pub args: Option<ArgSchema>,
}Expand description
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: CommandIdStable namespaced identifier.
title: StringVisible title.
category: StringGroup shown in menus and the palette.
icon: Option<String>Optional icon name.
description: Option<String>Optional secondary text.
keywords: Vec<String>Search terms beyond the title.
default_shortcut: Option<KeySequence>The default shortcut.
when: WhenThe context in which the command is available.
state: CommandStateEnabled and checked state.
args: Option<ArgSchema>Optional argument schema.
Implementations§
Source§impl Command
impl Command
Sourcepub fn new(id: impl Into<CommandId>, title: impl Into<String>) -> Self
pub fn new(id: impl Into<CommandId>, title: impl Into<String>) -> Self
A command with the default category (General).
Sourcepub fn description(self, description: impl Into<String>) -> Self
pub fn description(self, description: impl Into<String>) -> Self
Set the secondary text.
Sourcepub fn keywords(
self,
keywords: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn keywords( self, keywords: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Add search terms.
Sourcepub fn shortcut(self, shortcut: impl AsRef<str>) -> Self
pub fn shortcut(self, shortcut: impl AsRef<str>) -> Self
Set the default shortcut. An invalid string is ignored; use
Self::try_shortcut when the caller must see the error.
Sourcepub fn try_shortcut(
self,
shortcut: impl AsRef<str>,
) -> Result<Self, BindingError>
pub fn try_shortcut( self, shortcut: impl AsRef<str>, ) -> Result<Self, BindingError>
Set the default shortcut and report an invalid string.
Sourcepub fn try_when(self, when: impl AsRef<str>) -> Result<Self, BindingError>
pub fn try_when(self, when: impl AsRef<str>) -> Result<Self, BindingError>
Set the availability context and report a parse error.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether the command is currently enabled.
Sourcepub fn is_checked(&self) -> bool
pub fn is_checked(&self) -> bool
Whether the command is currently checked.
Sourcepub fn applies(&self, context: &WhenContext) -> bool
pub fn applies(&self, context: &WhenContext) -> bool
Whether the command applies in context.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Command
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Command
Available on crate feature
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl FromIterator<Command> for CommandRegistry
impl FromIterator<Command> for CommandRegistry
Auto Trait Implementations§
impl Forget for Command
impl Freeze for Commandwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
PhantomData<KeyChord>: Freeze,
*const Expression is !null: Freeze,
PhantomData<Expression>: Freeze,
impl Move for Command
impl RefUnwindSafe for Command
impl Send for Command
impl Sync for Command
impl Unpin for Command
impl UnsafeUnpin for Commandwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<KeyChord>: UnsafeUnpin,
*const Expression is !null: UnsafeUnpin,
PhantomData<Expression>: UnsafeUnpin,
impl UnwindSafe for Commandwhere
RawVecInner: UnwindSafe,
BoxRaw<Expression>: UnwindSafe,
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 more