Implement RFC 11: Redesigning Wasmtime's APIs (#2897)

Implement Wasmtime's new API as designed by RFC 11. This is quite a large commit which has had lots of discussion externally, so for more information it's best to read the RFC thread and the PR thread.
This commit is contained in:
Alex Crichton
2021-06-03 09:10:53 -05:00
committed by GitHub
parent a5a28b1c5b
commit 7a1b7cdf92
233 changed files with 13349 additions and 11997 deletions

View File

@@ -2,30 +2,14 @@ mod wiggle_interfaces;
pub use wiggle_interfaces::WasiCryptoCtx;
wasmtime_wiggle::wasmtime_integration!({
target: wiggle_interfaces::wasi_modules,
witx: ["$CARGO_MANIFEST_DIR/spec/witx/wasi_ephemeral_crypto.witx"],
ctx: WasiCryptoCtx,
modules: {
wasi_ephemeral_crypto_common =>
{
name: WasiCryptoCommon,
docs: "wasi-crypto - Common module."
},
wasi_ephemeral_crypto_asymmetric_common =>
{
name: WasiCryptoAsymmetricCommon,
docs: "wasi-crypto - Common module for asymmetric operations."
},
wasi_ephemeral_crypto_signatures =>
{
name: WasiCryptoSignatures,
docs: "wasi-crypto - Signature module."
},
wasi_ephemeral_crypto_symmetric =>
{
name: WasiCryptoSymmetric,
docs: "wasi-crypto - Symmetric cryptography module."
}
}
});
pub fn add_to_linker<T>(
linker: &mut wasmtime::Linker<T>,
get_cx: impl Fn(&mut T) -> &mut WasiCryptoCtx + Send + Sync + Copy + 'static,
) -> anyhow::Result<()> {
use wiggle_interfaces::wasi_modules as w;
w::wasi_ephemeral_crypto_common::add_to_linker(linker, get_cx)?;
w::wasi_ephemeral_crypto_asymmetric_common::add_to_linker(linker, get_cx)?;
w::wasi_ephemeral_crypto_signatures::add_to_linker(linker, get_cx)?;
w::wasi_ephemeral_crypto_symmetric::add_to_linker(linker, get_cx)?;
Ok(())
}