|
if !self.future_payloads.is_empty() { |
|
self.src.push_str( |
|
"\ |
|
pub mod wit_future { |
|
#![allow(dead_code, unused_variables, clippy::all)] |
|
|
|
#[doc(hidden)] |
|
pub trait FuturePayload: Unpin + Sized + 'static { |
|
fn new() -> (u32, &'static ::wit_bindgen_rt::async_support::FutureVtable<Self>); |
|
}", |
|
); |
|
for code in self.future_payloads.values() { |
|
self.src.push_str(code); |
|
} |
|
self.src.push_str( |
|
"\ |
|
/// Creates a new Component Model `future` with the specified payload type. |
|
pub fn new<T: FuturePayload>() -> (::wit_bindgen_rt::async_support::FutureWriter<T>, ::wit_bindgen_rt::async_support::FutureReader<T>) { |
|
let (handle, vtable) = T::new(); |
|
::wit_bindgen_rt::async_support::with_entry(handle, |entry| match entry { |
|
::std::collections::hash_map::Entry::Vacant(entry) => { |
|
entry.insert(::wit_bindgen_rt::async_support::Handle::LocalOpen); |
|
} |
|
::std::collections::hash_map::Entry::Occupied(_) => unreachable!(), |
|
}); |
|
( |
|
::wit_bindgen_rt::async_support::FutureWriter::new(handle, vtable), |
|
::wit_bindgen_rt::async_support::FutureReader::new(handle, vtable), |
|
) |
|
} |
|
} |
|
", |
|
); |
|
} |
|
|
|
if !self.stream_payloads.is_empty() { |
|
self.src.push_str( |
|
"\ |
|
pub mod wit_stream { |
|
#![allow(dead_code, unused_variables, clippy::all)] |
|
|
|
pub trait StreamPayload: Unpin + Sized + 'static { |
|
fn new() -> (u32, &'static ::wit_bindgen_rt::async_support::StreamVtable<Self>); |
|
}", |
|
); |
|
for code in self.stream_payloads.values() { |
|
self.src.push_str(code); |
|
} |
|
self.src.push_str( |
|
"\ |
|
/// Creates a new Component Model `stream` with the specified payload type. |
|
pub fn new<T: StreamPayload>() -> (::wit_bindgen_rt::async_support::StreamWriter<T>, ::wit_bindgen_rt::async_support::StreamReader<T>) { |
|
let (handle, vtable) = T::new(); |
|
::wit_bindgen_rt::async_support::with_entry(handle, |entry| match entry { |
|
::std::collections::hash_map::Entry::Vacant(entry) => { |
|
entry.insert(::wit_bindgen_rt::async_support::Handle::LocalOpen); |
|
} |
|
::std::collections::hash_map::Entry::Occupied(_) => unreachable!(), |
|
}); |
|
( |
|
::wit_bindgen_rt::async_support::StreamWriter::new(handle, vtable), |
|
::wit_bindgen_rt::async_support::StreamReader::new(handle, vtable), |
|
) |
|
} |
|
} |
|
", |
|
); |
|
} |
|
} |
Currently
wit-bindgenexplicitly imports::wit_bindgen_rtfor async, e.g.:wit-bindgen/crates/rust/src/lib.rs
Lines 458 to 526 in 629ced7
Instead, it should import from the configured runtime module path, which is normally re-exported by wit-bindgen