Skip to main content

ParsedCommandContext

Struct ParsedCommandContext 

Source
pub(crate) struct ParsedCommandContext<S, R = BrigadierRuntime>
where R: CommandRuntime<S>,
{ source: Arc<S>, root: NodeId, arguments: ParsedArguments<R::ArgumentValue>, executor: Option<Arc<R::Executor>>, nodes: Vec<ParsedCommandNode>, range: StringRange, child: Option<Box<Self>>, modifier: Option<Arc<R::Modifier>>, forks: bool, }
Expand description

The successful portion of one command parse branch.

Fields§

§source: Arc<S>§root: NodeId§arguments: ParsedArguments<R::ArgumentValue>§executor: Option<Arc<R::Executor>>§nodes: Vec<ParsedCommandNode>§range: StringRange§child: Option<Box<Self>>§modifier: Option<Arc<R::Modifier>>§forks: bool

Implementations§

Source§

impl<S, R> ParsedCommandContext<S, R>
where R: CommandRuntime<S>,

Source

pub(super) fn new(source: Arc<S>, root: NodeId, start: usize) -> Self

Source

pub(super) fn branch(&self) -> Self

Source

pub(super) fn source(&self) -> &S

Source

pub(super) fn argument_suggestion_context( &self, ) -> ArgumentSuggestionContext<'_, S, R::ArgumentValue>

Source

pub(super) const fn root(&self) -> NodeId

Source

pub(super) const fn source_arc(&self) -> &Arc<S>

Source

pub(super) fn set_executor(&mut self, executor: Option<Arc<R::Executor>>)

Source

pub(super) fn with_node( &mut self, node: NodeId, range: StringRange, redirect: Option<&CommandRedirect<S, R>>, )

Source

pub(super) fn with_argument( &mut self, name: &str, range: StringRange, value: R::ArgumentValue, )

Source

pub(super) fn set_child(&mut self, child: Self)

Source

pub(super) fn build(self, input: Arc<str>) -> Arc<CommandContext<S, R>>

Source

pub(super) fn find_suggestion_context( &self, cursor: usize, ) -> Option<SuggestionContext<'_, S, R>>

Source

pub(crate) fn nodes(&self) -> &[ParsedCommandNode]

Returns all nodes consumed by this parse segment.

Source

pub(crate) const fn range(&self) -> StringRange

Returns the range covered by this parse segment.

Source

pub(crate) const fn is_executable(&self) -> bool

Returns whether the last parsed node has a command callback.

Source

pub(crate) fn argument(&self, name: &str) -> Option<&R::ArgumentValue>

Returns a parsed runtime argument by name.

Source

pub(crate) fn child(&self) -> Option<&Self>

Returns the context reached through a redirect.

Source§

impl<S, R> ParsedCommandContext<S, R>

Source

pub(crate) fn boolean(&self, name: &str) -> Option<bool>

Returns a parsed boolean argument.

Source

pub(crate) fn integer(&self, name: &str) -> Option<i32>

Returns a parsed integer argument.

Source

pub(crate) fn long(&self, name: &str) -> Option<i64>

Returns a parsed long argument.

Source

pub(crate) fn float(&self, name: &str) -> Option<f32>

Returns a parsed float argument.

Source

pub(crate) fn double(&self, name: &str) -> Option<f64>

Returns a parsed double argument.

Source

pub(crate) fn string(&self, name: &str) -> Option<&str>

Returns a parsed string argument.

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

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> IntoShared for T

Source§

fn into_shared(self) -> Arc<Mutex<RawMutex, Self>>

Wraps this value in an Arc<SyncMutex<>>
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

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
§

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