Skip to content

Commit

Permalink
🐛 Fix wasmtime container example.
Browse files Browse the repository at this point in the history
  • Loading branch information
langyo committed Apr 15, 2024
1 parent 301594c commit fbde778
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion examples/host-side/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async fn main() -> Result<()> {
let tx = container.tx.clone();
let rx = container.rx.clone();
async_std::task::spawn(async move {
container.run().await.unwrap();
container.run().unwrap();
});

while let Ok(msg) = rx.recv() {
Expand Down
18 changes: 6 additions & 12 deletions packages/vm/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use wasmtime::{
component::{Component, Linker},
Config, Engine, Store,
};
use wasmtime_wasi::preview2::{
use wasmtime_wasi::{
command::{self, sync::Command},
Table, WasiCtx, WasiCtxBuilder, WasiView,
ResourceTable, WasiCtx, WasiCtxBuilder, WasiView,
};
use wit_component::ComponentEncoder;

Expand All @@ -24,20 +24,14 @@ lazy_static! {

pub struct WasiContext {
wasi: WasiCtx,
table: Table,
table: ResourceTable,
}

impl WasiView for WasiContext {
fn ctx(&self) -> &WasiCtx {
&self.wasi
}
fn ctx_mut(&mut self) -> &mut WasiCtx {
fn ctx(&mut self) -> &mut WasiCtx {
&mut self.wasi
}
fn table(&self) -> &Table {
&self.table
}
fn table_mut(&mut self) -> &mut Table {
fn table(&mut self) -> &mut ResourceTable {
&mut self.table
}
}
Expand Down Expand Up @@ -123,7 +117,7 @@ impl Image {
wasi.stdout(output_stream);

let wasi = wasi.build();
let table = Table::new();
let table = ResourceTable::new();
let store = Store::new(&self.engine, WasiContext { wasi, table });

Ok(Container {
Expand Down
2 changes: 1 addition & 1 deletion packages/vm/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bytes::Bytes;
use flume::Sender;
use std::sync::{Arc, Mutex};

use wasmtime_wasi::preview2::{
use wasmtime_wasi::{
HostInputStream, HostOutputStream, StdinStream, StdoutStream, StreamResult, Subscribe,
};

Expand Down

0 comments on commit fbde778

Please sign in to comment.