Struct CommandNode

Source
pub struct CommandNode {
    pub node: TreeNode,
    pub handler: Option<fn(node: &Node)>,
    pub parameters: Vec<Rc<Node>>,
    pub wrapped_root: Option<Rc<Node>>,
}
Expand description

A node representing a command. Constructed via Command and CommandTree.

If wrapped_root is set then this node wraps another command. This is used for the help command so that it can complete normal commands. The successors will be those of the wrapped node.

Fields§

§node: TreeNode

TreeNode data.

§handler: Option<fn(node: &Node)>

The handler which is executed once this node has been accepted.

§parameters: Vec<Rc<Node>>

Parameter nodes for this command

§wrapped_root: Option<Rc<Node>>

If present, the command wrapped by this node.

Implementations§

Source§

impl CommandNode

Source

pub fn new( name: &str, help_text: Option<&str>, hidden: bool, priority: i32, successors: Vec<Rc<Node>>, handler: Option<fn(node: &Node)>, parameters: Vec<Rc<Node>>, ) -> Self

Construct a new CommandNode.

Trait Implementations§

Source§

impl NodeOps for CommandNode

Source§

fn accept<'text>( &self, parser: &mut Parser<'text>, _token: Token<'_>, node_ref: &Rc<Node>, )

Record this command.

Source§

fn acceptable(&self, parser: &Parser<'_>, node_ref: &Rc<Node>) -> bool

Can this node be accepted in the current parser state? By default, a node can be accepted when it hasn’t been seen yet. Read more
Source§

fn complete<'text>(&self, token: Option<Token<'text>>) -> Completion<'text>

Given a node and an optional token, provide the completion options. Read more
Source§

fn matches(&self, _parser: &Parser<'_>, token: Token<'_>) -> bool

By default, a node matches a token when the name of the node starts with the token. Read more

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.