Skip to content

Commit

Permalink
Simplify trait
Browse files Browse the repository at this point in the history
Signed-off-by: James Sturtevant <[email protected]>
  • Loading branch information
jsturtevant committed Feb 6, 2024
1 parent 063242a commit 346e064
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions crates/containerd-shim-wasmtime/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use wasmtime_wasi::{self as wasi_preview1, Dir};
pub type WasmtimeInstance = Instance<WasmtimeEngine<DefaultConfig>>;

#[derive(Clone)]
pub struct WasmtimeEngine<T: WasiConfig + Clone + Send + Sync> {
pub struct WasmtimeEngine<T: WasiConfig> {
engine: wasmtime::Engine,
config_type: PhantomData<T>,
}
Expand All @@ -32,11 +32,11 @@ impl WasiConfig for DefaultConfig {
}

Check warning on line 32 in crates/containerd-shim-wasmtime/src/instance.rs

View workflow job for this annotation

GitHub Actions / wasmtime / lint on ubuntu-latest

Diff in /home/runner/work/runwasi/runwasi/crates/containerd-shim-wasmtime/src/instance.rs
}

pub trait WasiConfig {
pub trait WasiConfig: Clone + Sync + Send + 'static {
fn new_config() -> Config;
}

impl<T: WasiConfig + Clone + Sync + Send> Default for WasmtimeEngine<T> {
impl<T: WasiConfig> Default for WasmtimeEngine<T> {
fn default() -> Self {
let config = T::new_config();
Self {
Expand Down Expand Up @@ -74,7 +74,7 @@ impl wasmtime_wasi::preview2::WasiView for WasiCtx {
}
}

impl<T: WasiConfig + Clone + Sync + Send + 'static> Engine for WasmtimeEngine<T> {
impl<T: WasiConfig> Engine for WasmtimeEngine<T> {
fn name() -> &'static str {
"wasmtime"
}
Expand Down
4 changes: 2 additions & 2 deletions crates/containerd-shim-wasmtime/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use WasmtimeTestInstance as WasiInstance;
use crate::instance::{WasiConfig, WasmtimeEngine};

// use test configuration to avoid dead locks when running tests
// https://github.com/containerd/runwasi/issues/357
type WasmtimeTestInstance = Instance<WasmtimeEngine<WasiTestConfig>>;

#[derive(Clone)]
Expand All @@ -18,8 +19,7 @@ struct WasiTestConfig {}
impl WasiConfig for WasiTestConfig {
fn new_config() -> Config {
let mut config = wasmtime::Config::new();
// Disable Wasmtime parallel compilation for the
// https://github.com/containerd/runwasi/issues/357
// Disable Wasmtime parallel compilation for the tests
// see https://github.com/containerd/runwasi/pull/405#issuecomment-1928468714 for details
config.parallel_compilation(false);
config.wasm_component_model(true); // enable component linking
Expand Down

0 comments on commit 346e064

Please sign in to comment.