Trait CommandTrait

Source
pub trait CommandTrait: 'static {
    // Required methods
    fn name(&self) -> Name;
    fn inputs(&self) -> Vec<CmdInputDescription>;
    fn outputs(&self) -> Vec<CmdOutputDescription>;
    fn run<'life0, 'async_trait>(
        &'life0 self,
        ctx: CommandContext,
        params: ValueSet,
    ) -> Pin<Box<dyn Future<Output = Result<ValueSet, CommandError>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn instruction_info(&self) -> Option<InstructionInfo> { ... }
    fn permissions(&self) -> Permissions { ... }
    fn destroy<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn read_form_data(&self, data: Value) -> ValueSet { ... }
    fn passthrough_outputs(&self, inputs: &ValueSet) -> ValueSet { ... }
    fn input_is_required(&self, name: &str) -> Option<bool> { ... }
    fn output_is_optional(&self, name: &str) -> Option<bool> { ... }
}
Expand description

Generic trait for implementing commands.

Required Methods§

Source

fn name(&self) -> Name

Unique name to identify the command.

Source

fn inputs(&self) -> Vec<CmdInputDescription>

List of inputs that the command can receive.

Source

fn outputs(&self) -> Vec<CmdOutputDescription>

List of outputs that the command will return.

Source

fn run<'life0, 'async_trait>( &'life0 self, ctx: CommandContext, params: ValueSet, ) -> Pin<Box<dyn Future<Output = Result<ValueSet, CommandError>> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Run the command.

Provided Methods§

Source

fn instruction_info(&self) -> Option<InstructionInfo>

Specify if and how would this command output Solana instructions.

Source

fn permissions(&self) -> Permissions

Specify requested permissions of this command.

Source

fn destroy<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = ()> + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Async Drop method.

Source

fn read_form_data(&self, data: Value) -> ValueSet

Specify how form_data are read.

Source

fn passthrough_outputs(&self, inputs: &ValueSet) -> ValueSet

Specify how to convert inputs into passthrough outputs.

Source

fn input_is_required(&self, name: &str) -> Option<bool>

Source

fn output_is_optional(&self, name: &str) -> Option<bool>

Implementors§