pub trait RuntimePlugin:
Any
+ Send
+ Sync {
// Required methods
fn name(&self) -> String;
fn get_features(&self) -> Vec<RuntimeFeatures>;
fn get_version(&self) -> i32;
fn create_workload(
&self,
id: String,
config: &RuntimeConfig,
options: &Option<SandboxConfig>,
) -> Result<String, RuntimeError>;
fn start_workload(&mut self, id: String) -> Option<RuntimeError>;
fn stop_workload(&self, id: String, timeout: i32) -> Option<RuntimeError>;
fn remove_workload(&self, id: String) -> Option<RuntimeError>;
fn status_workload(
&self,
id: String,
) -> Result<WorkloadStatus, RuntimeError>;
fn update_workload_resources(
&self,
id: String,
rez: WorkloadResources,
) -> Option<RuntimeError>;
fn exec_sync(
&self,
id: String,
cmd: &[String],
timeout: i32,
) -> (&[u8], &[u8], Option<RuntimeError>);
// Provided methods
fn on_plugin_load(&self) { ... }
fn on_plugin_unload(&self) { ... }
}
Expand description
A trait for plugins that run workloads Any unimplemented function should return RuntimeErrors::Unimplemented as this is used internally to ensure functionality of the plugin.
Required Methods§
fn get_features(&self) -> Vec<RuntimeFeatures>
fn get_version(&self) -> i32
fn create_workload( &self, id: String, config: &RuntimeConfig, options: &Option<SandboxConfig>, ) -> Result<String, RuntimeError>
fn start_workload(&mut self, id: String) -> Option<RuntimeError>
fn stop_workload(&self, id: String, timeout: i32) -> Option<RuntimeError>
fn remove_workload(&self, id: String) -> Option<RuntimeError>
fn status_workload(&self, id: String) -> Result<WorkloadStatus, RuntimeError>
fn update_workload_resources( &self, id: String, rez: WorkloadResources, ) -> Option<RuntimeError>
fn exec_sync( &self, id: String, cmd: &[String], timeout: i32, ) -> (&[u8], &[u8], Option<RuntimeError>)
Provided Methods§
Sourcefn on_plugin_load(&self)
fn on_plugin_load(&self)
A callback fired immediately after the plugin is loaded. Usually used for initialization.
Sourcefn on_plugin_unload(&self)
fn on_plugin_unload(&self)
A callback fired immediately before the plugin is unloaded. Use this if you need to do any cleanup.