pub trait Command: Parser {
type Error: BuiltinError + 'static;
// Required method
fn execute(
&self,
context: ExecutionContext<'_>,
) -> impl Future<Output = Result<ExecutionResult, Self::Error>> + Send;
// Provided methods
fn new<I>(args: I) -> Result<Self, Error>
where I: IntoIterator<Item = String> { ... }
fn takes_plus_options() -> bool { ... }
fn get_content(
name: &str,
content_type: ContentType,
) -> Result<String, Error> { ... }
}Expand description
Trait implemented by built-in shell commands.
Required Associated Types§
Sourcetype Error: BuiltinError + 'static
type Error: BuiltinError + 'static
The error type returned by the command.
Required Methods§
Sourcefn execute(
&self,
context: ExecutionContext<'_>,
) -> impl Future<Output = Result<ExecutionResult, Self::Error>> + Send
fn execute( &self, context: ExecutionContext<'_>, ) -> impl Future<Output = Result<ExecutionResult, Self::Error>> + Send
Executes the built-in command in the provided context.
§Arguments
context- The context in which the command is being executed.
Provided Methods§
Sourcefn new<I>(args: I) -> Result<Self, Error>where
I: IntoIterator<Item = String>,
fn new<I>(args: I) -> Result<Self, Error>where
I: IntoIterator<Item = String>,
Instantiates the built-in command with the given arguments.
§Arguments
args- The arguments to the command.
Sourcefn takes_plus_options() -> bool
fn takes_plus_options() -> bool
Returns whether or not the command takes options with a leading ‘+’ or ‘-’ character.
Sourcefn get_content(name: &str, content_type: ContentType) -> Result<String, Error>
fn get_content(name: &str, content_type: ContentType) -> Result<String, Error>
Returns the textual help content associated with the command.
§Arguments
name- The name of the command.content_type- The type of content to retrieve.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.