#[non_exhaustive]pub struct CommandSpec {Show 19 fields
pub id: CommandId,
pub title: String,
pub category: String,
pub description: String,
pub when: String,
pub checked: String,
pub keys: Vec<KeySpec>,
pub menus: Vec<MenuPlacement>,
pub palette: bool,
pub agent: bool,
pub read_only: bool,
pub destructive: bool,
pub destructive_if: Vec<ArgMatch>,
pub private: bool,
pub args: Value,
pub icon: Option<String>,
pub icon_on: Option<String>,
pub menu_note: Option<String>,
pub opens_link: bool,
}Expand description
What a command declares.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: CommandIdStable, never translated: view.palette.
title: String§category: String§description: StringWhat it does, for the palette and agents.
when: StringWhere the command applies; empty: everywhere.
checked: StringWhen its menu entries show ticked (a toggle that is on, the theme in use); empty: never.
keys: Vec<KeySpec>Its default key bindings (Ctrl+K, Ctrl+K Ctrl+S).
Its menu entries.
palette: boolListed in the command palette.
agent: boolOffered to agents through the debug bridge.
read_only: boolIt only reads: running it changes nothing in the application
(about.read, value.get). The debug bridge reports it
(commands.run does not mutate then) and a read-only bridge runs
only these.
destructive: boolIt destroys or discards what cannot easily be had back (deletes files, empties a trash, drops unsaved work). Asked by anyone but the user (an agent), it waits for the user to confirm it first: the agent socket asks, through a dialog. The user’s own runs are never asked.
destructive_if: Vec<ArgMatch>The calls that are destructive by their arguments, when the
command is not destructive whole: a run whose arguments match one
of these (CommandSpec::destructive_if) is asked about as a
destructive command’s is; the others run at once. An export that
only overwrites with clash: "overwrite" says so here.
private: boolIts result carries the user’s private data: places (GPS), people
(faces, names), absolute file paths. An agent whose grant
withholds private data is refused it (the agent socket’s
Grant::private); the user’s own runs are never held.
args: ValueIts arguments: a JSON Schema (CommandSpec::schema), or a free
description (an example, a text); null when it takes none. A
schema (an object of schema keywords naming a type, see
egui_pop_core::debug::is_schema) is enforced: a run whose
arguments do not match is refused before its handler, whoever
asks it (command.refused, by: "pop.command.args"). A free
description checks nothing.
icon: Option<String>Its icon’s name (save, phosphor:export, my-plugin:crop):
every surface running the command shows it. Checked against the
icon vocabulary when the application resolves its declarations.
icon_on: Option<String>The icon shown instead while checked holds (eye-off for a
toggle whose icon is the eye).
A note at the end of its menu entries, muted, in the keys’ column (a version, “sessions kept”); its keys, if any, come first.
opens_link: boolIt opens a page outside the application: its menu entries end with ↗.
Implementations§
Source§impl CommandSpec
impl CommandSpec
pub fn new(id: CommandId, title: &str, category: &str) -> CommandSpec
Sourcepub fn icon(self, name: &str) -> CommandSpec
pub fn icon(self, name: &str) -> CommandSpec
Its icon, by name: egui-pop’s (save), a Phosphor glyph’s
(phosphor:export) or a registered one (my-plugin:crop).
Declared once, shown by every surface running the command.
Sourcepub fn icon_on(self, name: &str) -> CommandSpec
pub fn icon_on(self, name: &str) -> CommandSpec
The icon shown while its checked clause holds, by name.
A note at the end of its menu entries (CommandSpec::menu_note).
Sourcepub fn opens_link(self, link: bool) -> CommandSpec
pub fn opens_link(self, link: bool) -> CommandSpec
Its menu entries end with ↗: it opens a page outside the
application (CommandSpec::opens_link).
Sourcepub fn icon_for(&self, checked: bool) -> Option<&str>
pub fn icon_for(&self, checked: bool) -> Option<&str>
The icon’s name to show: icon_on while checked (when declared),
else icon.
pub fn when(self, when: &str) -> CommandSpec
Sourcepub fn checked(self, clause: &str) -> CommandSpec
pub fn checked(self, clause: &str) -> CommandSpec
Ticks its menu entries when the clause holds.
pub fn description(self, text: &str) -> CommandSpec
Sourcepub fn key(self, keys: &str) -> CommandSpec
pub fn key(self, keys: &str) -> CommandSpec
Adds a default global key binding (a text input keeps plain
keys, see keymap::Typing).
Sourcepub fn key_with(self, keys: &str, options: BindOptions) -> CommandSpec
pub fn key_with(self, keys: &str, options: BindOptions) -> CommandSpec
Adds a default key binding listening as options say: on a
surface, while typing, through modals.
Adds a menu entry.
Kept out of the palette.
Sourcepub fn no_agent(self) -> CommandSpec
pub fn no_agent(self) -> CommandSpec
Kept away from agents.
Sourcepub fn read_only(self) -> CommandSpec
pub fn read_only(self) -> CommandSpec
It only reads: running it changes nothing in the application (no value, file, window or state of any kind). Say it only when true: a read-only debug bridge runs these and refuses the others.
Sourcepub fn destructive(self) -> CommandSpec
pub fn destructive(self) -> CommandSpec
It destroys or discards what cannot easily be had back
(CommandSpec::destructive): an agent’s run waits for the
user’s confirmation.
Sourcepub fn destructive_if(self, arg: &str, value: Value) -> CommandSpec
pub fn destructive_if(self, arg: &str, value: Value) -> CommandSpec
A call whose argument arg equals value is destructive
(CommandSpec::destructive_if): an agent’s run with it waits
for the user’s confirmation, other runs do not. arg is a
top-level argument’s name, or a JSON Pointer (/options/clash).
Several rules: any one matching makes the call destructive.
CommandSpec::destructive still makes every call destructive.
Sourcepub fn is_destructive(&self, args: &Value) -> bool
pub fn is_destructive(&self, args: &Value) -> bool
Whether a call with args is destructive: the command is
(CommandSpec::destructive), or its arguments match one of
CommandSpec::destructive_if.
Sourcepub fn private(self) -> CommandSpec
pub fn private(self) -> CommandSpec
Its result carries private data (CommandSpec::private): an
agent whose grant withholds private data is refused it. A command
whose result only partly is private may instead leave the private
parts out for such an agent (the agent socket’s
grants::reads_private).
Sourcepub fn args(self, args: Value) -> CommandSpec
pub fn args(self, args: Value) -> CommandSpec
Describes the arguments (CommandSpec::args): a JSON Schema is
enforced, a free description (an example) only shown.
Sourcepub fn schema(self, schema: Value) -> CommandSpec
pub fn schema(self, schema: Value) -> CommandSpec
Its arguments’ JSON Schema, enforced before every run: arguments
that do not match are refused before the handler runs
(command.refused, by: "pop.command.args"). The checked subset
is egui_pop_core::schema’s (types, required, enum, ranges,
lengths, items, additionalProperties, combinators). null
arguments are checked as {} when the schema is an object’s. The
same as CommandSpec::args, said for what it is.
Trait Implementations§
Source§impl Clone for CommandSpec
impl Clone for CommandSpec
Source§fn clone(&self) -> CommandSpec
fn clone(&self) -> CommandSpec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CommandSpec
impl Debug for CommandSpec
Source§impl PartialEq for CommandSpec
impl PartialEq for CommandSpec
Source§impl Serialize for CommandSpec
impl Serialize for CommandSpec
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for CommandSpec
Auto Trait Implementations§
impl Freeze for CommandSpec
impl RefUnwindSafe for CommandSpec
impl Send for CommandSpec
impl Sync for CommandSpec
impl Unpin for CommandSpec
impl UnsafeUnpin for CommandSpec
impl UnwindSafe for CommandSpec
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.