Trait Instance

Source
pub trait Instance: 'static {
    // Required methods
    async fn new(id: String, cfg: &InstanceConfig) -> Result<Self, Error>
       where Self: Sized;
    async fn start(&self) -> Result<u32, Error>;
    async fn kill(&self, signal: u32) -> Result<(), Error>;
    async fn delete(&self) -> Result<(), Error>;
    async fn wait(&self) -> (u32, DateTime<Utc>);
}
Expand description

Represents a WASI module(s). Instance is a trait that gets implemented by consumers of this library. This trait requires that any type implementing it is 'static, similar to std::any::Any. This means that the type cannot contain a non-'static reference.

Required Methods§

Source

async fn new(id: String, cfg: &InstanceConfig) -> Result<Self, Error>
where Self: Sized,

Create a new instance

Source

async fn start(&self) -> Result<u32, Error>

Start the instance The returned value should be a unique ID (such as a PID) for the instance. Nothing internally should be using this ID, but it is returned to containerd where a user may want to use it.

Source

async fn kill(&self, signal: u32) -> Result<(), Error>

Send a signal to the instance

Source

async fn delete(&self) -> Result<(), Error>

Delete any reference to the instance This is called after the instance has exited.

Source

async fn wait(&self) -> (u32, DateTime<Utc>)

Waits for the instance to finish and returns its exit code This is an async call.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§