Skip to content

Updated example-host to use the latest deps #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions component-model/examples/example-host/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ edition = "2021"
[dependencies]
async-std = { version = "1.12.0", features = ["attributes"] }
clap = { version = "4.3.19", features = ["derive"] }
wasmtime = { git = "https://github.com/bytecodealliance/wasmtime", rev = "2ade3ad", features = ["component-model"] }
wasmtime-wasi = { git = "https://github.com/bytecodealliance/wasmtime", rev = "2ade3ad" }
wasi-cap-std-sync = { git = "https://github.com/bytecodealliance/wasmtime", rev = "2ade3ad" }
wasmtime = { version = "18", features = ["component-model"] }
wasmtime-wasi = "18"
anyhow = "1.0.72"
18 changes: 5 additions & 13 deletions component-model/examples/example-host/src/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Context;
use std::path::PathBuf;
use wasmtime::component::*;
use wasmtime::{Config, Engine, Store};
use wasmtime_wasi::preview2::{command, Table, WasiCtx, WasiCtxBuilder, WasiView};
use wasmtime_wasi::preview2::{command, ResourceTable, WasiCtx, WasiCtxBuilder, WasiView};

wasmtime::component::bindgen!({
path: "add.wit",
Expand Down Expand Up @@ -34,33 +34,25 @@ pub async fn add(path: PathBuf, x: i32, y: i32) -> wasmtime::Result<i32> {
}

struct ServerWasiView {
table: Table,
table: ResourceTable,
ctx: WasiCtx,
}

impl ServerWasiView {
fn new() -> Self {
let table = Table::new();
let table = ResourceTable::new();
let ctx = WasiCtxBuilder::new().inherit_stdio().build();

Self { table, ctx }
}
}

impl WasiView for ServerWasiView {
fn table(&self) -> &Table {
&self.table
}

fn table_mut(&mut self) -> &mut Table {
fn table(&mut self) -> &mut ResourceTable {
&mut self.table
}

fn ctx(&self) -> &WasiCtx {
&self.ctx
}

fn ctx_mut(&mut self) -> &mut WasiCtx {
fn ctx(&mut self) -> &mut WasiCtx {
&mut self.ctx
}
}