Skip to main content

CustomAction

Trait CustomAction 

Source
pub trait CustomAction: Send + Sync {
    // Required method
    fn run(
        &self,
        context: &Context,
        task_id: MaaId,
        node_name: &str,
        custom_action_name: &str,
        custom_action_param: &str,
        reco_id: MaaId,
        box_rect: &Rect,
    ) -> bool;
}
Expand description

Trait for implementing custom actions.

Actions are executed after a successful recognition and can perform clicks, swipes, or custom logic.

Required Methods§

Source

fn run( &self, context: &Context, task_id: MaaId, node_name: &str, custom_action_name: &str, custom_action_param: &str, reco_id: MaaId, box_rect: &Rect, ) -> bool

Execute the custom action.

§Arguments
  • context - The current execution context
  • task_id - ID of the current task
  • node_name - Name of the current node
  • custom_action_name - Name of this action (as registered)
  • custom_action_param - JSON parameters for this action
  • reco_id - ID of the preceding recognition result
  • box_rect - Target region found by recognition
§Returns

true if the action succeeded, false otherwise

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<F> CustomAction for FnAction<F>
where F: Fn(&Context, &ActionArgs<'_>) -> bool + Send + Sync,