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

@@ -11,10 +11,10 @@ wiggle::from_witx!({
impl_errno!(types::Errno);
impl<'a> handle_examples::HandleExamples for WasiCtx<'a> {
fn fd_create(&self) -> Result<types::Fd, types::Errno> {
fn fd_create(&mut self) -> Result<types::Fd, types::Errno> {
Ok(types::Fd::from(FD_VAL))
}
fn fd_consume(&self, fd: types::Fd) -> Result<(), types::Errno> {
fn fd_consume(&mut self, fd: types::Fd) -> Result<(), types::Errno> {
println!("FD_CONSUME {}", fd);
if fd == types::Fd::from(FD_VAL) {
Ok(())
@@ -31,10 +31,10 @@ struct HandleExercise {
impl HandleExercise {
pub fn test(&self) {
let ctx = WasiCtx::new();
let mut ctx = WasiCtx::new();
let host_memory = HostMemory::new();
let e = handle_examples::fd_create(&ctx, &host_memory, self.return_loc.ptr as i32);
let e = handle_examples::fd_create(&mut ctx, &host_memory, self.return_loc.ptr as i32);
assert_eq!(e, Ok(types::Errno::Ok as i32), "fd_create error");
@@ -45,11 +45,11 @@ impl HandleExercise {
assert_eq!(h_got, 123, "fd_create return val");
let e = handle_examples::fd_consume(&ctx, &host_memory, h_got as i32);
let e = handle_examples::fd_consume(&mut ctx, &host_memory, h_got as i32);
assert_eq!(e, Ok(types::Errno::Ok as i32), "fd_consume error");
let e = handle_examples::fd_consume(&ctx, &host_memory, h_got as i32 + 1);
let e = handle_examples::fd_consume(&mut ctx, &host_memory, h_got as i32 + 1);
assert_eq!(
e,