Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Consult the host's `socket_addr_check` for implicit binds (#13677)

Alex Crichton72403200a425
diff --git a/crates/component-macro/src/bindgen.rs b/crates/component-macro/src/bindgen.rs
index b651b867f3..fa9ec3d8e7 100644
--- a/crates/component-macro/src/bindgen.rs
+++ b/crates/component-macro/src/bindgen.rs
@@ -268,7 +268,6 @@ mod kw {
syn::custom_keyword!(exports);
syn::custom_keyword!(store);
syn::custom_keyword!(trappable);
- syn::custom_keyword!(ignore_wit);
syn::custom_keyword!(exact);
}
@@ -547,9 +546,6 @@ fn parse_function_config(input: ParseStream<'_>) -> Result<FunctionConfig> {
} else if l.peek(kw::trappable) {
input.parse::<kw::trappable>()?;
flags |= FunctionFlags::TRAPPABLE;
- } else if l.peek(kw::ignore_wit) {
- input.parse::<kw::ignore_wit>()?;
- flags |= FunctionFlags::IGNORE_WIT;
} else if l.peek(kw::exact) {
input.parse::<kw::exact>()?;
flags |= FunctionFlags::EXACT;
diff --git a/crates/component-macro/tests/expanded/char_concurrent.rs b/crates/component-macro/tests/expanded/char_concurrent.rs
index a32891b463..9a745b72a9 100644
--- a/crates/component-macro/tests/expanded/char_concurrent.rs
+++ b/crates/component-macro/tests/expanded/char_concurrent.rs
@@ -192,12 +192,12 @@ pub mod foo {
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
/// A function that accepts a character
fn take_char(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: char,
) -> impl ::core::future::Future<Output = ()> + Send;
/// A function that returns a character
fn return_char(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = char> + Send;
}
pub trait Host: Send {}
@@ -211,21 +211,36 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"take-char",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (char,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |
+ mut caller: wasmtime::StoreContextMut<'_, T>,
+ (arg0,): (char,)|
+ {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::take_char(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"return-char",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::return_char(host).await;
Ok((r,))
})
diff --git a/crates/component-macro/tests/expanded/conventions_concurrent.rs b/crates/component-macro/tests/expanded/conventions_concurrent.rs
index 8415239896..59cbdb3290 100644
--- a/crates/component-macro/tests/expanded/conventions_concurrent.rs
+++ b/crates/component-macro/tests/expanded/conventions_concurrent.rs
@@ -225,29 +225,29 @@ pub mod foo {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn kebab_case(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn foo(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: LudicrousSpeed,
) -> impl ::core::future::Future<Output = ()> + Send;
fn function_with_dashes(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn function_with_no_weird_characters(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn apple(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn apple_pear(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn apple_pear_grape(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn a0(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
/// Comment out identifiers that collide when mapped to snake_case, for now; see
/// https://github.com/WebAssembly/component-model/issues/118
@@ -255,17 +255,17 @@ pub mod foo {
/// APPLE-pear-GRAPE: func()
/// apple-PEAR-grape: func()
fn is_xml(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn explicit(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn explicit_kebab(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
/// Identifiers with the same name as keywords are quoted.
fn bool(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
}
pub trait Host: Send {}
@@ -279,45 +279,69 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"kebab-case",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::kebab_case(host).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"foo",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (LudicrousSpeed,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::foo(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"function-with-dashes",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::function_with_dashes(host)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"function-with-no-weird-characters",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::function_with_no_weird_characters(host)
@@ -326,82 +350,130 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"apple",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::apple(host).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"apple-pear",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::apple_pear(host).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"apple-pear-grape",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::apple_pear_grape(host)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a0",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::a0(host).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"is-XML",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::is_xml(host).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"explicit",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::explicit(host).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"explicit-kebab",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::explicit_kebab(host).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"bool",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::bool(host).await;
Ok(r)
})
diff --git a/crates/component-macro/tests/expanded/dead-code_concurrent.rs b/crates/component-macro/tests/expanded/dead-code_concurrent.rs
index 3d7b065dd3..818c296a4d 100644
--- a/crates/component-macro/tests/expanded/dead-code_concurrent.rs
+++ b/crates/component-macro/tests/expanded/dead-code_concurrent.rs
@@ -207,7 +207,7 @@ pub mod a {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn f(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = LiveType> + Send;
}
pub trait Host: Send {}
@@ -221,11 +221,17 @@ pub mod a {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"f",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::f(host).await;
Ok((r,))
})
diff --git a/crates/component-macro/tests/expanded/direct-import_concurrent.rs b/crates/component-macro/tests/expanded/direct-import_concurrent.rs
index e7dd908006..54be0cb145 100644
--- a/crates/component-macro/tests/expanded/direct-import_concurrent.rs
+++ b/crates/component-macro/tests/expanded/direct-import_concurrent.rs
@@ -100,7 +100,7 @@ pub struct FooIndices {}
pub struct Foo {}
pub trait FooImportsWithStore<T>: wasmtime::component::HasData + Send {
fn foo(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
}
pub trait FooImports: Send {}
@@ -178,11 +178,17 @@ const _: () = {
{
let mut linker = linker.root();
linker
- .func_wrap_concurrent(
+ .func_wrap_async(
"foo",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as FooImportsWithStore<T>>::foo(host).await;
Ok(r)
})
diff --git a/crates/component-macro/tests/expanded/flags_concurrent.rs b/crates/component-macro/tests/expanded/flags_concurrent.rs
index 7b862d1832..eeb3ef4da4 100644
--- a/crates/component-macro/tests/expanded/flags_concurrent.rs
+++ b/crates/component-macro/tests/expanded/flags_concurrent.rs
@@ -305,31 +305,31 @@ pub mod foo {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn roundtrip_flag1(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Flag1,
) -> impl ::core::future::Future<Output = Flag1> + Send;
fn roundtrip_flag2(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Flag2,
) -> impl ::core::future::Future<Output = Flag2> + Send;
fn roundtrip_flag4(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Flag4,
) -> impl ::core::future::Future<Output = Flag4> + Send;
fn roundtrip_flag8(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Flag8,
) -> impl ::core::future::Future<Output = Flag8> + Send;
fn roundtrip_flag16(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Flag16,
) -> impl ::core::future::Future<Output = Flag16> + Send;
fn roundtrip_flag32(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Flag32,
) -> impl ::core::future::Future<Output = Flag32> + Send;
fn roundtrip_flag64(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Flag64,
) -> impl ::core::future::Future<Output = Flag64> + Send;
}
@@ -344,77 +344,140 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"roundtrip-flag1",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (Flag1,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |
+ mut caller: wasmtime::StoreContextMut<'_, T>,
+ (arg0,): (Flag1,)|
+ {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::roundtrip_flag1(host, arg0)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"roundtrip-flag2",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (Flag2,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |
+ mut caller: wasmtime::StoreContextMut<'_, T>,
+ (arg0,): (Flag2,)|
+ {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::roundtrip_flag2(host, arg0)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"roundtrip-flag4",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (Flag4,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |
+ mut caller: wasmtime::StoreContextMut<'_, T>,
+ (arg0,): (Flag4,)|
+ {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::roundtrip_flag4(host, arg0)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"roundtrip-flag8",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (Flag8,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |
+ mut caller: wasmtime::StoreContextMut<'_, T>,
+ (arg0,): (Flag8,)|
+ {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::roundtrip_flag8(host, arg0)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"roundtrip-flag16",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (Flag16,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |
+ mut caller: wasmtime::StoreContextMut<'_, T>,
+ (arg0,): (Flag16,)|
+ {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::roundtrip_flag16(host, arg0)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"roundtrip-flag32",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (Flag32,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |
+ mut caller: wasmtime::StoreContextMut<'_, T>,
+ (arg0,): (Flag32,)|
+ {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::roundtrip_flag32(host, arg0)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"roundtrip-flag64",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (Flag64,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |
+ mut caller: wasmtime::StoreContextMut<'_, T>,
+ (arg0,): (Flag64,)|
+ {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::roundtrip_flag64(host, arg0)
.await;
Ok((r,))
diff --git a/crates/component-macro/tests/expanded/floats_concurrent.rs b/crates/component-macro/tests/expanded/floats_concurrent.rs
index 737bab5fcb..3e26d4fca1 100644
--- a/crates/component-macro/tests/expanded/floats_concurrent.rs
+++ b/crates/component-macro/tests/expanded/floats_concurrent.rs
@@ -193,18 +193,18 @@ pub mod foo {
use wasmtime::component::__internal::Box;
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn f32_param(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: f32,
) -> impl ::core::future::Future<Output = ()> + Send;
fn f64_param(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: f64,
) -> impl ::core::future::Future<Output = ()> + Send;
fn f32_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = f32> + Send;
fn f64_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = f64> + Send;
}
pub trait Host: Send {}
@@ -218,41 +218,65 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"f32-param",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (f32,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (f32,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::f32_param(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"f64-param",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (f64,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (f64,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::f64_param(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"f32-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::f32_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"f64-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::f64_result(host).await;
Ok((r,))
})
diff --git a/crates/component-macro/tests/expanded/host-world_concurrent.rs b/crates/component-macro/tests/expanded/host-world_concurrent.rs
index 0971f297ce..bae345345a 100644
--- a/crates/component-macro/tests/expanded/host-world_concurrent.rs
+++ b/crates/component-macro/tests/expanded/host-world_concurrent.rs
@@ -100,7 +100,7 @@ pub struct Host_Indices {}
pub struct Host_ {}
pub trait Host_ImportsWithStore<T>: wasmtime::component::HasData + Send {
fn foo(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
}
pub trait Host_Imports: Send {}
@@ -178,11 +178,17 @@ const _: () = {
{
let mut linker = linker.root();
linker
- .func_wrap_concurrent(
+ .func_wrap_async(
"foo",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as Host_ImportsWithStore<T>>::foo(host).await;
Ok(r)
})
diff --git a/crates/component-macro/tests/expanded/implements_concurrent.rs b/crates/component-macro/tests/expanded/implements_concurrent.rs
index bddc982224..99e264e6d2 100644
--- a/crates/component-macro/tests/expanded/implements_concurrent.rs
+++ b/crates/component-macro/tests/expanded/implements_concurrent.rs
@@ -190,13 +190,13 @@ pub mod foo {
use wasmtime::component::__internal::Box;
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn get(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
key: wasmtime::component::__internal::String,
) -> impl ::core::future::Future<
Output = Option<wasmtime::component::__internal::String>,
> + Send;
fn set(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
key: wasmtime::component::__internal::String,
value: wasmtime::component::__internal::String,
) -> impl ::core::future::Future<Output = ()> + Send;
@@ -212,23 +212,29 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"get",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::String,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::get(host, arg0).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"set",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
arg1,
@@ -237,8 +243,14 @@ pub mod foo {
wasmtime::component::__internal::String,
)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::set(host, arg0, arg1).await;
Ok(r)
})
diff --git a/crates/component-macro/tests/expanded/integers_concurrent.rs b/crates/component-macro/tests/expanded/integers_concurrent.rs
index 680f1fd2f5..de83fa322b 100644
--- a/crates/component-macro/tests/expanded/integers_concurrent.rs
+++ b/crates/component-macro/tests/expanded/integers_concurrent.rs
@@ -193,39 +193,39 @@ pub mod foo {
use wasmtime::component::__internal::Box;
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn a1(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: u8,
) -> impl ::core::future::Future<Output = ()> + Send;
fn a2(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: i8,
) -> impl ::core::future::Future<Output = ()> + Send;
fn a3(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: u16,
) -> impl ::core::future::Future<Output = ()> + Send;
fn a4(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: i16,
) -> impl ::core::future::Future<Output = ()> + Send;
fn a5(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: u32,
) -> impl ::core::future::Future<Output = ()> + Send;
fn a6(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: i32,
) -> impl ::core::future::Future<Output = ()> + Send;
fn a7(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: u64,
) -> impl ::core::future::Future<Output = ()> + Send;
fn a8(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: i64,
) -> impl ::core::future::Future<Output = ()> + Send;
fn a9(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
p1: u8,
p2: i8,
p3: u16,
@@ -236,31 +236,31 @@ pub mod foo {
p8: i64,
) -> impl ::core::future::Future<Output = ()> + Send;
fn r1(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = u8> + Send;
fn r2(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = i8> + Send;
fn r3(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = u16> + Send;
fn r4(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = i16> + Send;
fn r5(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = u32> + Send;
fn r6(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = i32> + Send;
fn r7(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = u64> + Send;
fn r8(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = i64> + Send;
fn pair_ret(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = (i64, u8)> + Send;
}
pub trait Host: Send {}
@@ -274,90 +274,138 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a1",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (u8,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u8,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::a1(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a2",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (i8,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i8,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::a2(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a3",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (u16,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u16,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::a3(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a4",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (i16,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i16,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::a4(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a5",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (u32,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u32,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::a5(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a6",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (i32,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i32,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::a6(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a7",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (u64,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u64,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::a7(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a8",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (i64,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (i64,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::a8(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a9",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
arg1,
@@ -369,8 +417,14 @@ pub mod foo {
arg7,
): (u8, i8, u16, i16, u32, i32, u64, i64)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::a9(host, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
@@ -379,91 +433,145 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"r1",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::r1(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"r2",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::r2(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"r3",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::r3(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"r4",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::r4(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"r5",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::r5(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"r6",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::r6(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"r7",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::r7(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"r8",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::r8(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"pair-ret",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::pair_ret(host).await;
Ok((r,))
})
diff --git a/crates/component-macro/tests/expanded/lists_concurrent.rs b/crates/component-macro/tests/expanded/lists_concurrent.rs
index 7ea12b27fc..61e8416e54 100644
--- a/crates/component-macro/tests/expanded/lists_concurrent.rs
+++ b/crates/component-macro/tests/expanded/lists_concurrent.rs
@@ -371,116 +371,116 @@ pub mod foo {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn list_u8_param(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<u8>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn list_u16_param(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<u16>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn list_u32_param(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<u32>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn list_u64_param(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<u64>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn list_s8_param(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<i8>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn list_s16_param(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<i16>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn list_s32_param(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<i32>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn list_s64_param(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<i64>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn list_f32_param(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<f32>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn list_f64_param(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<f64>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn list_u8_ret(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<u8>,
> + Send;
fn list_u16_ret(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<u16>,
> + Send;
fn list_u32_ret(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<u32>,
> + Send;
fn list_u64_ret(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<u64>,
> + Send;
fn list_s8_ret(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<i8>,
> + Send;
fn list_s16_ret(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<i16>,
> + Send;
fn list_s32_ret(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<i32>,
> + Send;
fn list_s64_ret(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<i64>,
> + Send;
fn list_f32_ret(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<f32>,
> + Send;
fn list_f64_ret(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<f64>,
> + Send;
fn tuple_list(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<(u8, i8)>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<(i64, u32)>,
> + Send;
fn string_list_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
a: wasmtime::component::__internal::Vec<
wasmtime::component::__internal::String,
>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn string_list_ret(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<
wasmtime::component::__internal::String,
>,
> + Send;
fn tuple_string_list(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<
(u8, wasmtime::component::__internal::String),
>,
@@ -490,7 +490,7 @@ pub mod foo {
>,
> + Send;
fn string_list(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<
wasmtime::component::__internal::String,
>,
@@ -500,25 +500,25 @@ pub mod foo {
>,
> + Send;
fn record_list(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<SomeRecord>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<OtherRecord>,
> + Send;
fn record_list_reverse(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<OtherRecord>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<SomeRecord>,
> + Send;
fn variant_list(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<SomeVariant>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<OtherVariant>,
> + Send;
fn load_store_everything(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
a: LoadStoreAllSizes,
) -> impl ::core::future::Future<Output = LoadStoreAllSizes> + Send;
}
@@ -533,264 +533,390 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-u8-param",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<u8>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_u8_param(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-u16-param",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<u16>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_u16_param(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-u32-param",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<u32>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_u32_param(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-u64-param",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<u64>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_u64_param(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-s8-param",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<i8>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_s8_param(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-s16-param",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<i16>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_s16_param(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-s32-param",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<i32>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_s32_param(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-s64-param",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<i64>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_s64_param(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-f32-param",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<f32>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_f32_param(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-f64-param",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<f64>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_f64_param(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-u8-ret",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_u8_ret(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-u16-ret",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_u16_ret(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-u32-ret",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_u32_ret(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-u64-ret",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_u64_ret(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-s8-ret",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_s8_ret(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-s16-ret",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_s16_ret(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-s32-ret",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_s32_ret(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-s64-ret",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_s64_ret(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-f32-ret",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_f32_ret(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-f64-ret",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_f64_ret(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"tuple-list",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<(u8, i8)>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::tuple_list(host, arg0)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"string-list-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
): (
@@ -799,28 +925,40 @@ pub mod foo {
>,
)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::string_list_arg(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"string-list-ret",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::string_list_ret(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"tuple-string-list",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
): (
@@ -829,8 +967,14 @@ pub mod foo {
>,
)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::tuple_string_list(host, arg0)
@@ -839,10 +983,10 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"string-list",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
): (
@@ -851,36 +995,54 @@ pub mod foo {
>,
)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::string_list(host, arg0)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"record-list",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<SomeRecord>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::record_list(host, arg0)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"record-list-reverse",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<OtherRecord>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::record_list_reverse(host, arg0)
@@ -889,28 +1051,40 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"variant-list",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<SomeVariant>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::variant_list(host, arg0)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"load-store-everything",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (LoadStoreAllSizes,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::load_store_everything(host, arg0)
diff --git a/crates/component-macro/tests/expanded/many-arguments_concurrent.rs b/crates/component-macro/tests/expanded/many-arguments_concurrent.rs
index 66e856b323..3b1753305c 100644
--- a/crates/component-macro/tests/expanded/many-arguments_concurrent.rs
+++ b/crates/component-macro/tests/expanded/many-arguments_concurrent.rs
@@ -274,7 +274,7 @@ pub mod foo {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn many_args(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
a1: u64,
a2: u64,
a3: u64,
@@ -293,7 +293,7 @@ pub mod foo {
a16: u64,
) -> impl ::core::future::Future<Output = ()> + Send;
fn big_argument(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: BigStruct,
) -> impl ::core::future::Future<Output = ()> + Send;
}
@@ -308,10 +308,10 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"many-args",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
arg1,
@@ -348,8 +348,14 @@ pub mod foo {
u64,
)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::many_args(
@@ -376,14 +382,20 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"big-argument",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (BigStruct,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::big_argument(host, arg0)
.await;
Ok(r)
diff --git a/crates/component-macro/tests/expanded/multiversion_concurrent.rs b/crates/component-macro/tests/expanded/multiversion_concurrent.rs
index f31e9e97a4..068971a107 100644
--- a/crates/component-macro/tests/expanded/multiversion_concurrent.rs
+++ b/crates/component-macro/tests/expanded/multiversion_concurrent.rs
@@ -203,7 +203,7 @@ pub mod my {
use wasmtime::component::__internal::Box;
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn x(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
}
pub trait Host: Send {}
@@ -217,11 +217,17 @@ pub mod my {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"x",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::x(host).await;
Ok(r)
})
@@ -250,7 +256,7 @@ pub mod my {
use wasmtime::component::__internal::Box;
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn x(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
}
pub trait Host: Send {}
@@ -264,11 +270,17 @@ pub mod my {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"x",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::x(host).await;
Ok(r)
})
diff --git a/crates/component-macro/tests/expanded/records_concurrent.rs b/crates/component-macro/tests/expanded/records_concurrent.rs
index f7c4473155..4e7febef64 100644
--- a/crates/component-macro/tests/expanded/records_concurrent.rs
+++ b/crates/component-macro/tests/expanded/records_concurrent.rs
@@ -390,42 +390,42 @@ pub mod foo {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn tuple_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: (char, u32),
) -> impl ::core::future::Future<Output = ()> + Send;
fn tuple_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = (char, u32)> + Send;
fn empty_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Empty,
) -> impl ::core::future::Future<Output = ()> + Send;
fn empty_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Empty> + Send;
fn scalar_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Scalars,
) -> impl ::core::future::Future<Output = ()> + Send;
fn scalar_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Scalars> + Send;
fn flags_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: ReallyFlags,
) -> impl ::core::future::Future<Output = ()> + Send;
fn flags_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ReallyFlags> + Send;
fn aggregate_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Aggregates,
) -> impl ::core::future::Future<Output = ()> + Send;
fn aggregate_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Aggregates> + Send;
fn typedef_inout(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
e: TupleTypedef2,
) -> impl ::core::future::Future<Output = i32> + Send;
}
@@ -440,129 +440,198 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"tuple-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): ((char, u32),)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::tuple_arg(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"tuple-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::tuple_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"empty-arg",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (Empty,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |
+ mut caller: wasmtime::StoreContextMut<'_, T>,
+ (arg0,): (Empty,)|
+ {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::empty_arg(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"empty-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::empty_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"scalar-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (Scalars,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::scalar_arg(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"scalar-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::scalar_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"flags-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (ReallyFlags,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::flags_arg(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"flags-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::flags_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"aggregate-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (Aggregates,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::aggregate_arg(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"aggregate-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::aggregate_result(host)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"typedef-inout",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (TupleTypedef2,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::typedef_inout(host, arg0)
.await;
Ok((r,))
diff --git a/crates/component-macro/tests/expanded/rename_concurrent.rs b/crates/component-macro/tests/expanded/rename_concurrent.rs
index 95179956e0..03a7c7c9c9 100644
--- a/crates/component-macro/tests/expanded/rename_concurrent.rs
+++ b/crates/component-macro/tests/expanded/rename_concurrent.rs
@@ -229,7 +229,7 @@ pub mod foo {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn foo(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Thing> + Send;
}
pub trait Host: Send {}
@@ -243,11 +243,17 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"foo",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::foo(host).await;
Ok((r,))
})
diff --git a/crates/component-macro/tests/expanded/resources-import_concurrent.rs b/crates/component-macro/tests/expanded/resources-import_concurrent.rs
index 96b97e5911..de3b9e4e1d 100644
--- a/crates/component-macro/tests/expanded/resources-import_concurrent.rs
+++ b/crates/component-macro/tests/expanded/resources-import_concurrent.rs
@@ -7,16 +7,16 @@ pub trait HostWorldResourceWithStore<T>: wasmtime::component::HasData + Send {
where
Self: Sized;
fn new(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::Resource<WorldResource>,
> + Send;
fn foo(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
self_: wasmtime::component::Resource<WorldResource>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn static_foo(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
}
pub trait HostWorldResource: Send {}
@@ -131,7 +131,7 @@ pub trait TheWorldImportsWithStore<
T,
>: wasmtime::component::HasData + HostWorldResourceWithStore<T> + Send {
fn some_world_func(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::Resource<WorldResource>,
> + Send;
@@ -273,11 +273,17 @@ const _: () = {
},
)?;
linker
- .func_wrap_concurrent(
+ .func_wrap_async(
"some-world-func",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as TheWorldImportsWithStore<
T,
>>::some_world_func(host)
@@ -287,11 +293,17 @@ const _: () = {
},
)?;
linker
- .func_wrap_concurrent(
+ .func_wrap_async(
"[constructor]world-resource",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWorldResourceWithStore<T>>::new(host)
.await;
Ok((r,))
@@ -299,14 +311,20 @@ const _: () = {
},
)?;
linker
- .func_wrap_concurrent(
+ .func_wrap_async(
"[method]world-resource.foo",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::Resource<WorldResource>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWorldResourceWithStore<T>>::foo(host, arg0)
.await;
Ok(r)
@@ -314,11 +332,17 @@ const _: () = {
},
)?;
linker
- .func_wrap_concurrent(
+ .func_wrap_async(
"[static]world-resource.static-foo",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWorldResourceWithStore<
T,
>>::static_foo(host)
@@ -409,15 +433,15 @@ pub mod foo {
where
Self: Sized;
fn new(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::Resource<Bar>,
> + Send;
fn static_a(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = u32> + Send;
fn method_a(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
self_: wasmtime::component::Resource<Bar>,
) -> impl ::core::future::Future<Output = u32> + Send;
}
@@ -487,7 +511,7 @@ pub mod foo {
where
Self: Sized;
fn new(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = Result<
wasmtime::component::Resource<Fallible>,
@@ -503,89 +527,89 @@ pub mod foo {
T,
> + HostFallibleWithStore<T> + Send {
fn bar_own_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::Resource<Bar>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn bar_borrow_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::Resource<Bar>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn bar_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::Resource<Bar>,
> + Send;
fn tuple_own_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: (wasmtime::component::Resource<Bar>, u32),
) -> impl ::core::future::Future<Output = ()> + Send;
fn tuple_borrow_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: (wasmtime::component::Resource<Bar>, u32),
) -> impl ::core::future::Future<Output = ()> + Send;
fn tuple_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = (wasmtime::component::Resource<Bar>, u32),
> + Send;
fn option_own_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Option<wasmtime::component::Resource<Bar>>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn option_borrow_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Option<wasmtime::component::Resource<Bar>>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn option_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = Option<wasmtime::component::Resource<Bar>>,
> + Send;
fn result_own_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Result<wasmtime::component::Resource<Bar>, ()>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn result_borrow_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: Result<wasmtime::component::Resource<Bar>, ()>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn result_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = Result<wasmtime::component::Resource<Bar>, ()>,
> + Send;
fn list_own_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<
wasmtime::component::Resource<Bar>,
>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn list_borrow_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::Vec<
wasmtime::component::Resource<Bar>,
>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn list_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<
wasmtime::component::Resource<Bar>,
>,
> + Send;
fn record_own_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: NestedOwn,
) -> impl ::core::future::Future<Output = ()> + Send;
fn record_borrow_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: NestedBorrow,
) -> impl ::core::future::Future<Output = ()> + Send;
fn record_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = NestedOwn> + Send;
fn func_with_handle_typedef(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: SomeHandle,
) -> impl ::core::future::Future<Output = ()> + Send;
}
@@ -636,138 +660,204 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"[constructor]bar",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostBarWithStore<T>>::new(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"[static]bar.static-a",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostBarWithStore<T>>::static_a(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"[method]bar.method-a",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::Resource<Bar>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostBarWithStore<T>>::method_a(host, arg0)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"bar-own-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::Resource<Bar>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::bar_own_arg(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"bar-borrow-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::Resource<Bar>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::bar_borrow_arg(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"bar-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::bar_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"tuple-own-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): ((wasmtime::component::Resource<Bar>, u32),)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::tuple_own_arg(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"tuple-borrow-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): ((wasmtime::component::Resource<Bar>, u32),)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::tuple_borrow_arg(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"tuple-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::tuple_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"option-own-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (Option<wasmtime::component::Resource<Bar>>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::option_own_arg(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"option-borrow-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (Option<wasmtime::component::Resource<Bar>>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::option_borrow_arg(host, arg0)
@@ -776,38 +866,56 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"option-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::option_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"result-own-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (Result<wasmtime::component::Resource<Bar>, ()>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::result_own_arg(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"result-borrow-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (Result<wasmtime::component::Resource<Bar>, ()>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::result_borrow_arg(host, arg0)
@@ -816,20 +924,26 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"result-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::result_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-own-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
): (
@@ -838,18 +952,24 @@ pub mod foo {
>,
)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_own_arg(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-borrow-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
): (
@@ -858,46 +978,70 @@ pub mod foo {
>,
)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_borrow_arg(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"list-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::list_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"record-own-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (NestedOwn,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::record_own_arg(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"record-borrow-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (NestedBorrow,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::record_borrow_arg(host, arg0)
@@ -906,24 +1050,36 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"record-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::record_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"func-with-handle-typedef",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (SomeHandle,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::func_with_handle_typedef(host, arg0)
@@ -932,11 +1088,17 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"[constructor]fallible",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostFallibleWithStore<T>>::new(host).await;
Ok((r,))
})
@@ -1102,7 +1264,7 @@ pub mod foo {
pub type A = super::super::super::foo::foo::long_use_chain3::A;
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn foo(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::Resource<A>,
> + Send;
@@ -1118,11 +1280,17 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"foo",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::foo(host).await;
Ok((r,))
})
diff --git a/crates/component-macro/tests/expanded/share-types_concurrent.rs b/crates/component-macro/tests/expanded/share-types_concurrent.rs
index 37159be077..052e32790f 100644
--- a/crates/component-macro/tests/expanded/share-types_concurrent.rs
+++ b/crates/component-macro/tests/expanded/share-types_concurrent.rs
@@ -278,7 +278,7 @@ pub mod http_fetch {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn fetch_request(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
request: Request,
) -> impl ::core::future::Future<Output = Response> + Send;
}
@@ -293,11 +293,12 @@ pub mod http_fetch {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"fetch-request",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (Request,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (Request,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(&mut caller);
+ let host = wasmtime::component::Access::new(access_cx, host_getter);
let r = <D as HostWithStore<T>>::fetch_request(host, arg0).await;
Ok((r,))
})
diff --git a/crates/component-macro/tests/expanded/simple-functions_concurrent.rs b/crates/component-macro/tests/expanded/simple-functions_concurrent.rs
index 11ee82a6c3..8136b47c5b 100644
--- a/crates/component-macro/tests/expanded/simple-functions_concurrent.rs
+++ b/crates/component-macro/tests/expanded/simple-functions_concurrent.rs
@@ -193,25 +193,25 @@ pub mod foo {
use wasmtime::component::__internal::Box;
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn f1(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn f2(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
a: u32,
) -> impl ::core::future::Future<Output = ()> + Send;
fn f3(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
a: u32,
b: u32,
) -> impl ::core::future::Future<Output = ()> + Send;
fn f4(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = u32> + Send;
fn f5(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = (u32, u32)> + Send;
fn f6(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
a: u32,
b: u32,
c: u32,
@@ -228,67 +228,103 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"f1",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::f1(host).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"f2",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (u32,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (u32,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::f2(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"f3",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0, arg1): (u32, u32)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::f3(host, arg0, arg1).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"f4",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::f4(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"f5",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::f5(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"f6",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0, arg1, arg2): (u32, u32, u32)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::f6(host, arg0, arg1, arg2)
.await;
Ok((r,))
diff --git a/crates/component-macro/tests/expanded/simple-lists_concurrent.rs b/crates/component-macro/tests/expanded/simple-lists_concurrent.rs
index ab9cdbb201..e18cadf2ac 100644
--- a/crates/component-macro/tests/expanded/simple-lists_concurrent.rs
+++ b/crates/component-macro/tests/expanded/simple-lists_concurrent.rs
@@ -193,16 +193,16 @@ pub mod foo {
use wasmtime::component::__internal::Box;
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn simple_list1(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
l: wasmtime::component::__internal::Vec<u32>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn simple_list2(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::Vec<u32>,
> + Send;
fn simple_list3(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
a: wasmtime::component::__internal::Vec<u32>,
b: wasmtime::component::__internal::Vec<u32>,
) -> impl ::core::future::Future<
@@ -212,7 +212,7 @@ pub mod foo {
),
> + Send;
fn simple_list4(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
l: wasmtime::component::__internal::Vec<
wasmtime::component::__internal::Vec<u32>,
>,
@@ -233,34 +233,46 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"simple-list1",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::Vec<u32>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::simple_list1(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"simple-list2",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::simple_list2(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"simple-list3",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
arg1,
@@ -269,8 +281,14 @@ pub mod foo {
wasmtime::component::__internal::Vec<u32>,
)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::simple_list3(host, arg0, arg1)
@@ -279,10 +297,10 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"simple-list4",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
): (
@@ -291,8 +309,14 @@ pub mod foo {
>,
)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::simple_list4(host, arg0)
.await;
Ok((r,))
diff --git a/crates/component-macro/tests/expanded/simple-wasi_concurrent.rs b/crates/component-macro/tests/expanded/simple-wasi_concurrent.rs
index 18698b0856..106795257e 100644
--- a/crates/component-macro/tests/expanded/simple-wasi_concurrent.rs
+++ b/crates/component-macro/tests/expanded/simple-wasi_concurrent.rs
@@ -247,10 +247,10 @@ pub mod foo {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn create_directory_at(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Result<(), Errno>> + Send;
fn stat(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = Result<DescriptorStat, Errno>,
> + Send;
@@ -266,22 +266,34 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"create-directory-at",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::create_directory_at(host)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"stat",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::stat(host).await;
Ok((r,))
})
diff --git a/crates/component-macro/tests/expanded/small-anonymous_concurrent.rs b/crates/component-macro/tests/expanded/small-anonymous_concurrent.rs
index 6dff16485f..de1a7b0d6e 100644
--- a/crates/component-macro/tests/expanded/small-anonymous_concurrent.rs
+++ b/crates/component-macro/tests/expanded/small-anonymous_concurrent.rs
@@ -236,7 +236,7 @@ pub mod foo {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn option_test(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = Result<
Option<wasmtime::component::__internal::String>,
@@ -255,11 +255,17 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"option-test",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::option_test(host).await;
Ok((r,))
})
diff --git a/crates/component-macro/tests/expanded/smoke_concurrent.rs b/crates/component-macro/tests/expanded/smoke_concurrent.rs
index 839c96a014..a328e6e69b 100644
--- a/crates/component-macro/tests/expanded/smoke_concurrent.rs
+++ b/crates/component-macro/tests/expanded/smoke_concurrent.rs
@@ -180,7 +180,7 @@ pub mod imports {
use wasmtime::component::__internal::Box;
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn y(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
}
pub trait Host: Send {}
@@ -194,11 +194,12 @@ pub mod imports {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"y",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(&mut caller);
+ let host = wasmtime::component::Access::new(access_cx, host_getter);
let r = <D as HostWithStore<T>>::y(host).await;
Ok(r)
})
diff --git a/crates/component-macro/tests/expanded/strings_concurrent.rs b/crates/component-macro/tests/expanded/strings_concurrent.rs
index 601ba45079..8bd33f0d90 100644
--- a/crates/component-macro/tests/expanded/strings_concurrent.rs
+++ b/crates/component-macro/tests/expanded/strings_concurrent.rs
@@ -193,16 +193,16 @@ pub mod foo {
use wasmtime::component::__internal::Box;
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn a(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: wasmtime::component::__internal::String,
) -> impl ::core::future::Future<Output = ()> + Send;
fn b(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = wasmtime::component::__internal::String,
> + Send;
fn c(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
a: wasmtime::component::__internal::String,
b: wasmtime::component::__internal::String,
) -> impl ::core::future::Future<
@@ -220,33 +220,45 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::__internal::String,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::a(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"b",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::b(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"c",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
arg1,
@@ -255,8 +267,14 @@ pub mod foo {
wasmtime::component::__internal::String,
)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::c(host, arg0, arg1).await;
Ok((r,))
})
diff --git a/crates/component-macro/tests/expanded/unstable-features_concurrent.rs b/crates/component-macro/tests/expanded/unstable-features_concurrent.rs
index 1d1c14a282..5d46276a75 100644
--- a/crates/component-macro/tests/expanded/unstable-features_concurrent.rs
+++ b/crates/component-macro/tests/expanded/unstable-features_concurrent.rs
@@ -87,7 +87,7 @@ pub trait HostBazWithStore<T>: wasmtime::component::HasData + Send {
where
Self: Sized;
fn foo(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
self_: wasmtime::component::Resource<Baz>,
) -> impl ::core::future::Future<Output = ()> + Send;
}
@@ -197,7 +197,7 @@ pub trait TheWorldImportsWithStore<
T,
>: wasmtime::component::HasData + HostBazWithStore<T> + Send {
fn foo(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
}
pub trait TheWorldImports: HostBaz + Send {}
@@ -299,11 +299,17 @@ const _: () = {
}
if options.experimental_world_function_import {
linker
- .func_wrap_concurrent(
+ .func_wrap_async(
"foo",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as TheWorldImportsWithStore<T>>::foo(host).await;
Ok(r)
})
@@ -312,14 +318,20 @@ const _: () = {
}
if options.experimental_world_resource_method {
linker
- .func_wrap_concurrent(
+ .func_wrap_async(
"[method]baz.foo",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::Resource<Baz>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostBazWithStore<T>>::foo(host, arg0).await;
Ok(r)
})
@@ -407,7 +419,7 @@ pub mod foo {
where
Self: Sized;
fn foo(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
self_: wasmtime::component::Resource<Bar>,
) -> impl ::core::future::Future<Output = ()> + Send;
}
@@ -417,7 +429,7 @@ pub mod foo {
T,
>: wasmtime::component::HasData + HostBarWithStore<T> + Send {
fn foo(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = ()> + Send;
}
pub trait Host: HostBar + Send {}
@@ -454,11 +466,17 @@ pub mod foo {
)?;
}
if options.experimental_interface_function {
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"foo",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::foo(host).await;
Ok(r)
})
@@ -466,14 +484,20 @@ pub mod foo {
)?;
}
if options.experimental_interface_resource_method {
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"[method]bar.foo",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (wasmtime::component::Resource<Bar>,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostBarWithStore<T>>::foo(host, arg0).await;
Ok(r)
})
diff --git a/crates/component-macro/tests/expanded/unversioned-foo_concurrent.rs b/crates/component-macro/tests/expanded/unversioned-foo_concurrent.rs
index 69d7a77674..399fa621f9 100644
--- a/crates/component-macro/tests/expanded/unversioned-foo_concurrent.rs
+++ b/crates/component-macro/tests/expanded/unversioned-foo_concurrent.rs
@@ -210,7 +210,7 @@ pub mod foo {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn g(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Result<(), Error>> + Send;
}
pub trait Host: Send {}
@@ -224,11 +224,17 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"g",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::g(host).await;
Ok((r,))
})
diff --git a/crates/component-macro/tests/expanded/use-paths_concurrent.rs b/crates/component-macro/tests/expanded/use-paths_concurrent.rs
index 24c05f7be6..69658c65b2 100644
--- a/crates/component-macro/tests/expanded/use-paths_concurrent.rs
+++ b/crates/component-macro/tests/expanded/use-paths_concurrent.rs
@@ -204,7 +204,7 @@ pub mod foo {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn a(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Foo> + Send;
}
pub trait Host: Send {}
@@ -218,11 +218,17 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::a(host).await;
Ok((r,))
})
@@ -254,7 +260,7 @@ pub mod foo {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn a(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Foo> + Send;
}
pub trait Host: Send {}
@@ -268,11 +274,17 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::a(host).await;
Ok((r,))
})
@@ -304,7 +316,7 @@ pub mod foo {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn a(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Foo> + Send;
}
pub trait Host: Send {}
@@ -318,11 +330,17 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"a",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::a(host).await;
Ok((r,))
})
@@ -356,7 +374,7 @@ pub mod d {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn b(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Foo> + Send;
}
pub trait Host: Send {}
@@ -370,11 +388,12 @@ pub mod d {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"b",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(&mut caller);
+ let host = wasmtime::component::Access::new(access_cx, host_getter);
let r = <D as HostWithStore<T>>::b(host).await;
Ok((r,))
})
diff --git a/crates/component-macro/tests/expanded/variants_concurrent.rs b/crates/component-macro/tests/expanded/variants_concurrent.rs
index 30778e5896..1c95e70901 100644
--- a/crates/component-macro/tests/expanded/variants_concurrent.rs
+++ b/crates/component-macro/tests/expanded/variants_concurrent.rs
@@ -465,28 +465,28 @@ pub mod foo {
};
pub trait HostWithStore<T>: wasmtime::component::HasData + Send {
fn e1_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: E1,
) -> impl ::core::future::Future<Output = ()> + Send;
fn e1_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = E1> + Send;
fn v1_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: V1,
) -> impl ::core::future::Future<Output = ()> + Send;
fn v1_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = V1> + Send;
fn bool_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
x: bool,
) -> impl ::core::future::Future<Output = ()> + Send;
fn bool_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = bool> + Send;
fn option_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
a: Option<bool>,
b: Option<()>,
c: Option<u32>,
@@ -495,7 +495,7 @@ pub mod foo {
g: Option<Option<bool>>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn option_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = (
Option<bool>,
@@ -507,7 +507,7 @@ pub mod foo {
),
> + Send;
fn casts(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
a: Casts1,
b: Casts2,
c: Casts3,
@@ -518,7 +518,7 @@ pub mod foo {
Output = (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6),
> + Send;
fn result_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
a: Result<(), ()>,
b: Result<(), E1>,
c: Result<E1, ()>,
@@ -530,7 +530,7 @@ pub mod foo {
>,
) -> impl ::core::future::Future<Output = ()> + Send;
fn result_result(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = (
Result<(), ()>,
@@ -545,36 +545,36 @@ pub mod foo {
),
> + Send;
fn return_result_sugar(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Result<i32, MyErrno>> + Send;
fn return_result_sugar2(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Result<(), MyErrno>> + Send;
fn return_result_sugar3(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = Result<MyErrno, MyErrno>,
> + Send;
fn return_result_sugar4(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<
Output = Result<(i32, u32), MyErrno>,
> + Send;
fn return_option_sugar(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Option<i32>> + Send;
fn return_option_sugar2(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Option<MyErrno>> + Send;
fn result_simple(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = Result<u32, i32>> + Send;
fn is_clone_arg(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
a: IsClone,
) -> impl ::core::future::Future<Output = ()> + Send;
fn is_clone_return(
- accessor: &wasmtime::component::Accessor<T, Self>,
+ host: wasmtime::component::Access<T, Self>,
) -> impl ::core::future::Future<Output = IsClone> + Send;
}
pub trait Host: Send {}
@@ -588,70 +588,109 @@ pub mod foo {
for<'a> D::Data<'a>: Host,
T: 'static + Send,
{
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"e1-arg",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (E1,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (E1,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::e1_arg(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"e1-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::e1_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"v1-arg",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (V1,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (arg0,): (V1,)| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::v1_arg(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"v1-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::v1_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"bool-arg",
- move |caller: &wasmtime::component::Accessor<T>, (arg0,): (bool,)| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |
+ mut caller: wasmtime::StoreContextMut<'_, T>,
+ (arg0,): (bool,)|
+ {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::bool_arg(host, arg0).await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"bool-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::bool_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"option-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
arg1,
@@ -668,8 +707,14 @@ pub mod foo {
Option<Option<bool>>,
)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::option_arg(host, arg0, arg1, arg2, arg3, arg4, arg5)
@@ -678,20 +723,26 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"option-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::option_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"casts",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
arg1,
@@ -701,8 +752,14 @@ pub mod foo {
arg5,
): (Casts1, Casts2, Casts3, Casts4, Casts5, Casts6)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::casts(host, arg0, arg1, arg2, arg3, arg4, arg5)
@@ -711,10 +768,10 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"result-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(
arg0,
arg1,
@@ -734,8 +791,14 @@ pub mod foo {
>,
)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<
T,
>>::result_arg(host, arg0, arg1, arg2, arg3, arg4, arg5)
@@ -744,111 +807,171 @@ pub mod foo {
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"result-result",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::result_result(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"return-result-sugar",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::return_result_sugar(host)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"return-result-sugar2",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::return_result_sugar2(host)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"return-result-sugar3",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::return_result_sugar3(host)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"return-result-sugar4",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::return_result_sugar4(host)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"return-option-sugar",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::return_option_sugar(host)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"return-option-sugar2",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::return_option_sugar2(host)
.await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"result-simple",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::result_simple(host).await;
Ok((r,))
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"is-clone-arg",
move |
- caller: &wasmtime::component::Accessor<T>,
+ mut caller: wasmtime::StoreContextMut<'_, T>,
(arg0,): (IsClone,)|
{
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::is_clone_arg(host, arg0)
.await;
Ok(r)
})
},
)?;
- inst.func_wrap_concurrent(
+ inst.func_wrap_async(
"is-clone-return",
- move |caller: &wasmtime::component::Accessor<T>, (): ()| {
- wasmtime::component::__internal::Box::pin(async move {
- let host = &caller.with_getter(host_getter);
+ move |mut caller: wasmtime::StoreContextMut<'_, T>, (): ()| {
+ wasmtime::component::__internal::Box::new(async move {
+ let access_cx = wasmtime::AsContextMut::as_context_mut(
+ &mut caller,
+ );
+ let host = wasmtime::component::Access::new(
+ access_cx,
+ host_getter,
+ );
let r = <D as HostWithStore<T>>::is_clone_return(host).await;
Ok((r,))
})
diff --git a/crates/misc/component-async-tests/src/round_trip.rs b/crates/misc/component-async-tests/src/round_trip.rs
index 432c28cf29..617f52a555 100644
--- a/crates/misc/component-async-tests/src/round_trip.rs
+++ b/crates/misc/component-async-tests/src/round_trip.rs
@@ -14,7 +14,7 @@ pub mod non_concurrent_export_bindings {
wasmtime::component::bindgen!({
path: "wit",
world: "round-trip",
- exports: { default: ignore_wit | async },
+ exports: { default: async },
});
}
diff --git a/crates/misc/component-async-tests/src/round_trip_many.rs b/crates/misc/component-async-tests/src/round_trip_many.rs
index 5f12ba21d5..d176b9e048 100644
--- a/crates/misc/component-async-tests/src/round_trip_many.rs
+++ b/crates/misc/component-async-tests/src/round_trip_many.rs
@@ -16,7 +16,7 @@ pub mod non_concurrent_export_bindings {
path: "wit",
world: "round-trip-many",
additional_derives: [ Eq, PartialEq ],
- exports: { default: ignore_wit | async },
+ exports: { default: async },
});
}
diff --git a/crates/misc/component-async-tests/tests/scenario/round_trip.rs b/crates/misc/component-async-tests/tests/scenario/round_trip.rs
index 2b6e6e2048..a6ecec7d29 100644
--- a/crates/misc/component-async-tests/tests/scenario/round_trip.rs
+++ b/crates/misc/component-async-tests/tests/scenario/round_trip.rs
@@ -476,13 +476,18 @@ pub async fn test_round_trip(
)?;
for (input, expected) in inputs_and_outputs {
- assert_eq!(
- *expected,
- &round_trip
- .local_local_baz()
- .call_foo(&mut store, input)
- .await?
- );
+ store
+ .run_concurrent(async |store| -> wasmtime::Result<_> {
+ assert_eq!(
+ *expected,
+ &round_trip
+ .local_local_baz()
+ .call_foo(store, input.to_string())
+ .await?
+ );
+ Ok(())
+ })
+ .await??;
}
store.assert_concurrent_state_empty();
diff --git a/crates/misc/component-async-tests/tests/scenario/round_trip_many.rs b/crates/misc/component-async-tests/tests/scenario/round_trip_many.rs
index 6ebd7bc8fe..d6eaa04fa1 100644
--- a/crates/misc/component-async-tests/tests/scenario/round_trip_many.rs
+++ b/crates/misc/component-async-tests/tests/scenario/round_trip_many.rs
@@ -306,21 +306,35 @@ async fn test_round_trip_many(
.await?;
for (input, expected) in inputs_and_outputs {
- assert_eq!(
- (
- (*expected).to_owned(),
- b,
- c.clone(),
- d,
- e.clone(),
- f.clone(),
- g.clone()
- ),
- round_trip_many
- .local_local_many()
- .call_foo(&mut store, input, b, &c, d, &e, f.as_ref(), Err(()))
- .await?
- );
+ store
+ .run_concurrent(async |store| -> wasmtime::Result<_> {
+ assert_eq!(
+ (
+ (*expected).to_owned(),
+ b,
+ c.clone(),
+ d,
+ e.clone(),
+ f.clone(),
+ g.clone()
+ ),
+ round_trip_many
+ .local_local_many()
+ .call_foo(
+ store,
+ input.to_string(),
+ b,
+ c.clone(),
+ d,
+ e.clone(),
+ f.clone(),
+ Err(())
+ )
+ .await?
+ );
+ Ok(())
+ })
+ .await??;
}
store.assert_concurrent_state_empty();
diff --git a/crates/test-programs/src/bin/p3_cli_deny_listen.rs b/crates/test-programs/src/bin/p3_cli_deny_listen.rs
new file mode 100644
index 0000000000..40dd957032
--- /dev/null
+++ b/crates/test-programs/src/bin/p3_cli_deny_listen.rs
@@ -0,0 +1,66 @@
+use test_programs::p3::wasi as wasip3;
+
+struct Component;
+
+test_programs::p3::export!(Component);
+
+fn test_wasip3() {
+ use wasip3::sockets::types::{
+ ErrorCode, IpAddressFamily, IpSocketAddress, Ipv4SocketAddress, TcpSocket,
+ };
+
+ // explicit bind disallowed
+ let a = TcpSocket::create(IpAddressFamily::Ipv4).unwrap();
+ let err = a
+ .bind(IpSocketAddress::Ipv4(Ipv4SocketAddress {
+ port: 0,
+ address: (127, 0, 0, 1),
+ }))
+ .unwrap_err();
+ assert!(matches!(err, ErrorCode::AccessDenied), "bad error {err:?}");
+
+ // implicit bind disallowed
+ let a = TcpSocket::create(IpAddressFamily::Ipv4).unwrap();
+ let err = a.listen().unwrap_err();
+ assert!(matches!(err, ErrorCode::AccessDenied), "bad error {err:?}");
+}
+
+fn test_wasip2() {
+ use test_programs::wasi::sockets::network::{
+ ErrorCode, IpAddressFamily, IpSocketAddress, Ipv4SocketAddress, Network,
+ };
+ use test_programs::wasi::sockets::tcp::TcpSocket;
+
+ // explicit bind disallowed
+ let sock = TcpSocket::new(IpAddressFamily::Ipv4).unwrap();
+ let net = Network::default();
+ let err = sock
+ .blocking_bind(
+ &net,
+ IpSocketAddress::Ipv4(Ipv4SocketAddress {
+ port: 0,
+ address: (127, 0, 0, 1),
+ }),
+ )
+ .unwrap_err();
+ assert!(matches!(err, ErrorCode::AccessDenied), "bad error {err:?}");
+
+ // implicit bind disallowed via the p2 state machine
+ let sock = TcpSocket::new(IpAddressFamily::Ipv4).unwrap();
+ assert!(matches!(
+ sock.blocking_listen(),
+ Err(ErrorCode::InvalidState)
+ ));
+}
+
+impl test_programs::p3::exports::wasi::cli::run::Guest for Component {
+ async fn run() -> Result<(), ()> {
+ test_wasip2();
+ test_wasip3();
+ Ok(())
+ }
+}
+
+fn main() {
+ unreachable!();
+}
diff --git a/crates/wasi/src/p2/host/tcp.rs b/crates/wasi/src/p2/host/tcp.rs
index 47d638dd4b..f4d02979ec 100644
--- a/crates/wasi/src/p2/host/tcp.rs
+++ b/crates/wasi/src/p2/host/tcp.rs
@@ -83,13 +83,13 @@ impl crate::p2::host::tcp::tcp::HostTcpSocket for WasiSocketsCtxView<'_> {
fn start_listen(&mut self, this: Resource<TcpSocket>) -> SocketResult<()> {
let socket = self.table.get_mut(&this)?;
- socket.start_listen_p2()?;
+ socket.start_listen()?;
Ok(())
}
fn finish_listen(&mut self, this: Resource<TcpSocket>) -> SocketResult<()> {
let socket = self.table.get_mut(&this)?;
- socket.finish_listen_p2()?;
+ socket.finish_listen()?;
Ok(())
}
diff --git a/crates/wasi/src/p3/bindings.rs b/crates/wasi/src/p3/bindings.rs
index ab774e909f..f1018bd45b 100644
--- a/crates/wasi/src/p3/bindings.rs
+++ b/crates/wasi/src/p3/bindings.rs
@@ -86,7 +86,7 @@ mod generated {
"wasi:filesystem/types.[method]descriptor.append-via-stream": store | tracing | trappable,
"wasi:filesystem/types.[method]descriptor.read-directory": store | tracing | trappable,
"wasi:sockets/types.[method]tcp-socket.bind": async | tracing | trappable,
- "wasi:sockets/types.[method]tcp-socket.listen": store | tracing | trappable,
+ "wasi:sockets/types.[method]tcp-socket.listen": async | store | tracing | trappable,
"wasi:sockets/types.[method]tcp-socket.send": store | tracing | trappable,
"wasi:sockets/types.[method]tcp-socket.receive": store | tracing | trappable,
"wasi:sockets/types.[method]udp-socket.bind": async | tracing | trappable,
diff --git a/crates/wasi/src/p3/sockets/host/types/tcp.rs b/crates/wasi/src/p3/sockets/host/types/tcp.rs
index 356d709cd6..b3b0e9658c 100644
--- a/crates/wasi/src/p3/sockets/host/types/tcp.rs
+++ b/crates/wasi/src/p3/sockets/host/types/tcp.rs
@@ -241,7 +241,7 @@ impl<D> StreamConsumer<D> for SendStreamConsumer {
}
}
-impl<T> HostTcpSocketWithStore<T> for WasiSockets {
+impl<T: Send> HostTcpSocketWithStore<T> for WasiSockets {
async fn connect(
store: &Accessor<T, Self>,
socket: Resource<TcpSocket>,
@@ -267,13 +267,58 @@ impl<T> HostTcpSocketWithStore<T> for WasiSockets {
})
}
- fn listen(
+ async fn listen(
mut store: Access<'_, T, Self>,
- socket: Resource<TcpSocket>,
+ socket_resource: Resource<TcpSocket>,
) -> SocketResult<StreamReader<Resource<TcpSocket>>> {
let getter = store.getter();
- let socket = get_socket_mut(store.get().table, &socket)?;
- socket.listen_p3()?;
+ let socket = get_socket_mut(store.get().table, &socket_resource)?;
+
+ // If this socket has not yet been explicitly bound then it's never hit
+ // the `socket_addr_check` callback/function. An unbound socket here
+ // implicitly performs a bind, so to ensure the address is checked this
+ // function explicitly performs a bind against the implicit bind
+ // address.
+ //
+ // In addition to this some platforms automatically perform an implicit
+ // bind as part of the `listen` syscall. However this is not ubiquitous
+ // behavior:
+ // - Linux mentions it in their docs [0] that they perform an
+ // implicit bind. This behavior has been experimentally verified.
+ // - Windows requires a `bind` before `listen`. This is both
+ // documented [1] and experimentally verified.
+ // - Other platforms (e.g. macOS, FreeBSD) do not explicitly
+ // document it either way and instead leave it up to the
+ // individual protocol to decide [2]. However, experiments
+ // show that MacOS in fact _does_ perform an implicit bind.
+ //
+ // Thus to ensure the socket address check is used and to additionally
+ // ensure consistent behavior across all platforms, we perform the
+ // implicit bind ourselves here for unbound sockets.
+ //
+ // [0]: https://man7.org/linux/man-pages/man7/ip.7.html
+ // > An ephemeral port is allocated to a socket in the following
+ // > circumstances: (...) listen(2) is called on a stream socket
+ // > that was not previously bound;
+ //
+ // [1]: https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen
+ // > WSAEINVAL: The socket has not been bound with bind.
+ //
+ // [2]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html
+ // > EDESTADDRREQ: The socket is not bound to a local address,
+ // > and the protocol does not support listening on an unbound
+ // > socket.
+ if !socket.is_bound() {
+ let implicit_addr = crate::sockets::util::implicit_bind_addr(socket.address_family());
+ store
+ .get()
+ .bind_addr(&socket_resource, implicit_addr)
+ .await?;
+ }
+
+ let socket = get_socket_mut(store.get().table, &socket_resource)?;
+ socket.start_listen()?;
+ socket.finish_listen()?;
let listener = socket.tcp_listener_arc().unwrap().clone();
let family = socket.address_family();
let options = socket.non_inherited_options().clone();
@@ -342,21 +387,31 @@ impl<T> HostTcpSocketWithStore<T> for WasiSockets {
}
}
-impl HostTcpSocket for WasiSocketsCtxView<'_> {
- async fn bind(
+impl WasiSocketsCtxView<'_> {
+ async fn bind_addr(
&mut self,
- socket: Resource<TcpSocket>,
- local_address: IpSocketAddress,
+ socket: &Resource<TcpSocket>,
+ local_address: SocketAddr,
) -> SocketResult<()> {
- let local_address = SocketAddr::from(local_address);
if !(self.ctx.socket_addr_check)(local_address, SocketAddrUse::TcpBind).await {
return Err(ErrorCode::AccessDenied.into());
}
- let socket = get_socket_mut(self.table, &socket)?;
+ let socket = get_socket_mut(self.table, socket)?;
socket.start_bind(local_address)?;
socket.finish_bind()?;
Ok(())
}
+}
+
+impl HostTcpSocket for WasiSocketsCtxView<'_> {
+ async fn bind(
+ &mut self,
+ socket: Resource<TcpSocket>,
+ local_address: IpSocketAddress,
+ ) -> SocketResult<()> {
+ let local_address = SocketAddr::from(local_address);
+ self.bind_addr(&socket, local_address).await
+ }
fn create(&mut self, address_family: IpAddressFamily) -> SocketResult<Resource<TcpSocket>> {
let family = address_family.into();
diff --git a/crates/wasi/src/p3/sockets/host/types/udp.rs b/crates/wasi/src/p3/sockets/host/types/udp.rs
index b684777215..fbf805ead2 100644
--- a/crates/wasi/src/p3/sockets/host/types/udp.rs
+++ b/crates/wasi/src/p3/sockets/host/types/udp.rs
@@ -47,6 +47,43 @@ impl<T> HostUdpSocketWithStore<T> for WasiSockets {
}
}
+ // If this socket is not yet explicitly bound then part of this
+ // operation is performing an implicit bind. This is done for a few
+ // reasons:
+ //
+ // * The host's `socket_addr_check` callback, if any, gets an
+ // opportunity to have an opinion about the implicit use of this
+ // address.
+ // * On the first send the OS will automatically assign a free local
+ // port. However, if the `send` syscall failed, we can't reliably know
+ // which state the socket is in at the kernel level and our own
+ // state bookkeeping may have become out-of-sync.
+ //
+ // To avoid that, we perform the implicit bind ourselves here. This way,
+ // we always leave the socket in a consistent state: Bound.
+ //
+ // Note that implicit binding only happens when the socket isn't bound
+ // and the remote address is `Some`. If the remote address is `None` and
+ // we're unbound then that's an invalid state that `send_p3` below will
+ // reject.
+ let (needs_implicit_bind, family) = store.with(|mut view| -> SocketResult<_> {
+ let socket = get_socket_mut(view.get().table, &socket)?;
+ let needs_implicit_bind = !socket.is_bound() && remote_address.is_some();
+ Ok((needs_implicit_bind, socket.address_family()))
+ })?;
+ if needs_implicit_bind {
+ let implicit_addr = crate::sockets::util::implicit_bind_addr(family);
+ if !is_addr_allowed(store, implicit_addr, SocketAddrUse::UdpBind).await {
+ return Err(ErrorCode::AccessDenied.into());
+ }
+ store.with(|mut view| -> SocketResult<_> {
+ let socket = get_socket_mut(view.get().table, &socket)?;
+ socket.bind(implicit_addr)?;
+ socket.finish_bind()?;
+ Ok(())
+ })?;
+ }
+
let fut = store.with(|mut view| {
get_socket_mut(view.get().table, &socket).map(|sock| sock.send_p3(data, remote_address))
})?;
diff --git a/crates/wasi/src/sockets/tcp.rs b/crates/wasi/src/sockets/tcp.rs
index 2dc7fff55c..37f4ea7fe3 100644
--- a/crates/wasi/src/sockets/tcp.rs
+++ b/crates/wasi/src/sockets/tcp.rs
@@ -381,7 +381,7 @@ impl TcpSocket {
}
/// Start listening using p2 semantics. (no implicit bind)
- pub(crate) fn start_listen_p2(&mut self) -> Result<(), ErrorCode> {
+ pub(crate) fn start_listen(&mut self) -> Result<(), ErrorCode> {
match mem::replace(&mut self.tcp_state, TcpState::Closed) {
TcpState::Bound(tokio_socket) => {
self.tcp_state = TcpState::ListenStarted(tokio_socket);
@@ -394,7 +394,7 @@ impl TcpSocket {
}
}
- pub(crate) fn finish_listen_p2(&mut self) -> Result<(), ErrorCode> {
+ pub(crate) fn finish_listen(&mut self) -> Result<(), ErrorCode> {
let tokio_socket = match mem::replace(&mut self.tcp_state, TcpState::Closed) {
TcpState::ListenStarted(tokio_socket) => tokio_socket,
previous_state => {
@@ -406,50 +406,13 @@ impl TcpSocket {
self.listen_common(tokio_socket)
}
- /// Start listening using p3 semantics. (with implicit bind)
+ /// Returns whether this socket is in the bound state.
#[cfg(feature = "p3")]
- pub(crate) fn listen_p3(&mut self) -> Result<(), ErrorCode> {
- let tokio_socket = match mem::replace(&mut self.tcp_state, TcpState::Closed) {
- TcpState::Bound(tokio_socket) => tokio_socket,
- TcpState::Default(tokio_socket) => {
- // Some platforms automatically perform an implicit bind as part
- // of the `listen` syscall. However this is not ubiquitous
- // behavior:
- // - Linux mentions it in their docs [0] that they perform an
- // implicit bind. This behavior has been experimentally verified.
- // - Windows requires a `bind` before `listen`. This is both
- // documented [1] and experimentally verified.
- // - Other platforms (e.g. macOS, FreeBSD) do not explicitly
- // document it either way and instead leave it up to the
- // individual protocol to decide [2]. However, experiments
- // show that MacOS in fact _does_ perform an implicit bind.
- //
- // To ensure consistent behavior across all platforms, we
- // perform the implicit bind ourselves here.
- //
- // [0]: https://man7.org/linux/man-pages/man7/ip.7.html
- // > An ephemeral port is allocated to a socket in the following
- // > circumstances: (...) listen(2) is called on a stream socket
- // > that was not previously bound;
- //
- // [1]: https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen
- // > WSAEINVAL: The socket has not been bound with bind.
- //
- // [2]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html
- // > EDESTADDRREQ: The socket is not bound to a local address,
- // > and the protocol does not support listening on an unbound
- // > socket.
- let implicit_addr = crate::sockets::util::implicit_bind_addr(self.family);
- tcp_bind(&tokio_socket, implicit_addr)?;
- tokio_socket
- }
- previous_state => {
- self.tcp_state = previous_state;
- return Err(ErrorCode::InvalidState);
- }
- };
-
- self.listen_common(tokio_socket)
+ pub(crate) fn is_bound(&self) -> bool {
+ match &self.tcp_state {
+ TcpState::Bound(_) => true,
+ _ => false,
+ }
}
fn listen_common(&mut self, tokio_socket: tokio::net::TcpSocket) -> Result<(), ErrorCode> {
diff --git a/crates/wasi/src/sockets/udp.rs b/crates/wasi/src/sockets/udp.rs
index 4dc1190e07..a009f3bd22 100644
--- a/crates/wasi/src/sockets/udp.rs
+++ b/crates/wasi/src/sockets/udp.rs
@@ -177,10 +177,12 @@ impl UdpSocket {
Send(Arc<tokio::net::UdpSocket>),
SendTo(Arc<tokio::net::UdpSocket>, SocketAddr),
}
- let mut socket = match (&self.udp_state, addr) {
- (UdpState::BindStarted, _) => Err(ErrorCode::InvalidState),
- (UdpState::Default | UdpState::Bound, None) => Err(ErrorCode::InvalidArgument),
- (UdpState::Default | UdpState::Bound, Some(addr)) => {
+ let socket = match (&self.udp_state, addr) {
+ (UdpState::BindStarted, _) | (UdpState::Default, Some(_)) => {
+ Err(ErrorCode::InvalidState)
+ }
+ (UdpState::Bound | UdpState::Default, None) => Err(ErrorCode::InvalidArgument),
+ (UdpState::Bound, Some(addr)) => {
if is_valid_remote_address(addr) && is_valid_address_family(addr.ip(), self.family)
{
Ok(Mode::SendTo(Arc::clone(&self.socket), addr))
@@ -198,28 +200,6 @@ impl UdpSocket {
}
};
- // Send may be called without a prior bind or connect. In that case, the
- // first send will automatically assign a free local port. This is
- // normally performed by the OS itself. However, if the `send` syscall
- // failed, we can't reliably know which state the socket is in at the
- // kernel level and our own `udp_state` bookkeeping may have become
- // out-of-sync.
- // To avoid that, we perform the implicit bind ourselves here. This way,
- // we always leave the socket in a consistent state: Bound.
- if socket.is_ok()
- && let UdpState::Default = self.udp_state
- {
- let implicit_addr = crate::sockets::util::implicit_bind_addr(self.family);
- match udp_bind(&self.socket, implicit_addr) {
- Ok(()) => {
- self.udp_state = UdpState::Bound;
- }
- Err(e) => {
- socket = Err(e);
- }
- }
- }
-
async move {
match socket? {
Mode::Send(socket) => send(&socket, &buf).await,
diff --git a/crates/wasmtime/src/runtime/component/mod.rs b/crates/wasmtime/src/runtime/component/mod.rs
index 68bb0e6169..591ee8f0a3 100644
--- a/crates/wasmtime/src/runtime/component/mod.rs
+++ b/crates/wasmtime/src/runtime/component/mod.rs
@@ -305,9 +305,10 @@ pub(crate) use self::store::ComponentStoreData;
/// // `HostWithStore` trait. Functions without a `store` are generated
/// // in a `Host` trait.
/// //
-/// // > Note: this is not yet implemented for non-async functions. This
-/// // > will result in bindgen errors right now and is intended to be
-/// // > implemented in the near future.
+/// // If the WIT function itself is `async`, then the function will
+/// // already have this flag and will take an `&Accessor<T, Self>`. If
+/// // the WIT function is not `async`, however, then the function will
+/// // take `Access<T, Self>`.
/// "wasi:clocks/monotonic-clock.now": store,
///
/// // This is an example of combining flags where the `async` and
@@ -349,11 +350,6 @@ pub(crate) use self::store::ComponentStoreData;
/// // for example and instead return `Result<WitOk, RustErrorType>`.
/// "my:local/api.fallible": trappable,
///
-/// // The `ignore_wit` flag discards the WIT-level defaults of a
-/// // function. For example this `async` WIT function will be ignored
-/// // and a synchronous function will be generated on the host.
-/// "my:local/api.wait": ignore_wit,
-///
/// // The `exact` flag ensures that the filter, here "f", only matches
/// // functions exactly. For example "f" here would only refer to
/// // `import f: func()` in a world. Without this flag then "f"
diff --git a/crates/wit-bindgen/src/config.rs b/crates/wit-bindgen/src/config.rs
index 6497d30ad8..def8fc7e09 100644
--- a/crates/wit-bindgen/src/config.rs
+++ b/crates/wit-bindgen/src/config.rs
@@ -10,8 +10,7 @@ bitflags::bitflags! {
const STORE = 1 << 2;
const TRACING = 1 << 3;
const VERBOSE_TRACING = 1 << 4;
- const IGNORE_WIT = 1 << 5;
- const EXACT = 1 << 6;
+ const EXACT = 1 << 5;
}
}
@@ -89,9 +88,7 @@ impl FunctionConfig {
let mut ret = FunctionFlags::empty();
self.add_function_flags(resolve, ns, &func.name, &mut ret);
- if !ret.contains(FunctionFlags::IGNORE_WIT) {
- ret |= wit_flags;
- }
+ ret |= wit_flags;
ret
}
diff --git a/crates/wit-bindgen/src/lib.rs b/crates/wit-bindgen/src/lib.rs
index 6ca77d39d4..a3f409fff8 100644
--- a/crates/wit-bindgen/src/lib.rs
+++ b/crates/wit-bindgen/src/lib.rs
@@ -2687,7 +2687,7 @@ pub fn add_to_linker<T, D>(
uwrite!(
self.src,
"{linker}.{}(\"{}\", ",
- if flags.contains(FunctionFlags::ASYNC | FunctionFlags::STORE) {
+ if func.kind.is_async() {
"func_wrap_concurrent"
} else if flags.contains(FunctionFlags::ASYNC) {
"func_wrap_async"
@@ -2717,7 +2717,7 @@ pub fn add_to_linker<T, D>(
// codegen here.
let wt = self.generator.wasmtime_path();
- if flags.contains(FunctionFlags::ASYNC | FunctionFlags::STORE) {
+ if func.kind.is_async() {
uwrite!(self.src, "move |caller: &{wt}::component::Accessor::<T>, (");
} else {
uwrite!(
@@ -2769,11 +2769,7 @@ pub fn add_to_linker<T, D>(
}
if flags.contains(FunctionFlags::ASYNC) {
- let ctor = if flags.contains(FunctionFlags::STORE) {
- "pin"
- } else {
- "new"
- };
+ let ctor = if func.kind.is_async() { "pin" } else { "new" };
uwriteln!(
self.src,
"{wt}::component::__internal::Box::{ctor}(async move {{"
@@ -2805,19 +2801,17 @@ pub fn add_to_linker<T, D>(
);
}
- if flags.contains(FunctionFlags::STORE) {
- if flags.contains(FunctionFlags::ASYNC) {
- uwriteln!(self.src, "let host = &caller.with_getter(host_getter);");
- } else {
- uwriteln!(
- self.src,
- "let access_cx = {wt}::AsContextMut::as_context_mut(&mut caller);"
- );
- uwriteln!(
- self.src,
- "let host = {wt}::component::Access::new(access_cx, host_getter);"
- );
- }
+ if func.kind.is_async() {
+ uwriteln!(self.src, "let host = &caller.with_getter(host_getter);");
+ } else if flags.contains(FunctionFlags::STORE) {
+ uwriteln!(
+ self.src,
+ "let access_cx = {wt}::AsContextMut::as_context_mut(&mut caller);"
+ );
+ uwriteln!(
+ self.src,
+ "let host = {wt}::component::Access::new(access_cx, host_getter);"
+ );
} else {
self.src
.push_str("let host = &mut host_getter(caller.data_mut());\n");
@@ -2890,12 +2884,10 @@ pub fn add_to_linker<T, D>(
None => format!("Host"),
};
let convert = format!("{}::convert_{}", convert_trait, err_name.to_snake_case());
- let convert = if flags.contains(FunctionFlags::STORE) {
- if flags.contains(FunctionFlags::ASYNC) {
- format!("caller.with(|mut host| {convert}(&mut host_getter(host.get()), e))")
- } else {
- format!("{convert}(&mut host_getter(caller.data_mut()), e)")
- }
+ let convert = if func.kind.is_async() {
+ format!("caller.with(|mut host| {convert}(&mut host_getter(host.get()), e))")
+ } else if flags.contains(FunctionFlags::STORE) {
+ format!("{convert}(&mut host_getter(caller.data_mut()), e)")
} else {
format!("{convert}(host, e)")
};
@@ -2932,7 +2924,7 @@ pub fn add_to_linker<T, D>(
self.push_str("fn ");
self.push_str(&rust_function_name(func));
- if flags.contains(FunctionFlags::STORE | FunctionFlags::ASYNC) {
+ if func.kind.is_async() {
uwrite!(self.src, "(accessor: &{wt}::component::Accessor<T, Self>, ");
} else if flags.contains(FunctionFlags::STORE) {
uwrite!(self.src, "(host: {wt}::component::Access<T, Self>, ");
diff --git a/tests/all/cli_tests.rs b/tests/all/cli_tests.rs
index b9ec26420e..ea54c4b3ee 100644
--- a/tests/all/cli_tests.rs
+++ b/tests/all/cli_tests.rs
@@ -3005,6 +3005,12 @@ start a print 1234
run_wasmtime(&["run", "-Smax-resources=100", P3_CLI_MANY_STREAM_COMPONENT])?;
Ok(())
}
+
+ #[test]
+ fn p3_cli_deny_listen() -> Result<()> {
+ run_wasmtime(&["run", P3_CLI_DENY_LISTEN_COMPONENT])?;
+ Ok(())
+ }
}
#[test]