Skip to main content

CommandSpec

Struct CommandSpec 

Source
pub struct CommandSpec<S: Host> {
    pub id: &'static str,
    pub label: &'static str,
    pub menu: &'static [&'static str],
    pub shortcut: Option<&'static str>,
    pub params: Params,
    pub enabled: Enabled<S>,
    pub run: Run<S>,
    pub mutates: bool,
}
Expand description

One command of host state S. Build it with cmd!/query! (the shape of existing command tables) or with CommandSpec::new and its const setters.

Fields§

§id: &'static str§label: &'static str§menu: &'static [&'static str]§shortcut: Option<&'static str>

Portable shortcut(s): Mod+Shift+S, alternatives separated by / (see shortcut).

§params: Params§enabled: Enabled<S>§run: Run<S>§mutates: bool

Record in the journal / history (false for pure queries and view commands).

Implementations§

Source§

impl<S: Host> CommandSpec<S>

Source

pub const fn new(id: &'static str, label: &'static str, run: Run<S>) -> Self

A mutating command without menu, shortcut or parameters that is always enabled.

Source

pub const fn menu(self, menu: &'static [&'static str]) -> Self

Source

pub const fn shortcut(self, shortcut: &'static str) -> Self

Source

pub const fn enabled(self, enabled: Enabled<S>) -> Self

Source

pub const fn query(self) -> Self

A pure query / view command: not journaled.

Source

pub fn params(self, params: Params) -> Self

Auto Trait Implementations§

§

impl<S> Freeze for CommandSpec<S>
where fn(&S) -> Result<(), String>: Freeze, fn(&mut S, &Value) -> Result<Value, <S as Host>::Error>: Freeze,

§

impl<S> RefUnwindSafe for CommandSpec<S>

§

impl<S> Send for CommandSpec<S>
where fn(&S) -> Result<(), String>: Send, fn(&mut S, &Value) -> Result<Value, <S as Host>::Error>: Send,

§

impl<S> Sync for CommandSpec<S>
where fn(&S) -> Result<(), String>: Sync, fn(&mut S, &Value) -> Result<Value, <S as Host>::Error>: Sync,

§

impl<S> Unpin for CommandSpec<S>
where fn(&S) -> Result<(), String>: Unpin, fn(&mut S, &Value) -> Result<Value, <S as Host>::Error>: Unpin,

§

impl<S> UnsafeUnpin for CommandSpec<S>

§

impl<S> UnwindSafe for CommandSpec<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.