pub(crate) struct CommandDispatcher<S, R = BrigadierRuntime>where
R: CommandRuntime<S>,{
id: u64,
nodes: Vec<CommandNode<S, R>>,
}Expand description
Owns a stable arena of command nodes.
Fields§
§id: u64§nodes: Vec<CommandNode<S, R>>Implementations§
Source§impl<S, R> CommandDispatcher<S, R>where
R: CommandRuntime<S>,
impl<S, R> CommandDispatcher<S, R>where
R: CommandRuntime<S>,
Sourcepub(crate) fn register(
&mut self,
builder: CommandNodeBuilder<S, R>,
) -> Result<NodeId, RegistrationError>
pub(crate) fn register( &mut self, builder: CommandNodeBuilder<S, R>, ) -> Result<NodeId, RegistrationError>
Registers and merges a literal command tree.
Sourcepub(crate) fn parse<'input>(
&self,
input: &'input str,
source: S,
) -> ParseResults<'input, S, R>
pub(crate) fn parse<'input>( &self, input: &'input str, source: S, ) -> ParseResults<'input, S, R>
Parses input into the best Brigadier command branch.
Sourcepub(crate) fn parse_reader<'input>(
&self,
reader: StringReader<'input>,
source: S,
) -> ParseResults<'input, S, R>
pub(crate) fn parse_reader<'input>( &self, reader: StringReader<'input>, source: S, ) -> ParseResults<'input, S, R>
Parses from an existing reader while preserving its current cursor.
Sourcepub(crate) fn completion_suggestions(
&self,
parse: &ParseResults<'_, S, R>,
) -> Result<Suggestions, SuggestionError>
pub(crate) fn completion_suggestions( &self, parse: &ParseResults<'_, S, R>, ) -> Result<Suggestions, SuggestionError>
Returns completions for the end of a parsed command input.
Sourcepub(crate) fn context_chain(
&self,
parse: ParseResults<'_, S, R>,
) -> Result<ContextChain<S, R>, CommandSyntaxError>
pub(crate) fn context_chain( &self, parse: ParseResults<'_, S, R>, ) -> Result<ContextChain<S, R>, CommandSyntaxError>
Validates a parse and turns its redirect contexts into executable stages.
Sourcepub(crate) fn node(&self, id: NodeId) -> Option<&CommandNode<S, R>>
pub(crate) fn node(&self, id: NodeId) -> Option<&CommandNode<S, R>>
Returns a node if the ID belongs to this dispatcher.
Sourcepub(crate) fn children(&self, id: NodeId) -> Option<&[NodeId]>
pub(crate) fn children(&self, id: NodeId) -> Option<&[NodeId]>
Returns a node’s children in registration order.
Sourcepub(crate) const fn node_count(&self) -> usize
pub(crate) const fn node_count(&self) -> usize
Returns the number of allocated nodes, including the root.
fn validate_merge( &self, parent: NodeId, incoming: &UnregisteredCommandNode<S, R>, ) -> Result<(), RegistrationError>
fn validate_redirects( &self, node: &UnregisteredCommandNode<S, R>, ) -> Result<(), RegistrationError>
fn apply_merge( &mut self, parent: NodeId, incoming: UnregisteredCommandNode<S, R>, ) -> NodeId
fn find_child(&self, parent: NodeId, name: &str) -> Option<NodeId>
fn parse_nodes<'input>( &self, parent: NodeId, original_reader: StringReader<'input>, context_so_far: ParsedCommandContext<S, R>, ) -> ParseResults<'input, S, R>
fn parse_node( &self, node_id: NodeId, reader: &mut StringReader<'_>, context: &mut ParsedCommandContext<S, R>, ) -> Result<(), CommandSyntaxError>
fn relevant_nodes( &self, parent: NodeId, reader: &StringReader<'_>, ) -> Vec<NodeId>
fn is_better_parse( candidate: &ParseResults<'_, S, R>, current: &ParseResults<'_, S, R>, ) -> bool
Trait Implementations§
Source§impl<S, R> Default for CommandDispatcher<S, R>where
R: CommandRuntime<S>,
impl<S, R> Default for CommandDispatcher<S, R>where
R: CommandRuntime<S>,
Auto Trait Implementations§
impl<S, R = BrigadierRuntime> !RefUnwindSafe for CommandDispatcher<S, R>
impl<S, R = BrigadierRuntime> !UnwindSafe for CommandDispatcher<S, R>
impl<S, R> Freeze for CommandDispatcher<S, R>
impl<S, R> Send for CommandDispatcher<S, R>
impl<S, R> Sync for CommandDispatcher<S, R>
impl<S, R> Unpin for CommandDispatcher<S, R>
impl<S, R> UnsafeUnpin for CommandDispatcher<S, R>
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
Converts
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> ⓘ
Converts
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 moreWraps this value in an
Arc<SyncMutex<>>