Skip to main content

RuntimePlugin

Trait RuntimePlugin 

Source
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§

Source

fn name(&self) -> String

The name of the plugin used to identify it.

Source

fn get_features(&self) -> Vec<RuntimeFeatures>

Source

fn get_version(&self) -> i32

Source

fn create_workload( &self, id: String, config: &RuntimeConfig, options: &Option<SandboxConfig>, ) -> Result<String, RuntimeError>

Source

fn start_workload(&mut self, id: String) -> Option<RuntimeError>

Source

fn stop_workload(&self, id: String, timeout: i32) -> Option<RuntimeError>

Source

fn remove_workload(&self, id: String) -> Option<RuntimeError>

Source

fn status_workload(&self, id: String) -> Result<WorkloadStatus, RuntimeError>

Source

fn update_workload_resources( &self, id: String, rez: WorkloadResources, ) -> Option<RuntimeError>

Source

fn exec_sync( &self, id: String, cmd: &[String], timeout: i32, ) -> (&[u8], &[u8], Option<RuntimeError>)

Provided Methods§

Source

fn on_plugin_load(&self)

A callback fired immediately after the plugin is loaded. Usually used for initialization.

Source

fn on_plugin_unload(&self)

A callback fired immediately before the plugin is unloaded. Use this if you need to do any cleanup.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§