Skip to main content

CommandNodeBuilder

Struct CommandNodeBuilder 

Source
pub(crate) struct CommandNodeBuilder<S, R = BrigadierRuntime>
where R: CommandRuntime<S>,
{ data: CommandNodeData<R::Argument>, children: Vec<Self>, executor: Option<Arc<R::Executor>>, requirement: CommandRequirement<S>, execution_requirement: CommandRequirement<S>, redirect: Option<CommandRedirect<S, R>>, }
Expand description

Builds one literal or argument command node and its descendants.

Fields§

§data: CommandNodeData<R::Argument>§children: Vec<Self>§executor: Option<Arc<R::Executor>>§requirement: CommandRequirement<S>§execution_requirement: CommandRequirement<S>§redirect: Option<CommandRedirect<S, R>>

Implementations§

Source§

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

Source

pub(crate) fn literal(name: impl Into<Box<str>>) -> Self

Creates a literal for this runtime model.

Source

pub(crate) fn argument( name: impl Into<Box<str>>, argument_type: R::Argument, ) -> Self

Creates an argument for this runtime model.

Source

pub(crate) fn literal_name(&self) -> Option<&str>

Returns this node’s literal name, or None for an argument node.

Source

pub(crate) fn with_literal_name(self, name: impl Into<Box<str>>) -> Option<Self>

Replaces this node’s literal name, returning None for an argument node.

Source

pub(crate) fn then(self, child: Self) -> Self

Adds a child while preserving registration order.

Source

pub(crate) fn executes_with_executor(self, executor: Arc<R::Executor>) -> Self

Attaches an executor payload without interpreting it.

Source

pub(crate) fn requires(self, requirement: CommandRequirement<S>) -> Self

Replaces the allow-all requirement with requirement.

Source

pub(crate) fn also_requires(self, requirement: CommandRequirement<S>) -> Self
where S: 'static,

Adds a requirement while preserving any predicate already on this node.

Source

pub(crate) fn also_requires_execution( self, requirement: CommandRequirement<S>, ) -> Self
where S: 'static,

Adds a requirement that applies only when this node’s executor is selected.

Source

pub(crate) fn literal_path_match_count(&self, path: &[Box<str>]) -> usize

Returns the number of occurrences of one literal path below this node.

Argument nodes do not consume path segments.

Source

pub(crate) fn apply_scoped_requirements( &mut self, scope_paths: &[Vec<Box<str>>], requirements_for: impl FnMut(Option<usize>, &[usize]) -> CommandRequirementRoute<S>, )
where S: 'static,

Applies independently scoped requirements using literal-only paths.

A descendant scope may traverse its ancestors, but it cannot execute an ancestor unless the route’s governing requirement also permits it.

Source

fn apply_scoped_requirements_inner<F>( &mut self, inherited_scope: Option<usize>, active: &[ActiveRequirementScope<'_>], parent_route: Option<&RequirementRouteKey>, cache: &mut Vec<(RequirementRouteKey, CommandRequirementRoute<S>)>, requirements_for: &mut F, )
where S: 'static, F: FnMut(Option<usize>, &[usize]) -> CommandRequirementRoute<S>,

Source

pub(crate) fn redirects(self, target: impl Into<CommandRedirectTarget>) -> Self

Redirects parsing to an existing node without transforming the source.

Source

pub(crate) fn redirects_with_modifier( self, target: impl Into<CommandRedirectTarget>, modifier: Arc<R::Modifier>, forks: bool, ) -> Self

Redirects with an opaque runtime modifier payload.

Source

pub(super) fn normalize( self, ) -> Result<UnregisteredCommandNode<S, R>, RegistrationError>

Source§

impl<S> CommandNodeBuilder<S, BrigadierRuntime>

Source

pub(crate) fn executes( self, executor: impl Fn(&CommandContext<S>) -> Result<i32, CommandSyntaxError> + Send + Sync + 'static, ) -> Self

Attaches a standard synchronous command callback.

Source

pub(crate) fn redirects_with( self, target: NodeId, modifier: impl Fn(&CommandContext<S>) -> Result<S, CommandSyntaxError> + Send + Sync + 'static, ) -> Self

Redirects parsing and transforms the source once before continuing.

Source

pub(crate) fn forks( self, target: NodeId, modifier: impl Fn(&CommandContext<S>) -> Result<Vec<S>, CommandSyntaxError> + Send + Sync + 'static, ) -> Self

Redirects parsing and expands one source into zero or more sources.

Source§

impl<S> CommandNodeBuilder<S, SteelCommandRuntime>

Source

pub(crate) fn executes( self, executor: impl Fn(&CommandContext<S, SteelCommandRuntime>) -> Result<i32, CommandSyntaxError> + Send + Sync + 'static, ) -> Self

Attaches an ordinary synchronous executor.

Source

pub(crate) fn executes_suspended<T>( self, executor: impl Fn(&CommandContext<S, SteelCommandRuntime>) -> Result<T, CommandSyntaxError> + Send + Sync + 'static, ) -> Self

Attaches an ordinary executor whose command result is produced across ticks.

Source

pub(crate) fn executes_custom( self, executor: impl CustomCommandExecutor<S> + 'static, ) -> Self

Attaches an internal executor with frame and queue control.

Source

pub(crate) fn redirects_with( self, target: impl Into<CommandRedirectTarget>, modifier: impl Fn(&CommandContext<S, SteelCommandRuntime>) -> Result<S, CommandSyntaxError> + Send + Sync + 'static, ) -> Self

Redirects parsing and transforms the source once before continuing.

Source

pub(crate) fn forks( self, target: impl Into<CommandRedirectTarget>, modifier: impl Fn(&CommandContext<S, SteelCommandRuntime>) -> Result<Vec<S>, CommandSyntaxError> + Send + Sync + 'static, ) -> Self

Redirects parsing and expands one source into zero or more sources.

Source

pub(crate) fn redirects_custom( self, target: impl Into<CommandRedirectTarget>, modifier: impl CustomModifierExecutor<S> + 'static, forks: bool, ) -> Self

Redirects with an internal modifier that controls frames or queued work.

Trait Implementations§

Source§

impl<S, R> Clone for CommandNodeBuilder<S, R>
where R: CommandRuntime<S>, R::Argument: Clone,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<S, R = BrigadierRuntime> !RefUnwindSafe for CommandNodeBuilder<S, R>

§

impl<S, R = BrigadierRuntime> !UnwindSafe for CommandNodeBuilder<S, R>

§

impl<S, R> Freeze for CommandNodeBuilder<S, R>
where <R as CommandRuntime<S>>::Argument: Freeze,

§

impl<S, R> Send for CommandNodeBuilder<S, R>

§

impl<S, R> Sync for CommandNodeBuilder<S, R>

§

impl<S, R> Unpin for CommandNodeBuilder<S, R>
where <R as CommandRuntime<S>>::Argument: Unpin,

§

impl<S, R> UnsafeUnpin for CommandNodeBuilder<S, R>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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