Skip to main content

Command

Struct Command 

Source
pub struct Command {
    pub name: &'static str,
    pub aliases: &'static [&'static str],
    pub args: Args,
    pub help: &'static str,
    pub fronts: &'static [Front],
}

Fields§

§name: &'static str

The canonical word, with its slash: /new.

§aliases: &'static [&'static str]

Other words that run the same command; /resume is also /sessions.

§args: Args

Whether an argument is accepted, and whether the table spells it. See Args.

§help: &'static str

One line, no trailing full stop.

§fronts: &'static [Front]

Every front end that has it, widest first. A list rather than a “both” shorthand: with three fronts the shorthand would mean “not the web”, which is a reading nobody would guess and a bug waiting for the next front end. The order is only ever read by Command::unavailable_in’s sentence — /help and completion walk COMMANDS.

Implementations§

Source§

impl Command

Source

pub fn label(&self) -> String

/set <key> <value>: the name and its argument, as /help and the menu show it. A command whose arguments are Unshown is just its name — the table does not teach that syntax.

Source

pub fn spelling(&self, prefix: &str) -> &'static str

The word to put in the line for someone who has typed prefix: the name, unless only an alias starts with it — /qu completes to /quit, not to a command they did not type.

Source

pub fn fill(&self, prefix: &str) -> String

What completing prefix to this command leaves in the line. A command that takes an argument gets a space after it, so the next key is the argument.

Source

pub fn serves(&self, viewer: Front) -> bool

Whether viewer has this command.

Source

pub fn unavailable_in(&self, here: Front) -> String

Why this command does nothing in here, for the front end that was asked for it.

Names every front that does have it, because a command can live in two of the three and naming one of them would send a person looking in the wrong place. The “how” half is the nearest way in: what to type after they have read it.

Trait Implementations§

Source§

impl Debug for Command

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Command

Source§

impl PartialEq for Command

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Command

Auto Trait Implementations§

§

impl Forget for Command

§

impl Freeze for Command
where &'static str: Freeze, &'static [&'static str]: Freeze, &'static [Front]: Freeze,

§

impl Move for Command

§

impl RefUnwindSafe for Command

§

impl Send for Command
where &'static str: Send, &'static [&'static str]: Send, &'static [Front]: Send,

§

impl Sync for Command

§

impl Unpin for Command
where &'static str: Unpin, &'static [&'static str]: Unpin, &'static [Front]: Unpin,

§

impl UnsafeUnpin for Command
where &'static str: UnsafeUnpin, &'static [&'static str]: UnsafeUnpin, &'static [Front]: UnsafeUnpin,

§

impl UnwindSafe for Command
where &'static str: UnwindSafe, &'static [&'static str]: UnwindSafe, &'static [Front]: UnwindSafe,

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more