pub trait Plugin: Send + Sync {
Show 13 methods
// Required method
fn metadata(&self) -> &PluginMetadata;
// Provided methods
fn get_menu(&self) -> Vec<MenuItem> { ... }
fn get_commands(&self) -> Vec<ModalItem> { ... }
fn on_load<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_unload<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_output<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_line: &'life1 str,
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<Action>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn on_input<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_input: &'life1 [u8],
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<Action>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn on_pre_command<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_command: &'life1 str,
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<Action>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn on_post_command<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_command: &'life1 str,
_exit_code: i32,
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn on_resize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_cols: u16,
_rows: u16,
_ctx: &'life1 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_attach<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_client_id: u64,
_ctx: &'life1 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_detach<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_client_id: u64,
_ctx: &'life1 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_remote_command<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_id: &'life1 str,
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
Main plugin trait that all plugins must implement
Plugins can hook into various events in the terminal lifecycle. All methods have default implementations that do nothing.
Required Methods§
Sourcefn metadata(&self) -> &PluginMetadata
fn metadata(&self) -> &PluginMetadata
Get plugin metadata
Provided Methods§
Get the menu items for this plugin’s dock menu
This defines the menu that appears when the plugin is activated from the dock. Return an empty Vec if the plugin has no menu.
§Example
use scarab_plugin_api::menu::{MenuItem, MenuAction};
fn get_menu(&self) -> Vec<MenuItem> {
vec![
MenuItem::new("Chat", MenuAction::remote("open_chat"))
.with_icon("💬"),
MenuItem::new("Settings", MenuAction::remote("settings"))
.with_icon("⚙️"),
]
}Sourcefn get_commands(&self) -> Vec<ModalItem>
fn get_commands(&self) -> Vec<ModalItem>
Get list of commands provided by this plugin
Sourcefn on_load<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_load<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when the plugin is loaded
This is where plugins should initialize their state and resources.
Sourcefn on_unload<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn on_unload<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Called when the plugin is being unloaded
Plugins should clean up resources here.
Sourcefn on_output<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_line: &'life1 str,
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<Action>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_output<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_line: &'life1 str,
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<Action>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Hook called before output is displayed to the terminal
Plugins can modify, block, or pass through the output.
Sourcefn on_input<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_input: &'life1 [u8],
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<Action>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_input<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_input: &'life1 [u8],
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<Action>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Hook called after input is received from the user
Plugins can intercept and modify input before it reaches the PTY.
Sourcefn on_pre_command<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_command: &'life1 str,
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<Action>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_pre_command<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_command: &'life1 str,
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<Action>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Hook called before a command is executed
Sourcefn on_post_command<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_command: &'life1 str,
_exit_code: i32,
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_post_command<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_command: &'life1 str,
_exit_code: i32,
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Hook called after a command completes
Sourcefn on_resize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_cols: u16,
_rows: u16,
_ctx: &'life1 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_resize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_cols: u16,
_rows: u16,
_ctx: &'life1 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Hook called when terminal is resized
Sourcefn on_attach<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_client_id: u64,
_ctx: &'life1 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_attach<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_client_id: u64,
_ctx: &'life1 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Hook called when a client attaches to the session
Sourcefn on_detach<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_client_id: u64,
_ctx: &'life1 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_detach<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_client_id: u64,
_ctx: &'life1 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Hook called when a client detaches from the session
Sourcefn on_remote_command<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_id: &'life1 str,
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_remote_command<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
_id: &'life1 str,
_ctx: &'life2 PluginContext,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Hook called when a remote command is selected/triggered by the client
This is called when a user selects a menu item with MenuAction::Remote(id).