azalea_brigadier::command_dispatcher

Struct CommandDispatcher

Source
pub struct CommandDispatcher<S>
where Self: Sync + Send,
{ pub root: Arc<RwLock<CommandNode<S>>>, }
Expand description

The root of the command tree. You need to make this to register commands.

let mut subject = CommandDispatcher::<CommandSource>::new();

Fields§

§root: Arc<RwLock<CommandNode<S>>>

Implementations§

Source§

impl<S> CommandDispatcher<S>

Source

pub fn new() -> Self

Source

pub fn register( &mut self, node: ArgumentBuilder<S>, ) -> Arc<RwLock<CommandNode<S>>>

Add a new node to the root.

subject.register(literal("foo").executes(|_| 42));
Source

pub fn parse(&self, command: StringReader, source: S) -> ParseResults<'_, S>

Source

pub fn execute( &self, input: impl Into<StringReader>, source: S, ) -> Result<i32, CommandSyntaxException>

Parse and execute the command using the given input and context. The number returned depends on the command, and may not be of significance.

This is a shortcut for Self::parse and Self::execute_parsed.

Source

pub fn add_paths( node: Arc<RwLock<CommandNode<S>>>, result: &mut Vec<Vec<Arc<RwLock<CommandNode<S>>>>>, parents: Vec<Arc<RwLock<CommandNode<S>>>>, )

Source

pub fn get_path(&self, target: CommandNode<S>) -> Vec<String>

Source

pub fn find_node(&self, path: &[&str]) -> Option<Arc<RwLock<CommandNode<S>>>>

Source

pub fn execute_parsed( parse: ParseResults<'_, S>, ) -> Result<i32, CommandSyntaxException>

Executes a given pre-parsed command.

Source

pub fn get_all_usage( &self, node: &CommandNode<S>, source: &S, restricted: bool, ) -> Vec<String>

Source

pub fn get_smart_usage( &self, node: &CommandNode<S>, source: &S, ) -> Vec<(Arc<RwLock<CommandNode<S>>>, String)>

Gets the possible executable commands from a specified node.

You may use Self::root as a target to get usage data for the entire command tree.

Source

pub fn get_completion_suggestions(parse: ParseResults<'_, S>) -> Suggestions

Source

pub fn get_completion_suggestions_with_cursor( parse: ParseResults<'_, S>, cursor: usize, ) -> Suggestions

Trait Implementations§

Source§

impl<S> Default for CommandDispatcher<S>

Source§

fn default() -> Self

Returns the “default value” for a type. 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.

§

impl<T> Instrument for T

§

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

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

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> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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