Skip to main content

steel_core/command/brigadier/
runtime.rs

1//! Opaque command behavior payloads stored by the Brigadier graph.
2
3use super::{
4    ArgumentType, CommandArgumentParser, CommandContext, CommandSyntaxError, PrimitiveArgumentValue,
5};
6
7/// Selects the executor and redirect-modifier representations stored in a graph.
8pub(crate) trait CommandRuntime<S>: 'static {
9    type Argument: CommandArgumentParser<S, Value = Self::ArgumentValue>;
10    type ArgumentValue: Clone + Send + Sync + 'static;
11    type Executor: Send + Sync + ?Sized;
12    type Modifier: Send + Sync + ?Sized;
13}
14
15/// The standard synchronous behavior used by the standalone Brigadier layer.
16pub(crate) struct BrigadierRuntime;
17
18pub(super) type BrigadierExecutor<S> =
19    dyn Fn(&CommandContext<S, BrigadierRuntime>) -> Result<i32, CommandSyntaxError> + Send + Sync;
20pub(super) type BrigadierModifier<S> = dyn Fn(&CommandContext<S, BrigadierRuntime>) -> Result<Vec<S>, CommandSyntaxError>
21    + Send
22    + Sync;
23
24impl<S> CommandRuntime<S> for BrigadierRuntime {
25    type Argument = ArgumentType;
26    type ArgumentValue = PrimitiveArgumentValue;
27    type Executor = BrigadierExecutor<S>;
28    type Modifier = BrigadierModifier<S>;
29}