-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Up until wstd 0.5.4, there was no 'static constraint on the future passed to block_on, but the following PR changed this: #86
This makes it impossible (? as far as I understand) to use block_on together with borrowed resources using the current wit-bindgen-rust representation for them, as the generated borrow type has a non-static lifetime.
Small reproducer of what I mean:
package component:wstd-problem-reproducer;
interface api {
resource test {
hello: func() -> string;
}
use-test: func(test: borrow<test>) -> string;
}
/// An example world for the component to target.
world example {
export api;
}#[allow(warnings)]
mod bindings;
use bindings::exports::component::wstd_problem_reproducer::api::Guest;
use wstd::runtime::block_on;
use crate::bindings::exports::component::wstd_problem_reproducer::api::{GuestTest, TestBorrow};
struct Component;
impl Guest for Component {
type Test = Test;
fn use_test(test: TestBorrow<'_>) -> String {
block_on(async move { test.get::<Test>().hello() })
}
}
struct Test;
impl GuestTest for Test {
fn hello(&self) -> String {
block_on(async move { "Test passed!".to_string() })
}
}
bindings::export!(Component with_types_in bindings);The block_on in use_test does not compile with wstd > 0.5.4 because of the static constraint.
Metadata
Metadata
Assignees
Labels
No labels