pub struct Commands<H = FnHandler> { /* private fields */ }Expand description
The commands, by id, each owned.
Implementations§
Source§impl<H> Commands<H>
impl<H> Commands<H>
pub fn new() -> Self
Sourcepub fn register(
&mut self,
owner: &OwnerId,
spec: CommandSpec,
handler: H,
) -> Result<(), RegisterError>
pub fn register( &mut self, owner: &OwnerId, spec: CommandSpec, handler: H, ) -> Result<(), RegisterError>
Declares a command; a second declaration of an id is refused.
pub fn spec(&self, id: &CommandId) -> Option<&CommandSpec>
pub fn owner(&self, id: &CommandId) -> Option<&OwnerId>
Sourcepub fn specs(&self) -> impl Iterator<Item = &CommandSpec>
pub fn specs(&self) -> impl Iterator<Item = &CommandSpec>
Every declared command, by id.
Sourcepub fn applies(&self, id: &CommandId, cx: &WhenContext) -> bool
pub fn applies(&self, id: &CommandId, cx: &WhenContext) -> bool
Whether a command applies in a context.
Sourcepub fn available(&self, cx: &WhenContext) -> Vec<&CommandSpec>
pub fn available(&self, cx: &WhenContext) -> Vec<&CommandSpec>
The commands that apply in a context.
Sourcepub fn search(&self, query: &str, cx: &WhenContext) -> Vec<&CommandSpec>
pub fn search(&self, query: &str, cx: &WhenContext) -> Vec<&CommandSpec>
Palette commands whose category, title or id contains every word of
query, in that context, best first: a title starting with the
query, then one with a word starting with each query word, then
the rest, each by title.
Sourcepub fn prepare(
&self,
id: &CommandId,
cx: &WhenContext,
) -> Result<&H, RunRefused>
pub fn prepare( &self, id: &CommandId, cx: &WhenContext, ) -> Result<&H, RunRefused>
The handler of a command that may run here.
Sourcepub fn remove(&mut self, id: &CommandId) -> Option<OwnerId>
pub fn remove(&mut self, id: &CommandId) -> Option<OwnerId>
Removes one command; returns its owner.
Sourcepub fn remove_owner(&mut self, owner: &OwnerId) -> Vec<CommandId>
pub fn remove_owner(&mut self, owner: &OwnerId) -> Vec<CommandId>
Removes an owner’s commands; returns their ids.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl<H> Freeze for Commands<H>
impl<H> RefUnwindSafe for Commands<H>where
H: RefUnwindSafe,
impl<H> Send for Commands<H>where
H: Send,
impl<H> Sync for Commands<H>where
H: Sync,
impl<H> Unpin for Commands<H>
impl<H> UnsafeUnpin for Commands<H>
impl<H> UnwindSafe for Commands<H>where
H: RefUnwindSafe,
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