Stream: wasi

Topic: using wasi types


view this post on Zulip julia (Sep 19 2022 at 23:24):

I want to use some types which are used by wasi in my code which is added to wasmtime-cli (run.rs file). For doing that, so I added wasi-common crate to dependencies. And then I imported types using the below line:
wasi_common::snapshots::preview_1::types::*;

But I still got errors when I want to use some types. For example, for Fd, I used the similar code in fd_write function and use wasi in Host struct as WasiCtx.

        let fd_val: u32 = i1.try_into().unwrap();
        let new_fd=Fd::from(fd_val);
            let f = name
            .table()
            .get_file_mut(fd_val)?
            .get_cap_mut(FileCaps::WRITE)?;
      }

It says:
no method named `get_file_mut` found for mutable reference `&mut wasi_common::Table` in the current scope. --> src/commands/run.rs:258:14

Can you please help me with that?
(Sorry I just started to work on wasmtime and wasi)

A fast and secure runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.

view this post on Zulip Lann Martin (Sep 20 2022 at 12:55):

get_file_mut is a crate-private method. I'm not sure that what you are trying to do is actually possible with the current public interface.

view this post on Zulip Pat Hickey (Sep 22 2022 at 00:10):

We could make that method public if it solves your problem. Feel free to send a PR and mark me as the reviewer

view this post on Zulip julia (Sep 22 2022 at 18:51):

@Pat Hickey Oh that would be great! right now, I changed my plan for implementation, will do if I decide to use this way.


Last updated: Oct 23 2024 at 20:03 UTC