fix wasi-nn and wasi-crypto integrations for wasmtime-wiggle changes
the Rc<RefCell<ctx>> wrapping inside the wasmtime-generated bindings was eliminated, and instead the caller of ::new(linker, ctx) is required to wrap the ctx in Rc<RefCell<>>. The Rc wrapping inside WasiCryptoCtx can be eliminated due to this change.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use wasi_crypto::CryptoCtx;
|
pub use wasi_crypto::CryptoCtx as WasiCryptoCtx;
|
||||||
|
|
||||||
wiggle::from_witx!({
|
wiggle::from_witx!({
|
||||||
witx: ["$CARGO_MANIFEST_DIR/spec/witx/wasi_ephemeral_crypto.witx"],
|
witx: ["$CARGO_MANIFEST_DIR/spec/witx/wasi_ephemeral_crypto.witx"],
|
||||||
@@ -17,19 +17,6 @@ pub mod wasi_modules {
|
|||||||
|
|
||||||
pub use types as guest_types;
|
pub use types as guest_types;
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
pub struct WasiCryptoCtx {
|
|
||||||
ctx: Rc<CryptoCtx>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WasiCryptoCtx {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
WasiCryptoCtx {
|
|
||||||
ctx: Rc::new(CryptoCtx::new()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mod asymmetric_common;
|
mod asymmetric_common;
|
||||||
mod common;
|
mod common;
|
||||||
mod error;
|
mod error;
|
||||||
|
|||||||
@@ -363,17 +363,21 @@ fn populate_with_wasi(
|
|||||||
|
|
||||||
#[cfg(feature = "wasi-nn")]
|
#[cfg(feature = "wasi-nn")]
|
||||||
{
|
{
|
||||||
let wasi_nn = WasiNn::new(linker.store(), WasiNnCtx::new()?);
|
use std::cell::RefCell;
|
||||||
|
use std::rc::Rc;
|
||||||
|
let wasi_nn = WasiNn::new(linker.store(), Rc::new(RefCell::new(WasiNnCtx::new()?)));
|
||||||
wasi_nn.add_to_linker(linker)?;
|
wasi_nn.add_to_linker(linker)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "wasi-crypto")]
|
#[cfg(feature = "wasi-crypto")]
|
||||||
{
|
{
|
||||||
let cx_crypto = WasiCryptoCtx::new();
|
use std::cell::RefCell;
|
||||||
|
use std::rc::Rc;
|
||||||
|
let cx_crypto = Rc::new(RefCell::new(WasiCryptoCtx::new()));
|
||||||
WasiCryptoCommon::new(linker.store(), cx_crypto.clone()).add_to_linker(linker)?;
|
WasiCryptoCommon::new(linker.store(), cx_crypto.clone()).add_to_linker(linker)?;
|
||||||
WasiCryptoAsymmetricCommon::new(linker.store(), cx_crypto.clone()).add_to_linker(linker)?;
|
WasiCryptoAsymmetricCommon::new(linker.store(), cx_crypto.clone()).add_to_linker(linker)?;
|
||||||
WasiCryptoSignatures::new(linker.store(), cx_crypto.clone()).add_to_linker(linker)?;
|
WasiCryptoSignatures::new(linker.store(), cx_crypto.clone()).add_to_linker(linker)?;
|
||||||
WasiCryptoSymmetric::new(linker.store(), cx_crypto.clone()).add_to_linker(linker)?;
|
WasiCryptoSymmetric::new(linker.store(), cx_crypto).add_to_linker(linker)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user