Skip to content
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

Add missing wasi:random/insecure{,_seed} interfaces #2374

Merged
Merged
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
26 changes: 25 additions & 1 deletion crates/core/src/wasi_2023_10_18.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod bindings {
path: "../../wit",
interfaces: r#"
include wasi:http/[email protected];

// NB: this is handling the historical behavior where Spin supported
// more than "just" this snaphsot of the proxy world but additionally
// other CLI-related interfaces.
Expand Down Expand Up @@ -156,6 +156,8 @@ where
wasi::io::poll::add_to_linker(linker, |t| t)?;
wasi::io::streams::add_to_linker(linker, |t| t)?;
wasi::random::random::add_to_linker(linker, |t| t)?;
wasi::random::insecure::add_to_linker(linker, |t| t)?;
wasi::random::insecure_seed::add_to_linker(linker, |t| t)?;
wasi::cli::exit::add_to_linker(linker, |t| t)?;
wasi::cli::environment::add_to_linker(linker, |t| t)?;
wasi::cli::stdin::add_to_linker(linker, |t| t)?;
Expand Down Expand Up @@ -898,6 +900,28 @@ where
}
}

impl<T> wasi::random::insecure::Host for T
where
T: WasiView,
{
fn get_insecure_random_bytes(&mut self, len: u64) -> wasmtime::Result<Vec<u8>> {
<T as latest::random::insecure::Host>::get_insecure_random_bytes(self, len)
}

fn get_insecure_random_u64(&mut self) -> wasmtime::Result<u64> {
<T as latest::random::insecure::Host>::get_insecure_random_u64(self)
}
}

impl<T> wasi::random::insecure_seed::Host for T
where
T: WasiView,
{
fn insecure_seed(&mut self) -> wasmtime::Result<(u64, u64)> {
<T as latest::random::insecure_seed::Host>::insecure_seed(self)
}
}

impl<T> wasi::cli::exit::Host for T
where
T: WasiView,
Expand Down
26 changes: 25 additions & 1 deletion crates/core/src/wasi_2023_11_10.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mod bindings {
path: "../../wit",
interfaces: r#"
include wasi:http/[email protected];

// NB: this is handling the historical behavior where Spin supported
// more than "just" this snapshot of the proxy world but additionally
// other CLI-related interfaces.
Expand Down Expand Up @@ -154,6 +154,8 @@ where
wasi::io::poll::add_to_linker(linker, |t| t)?;
wasi::io::streams::add_to_linker(linker, |t| t)?;
wasi::random::random::add_to_linker(linker, |t| t)?;
wasi::random::insecure::add_to_linker(linker, |t| t)?;
wasi::random::insecure_seed::add_to_linker(linker, |t| t)?;
wasi::cli::exit::add_to_linker(linker, |t| t)?;
wasi::cli::environment::add_to_linker(linker, |t| t)?;
wasi::cli::stdin::add_to_linker(linker, |t| t)?;
Expand Down Expand Up @@ -843,6 +845,28 @@ where
}
}

impl<T> wasi::random::insecure::Host for T
where
T: WasiView,
{
fn get_insecure_random_bytes(&mut self, len: u64) -> wasmtime::Result<Vec<u8>> {
<T as latest::random::insecure::Host>::get_insecure_random_bytes(self, len)
}

fn get_insecure_random_u64(&mut self) -> wasmtime::Result<u64> {
<T as latest::random::insecure::Host>::get_insecure_random_u64(self)
}
}

impl<T> wasi::random::insecure_seed::Host for T
where
T: WasiView,
{
fn insecure_seed(&mut self) -> wasmtime::Result<(u64, u64)> {
<T as latest::random::insecure_seed::Host>::insecure_seed(self)
}
}

impl<T> wasi::cli::exit::Host for T
where
T: WasiView,
Expand Down
Loading