diff --git a/crates/durable-core/src/bindings.rs b/crates/durable-core/src/bindings.rs index c1ba274..9cd4a12 100644 --- a/crates/durable-core/src/bindings.rs +++ b/crates/durable-core/src/bindings.rs @@ -1,8 +1,8 @@ -#[allow(dead_code)] +#[rustfmt::skip] +#[allow(dead_code, clippy::all)] pub mod durable { - #[allow(dead_code)] pub mod core { - #[allow(dead_code, clippy::all)] + #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] pub mod core { #[used] #[doc(hidden)] @@ -11,76 +11,102 @@ pub mod durable { pub type Datetime = super::super::super::wasi::clocks::wall_clock::Datetime; #[allow(unused_unsafe, clippy::all)] /// Get the task id for the current workflow. + #[allow(async_fn_in_trait)] pub fn task_id() -> i64 { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/core@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/core@2.7.0")] + unsafe extern "C" { #[link_name = "task-id"] - fn wit_import() -> i64; + fn wit_import0() -> i64; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64 { + unsafe extern "C" fn wit_import0() -> i64 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); ret } } #[allow(unused_unsafe, clippy::all)] /// Get the task name for the current workflow. + #[allow(async_fn_in_trait)] pub fn task_name() -> _rt::String { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 2 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 2 + * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/core@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/core@2.7.0")] + unsafe extern "C" { #[link_name = "task-name"] - fn wit_import(_: *mut u8); + fn wit_import1(_: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8) { + unsafe extern "C" fn wit_import1(_: *mut u8) { unreachable!() } - wit_import(ptr0); - let l1 = *ptr0.add(0).cast::<*mut u8>(); - let l2 = *ptr0.add(4).cast::(); - let len3 = l2; - let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); - _rt::string_lift(bytes3) + wit_import1(ptr0); + let l2 = *ptr0.add(0).cast::<*mut u8>(); + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + let result5 = _rt::string_lift(bytes4); + result5 } } #[allow(unused_unsafe, clippy::all)] /// Get the json-encoded task data for the current workflow. + #[allow(async_fn_in_trait)] pub fn task_data() -> _rt::String { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 2 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 2 + * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/core@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/core@2.7.0")] + unsafe extern "C" { #[link_name = "task-data"] - fn wit_import(_: *mut u8); + fn wit_import1(_: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8) { + unsafe extern "C" fn wit_import1(_: *mut u8) { unreachable!() } - wit_import(ptr0); - let l1 = *ptr0.add(0).cast::<*mut u8>(); - let l2 = *ptr0.add(4).cast::(); - let len3 = l2; - let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); - _rt::string_lift(bytes3) + wit_import1(ptr0); + let l2 = *ptr0.add(0).cast::<*mut u8>(); + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + let result5 = _rt::string_lift(bytes4); + result5 } } #[allow(unused_unsafe, clippy::all)] /// Get the timestamp that this task was created at. + #[allow(async_fn_in_trait)] pub fn task_created_at() -> Datetime { unsafe { #[repr(align(8))] @@ -88,22 +114,23 @@ pub mod durable { let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/core@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/core@2.7.0")] + unsafe extern "C" { #[link_name = "task-created-at"] - fn wit_import(_: *mut u8); + fn wit_import1(_: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8) { + unsafe extern "C" fn wit_import1(_: *mut u8) { unreachable!() } - wit_import(ptr0); - let l1 = *ptr0.add(0).cast::(); - let l2 = *ptr0.add(8).cast::(); - super::super::super::wasi::clocks::wall_clock::Datetime { - seconds: l1 as u64, - nanoseconds: l2 as u32, - } + wit_import1(ptr0); + let l2 = *ptr0.add(0).cast::(); + let l3 = *ptr0.add(8).cast::(); + let result4 = super::super::super::wasi::clocks::wall_clock::Datetime { + seconds: l2 as u64, + nanoseconds: l3 as u32, + }; + result4 } } #[allow(unused_unsafe, clippy::all)] @@ -112,30 +139,44 @@ pub mod durable { /// /// # Parameters /// - `label` - A text label that gets recorded in the event. This is used to - /// validate that events are in fact executing in the same order - /// when the workflow is restarted. + /// validate that events are in fact executing in the same order + /// when the workflow is restarted. /// - `is-db` - Whether this transaction is a database transaction and should - /// reserve a database connection so that sql can be used within. + /// reserve a database connection so that sql can be used within. + #[allow(async_fn_in_trait)] pub fn transaction_enter(label: &str, is_db: bool) -> Option<_rt::String> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], + ); let vec0 = label; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); let ptr1 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/core@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/core@2.7.0")] + unsafe extern "C" { #[link_name = "transaction-enter"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8); + fn wit_import2(_: *mut u8, _: usize, _: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8) { + unsafe extern "C" fn wit_import2( + _: *mut u8, + _: usize, + _: i32, + _: *mut u8, + ) { unreachable!() } - wit_import( + wit_import2( ptr0.cast_mut(), len0, match &is_db { @@ -144,25 +185,30 @@ pub mod durable { }, ptr1, ); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { + let l3 = i32::from(*ptr1.add(0).cast::()); + let result7 = match l3 { 0 => None, 1 => { let e = { - let l3 = *ptr1.add(4).cast::<*mut u8>(); - let l4 = *ptr1.add(8).cast::(); - let len5 = l4; - let bytes5 = _rt::Vec::from_raw_parts( - l3.cast(), - len5, - len5, + let l4 = *ptr1 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l5 = *ptr1 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts( + l4.cast(), + len6, + len6, ); - _rt::string_lift(bytes5) + _rt::string_lift(bytes6) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result7 } } #[allow(unused_unsafe, clippy::all)] @@ -170,26 +216,27 @@ pub mod durable { /// /// Parameters: /// - `data` - JSON-encoded state to save. - pub fn transaction_exit(data: &str) { + #[allow(async_fn_in_trait)] + pub fn transaction_exit(data: &str) -> () { unsafe { let vec0 = data; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/core@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/core@2.7.0")] + unsafe extern "C" { #[link_name = "transaction-exit"] - fn wit_import(_: *mut u8, _: usize); + fn wit_import1(_: *mut u8, _: usize); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) { unreachable!() } - wit_import(ptr0.cast_mut(), len0); + wit_import1(ptr0.cast_mut(), len0); } } } - #[allow(dead_code, clippy::all)] + #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] pub mod notify { #[used] #[doc(hidden)] @@ -259,54 +306,152 @@ pub mod durable { /// Attempt to read the next available notification, if there is one. /// notification: func() -> option; /// Read the next available notification, blocking until one is available. + #[allow(async_fn_in_trait)] pub fn notification_blocking() -> Event { unsafe { #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 32]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 32]); + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 16 + 4 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 16 + + 4 * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/notify@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/notify@2.7.0")] + unsafe extern "C" { #[link_name = "notification-blocking"] - fn wit_import(_: *mut u8); + fn wit_import1(_: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8) { + unsafe extern "C" fn wit_import1(_: *mut u8) { unreachable!() } - wit_import(ptr0); - let l1 = *ptr0.add(0).cast::(); - let l2 = *ptr0.add(8).cast::(); - let l3 = *ptr0.add(16).cast::<*mut u8>(); - let l4 = *ptr0.add(20).cast::(); - let len5 = l4; - let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); - let l6 = *ptr0.add(24).cast::<*mut u8>(); - let l7 = *ptr0.add(28).cast::(); - let len8 = l7; - let bytes8 = _rt::Vec::from_raw_parts(l6.cast(), len8, len8); - Event { + wit_import1(ptr0); + let l2 = *ptr0.add(0).cast::(); + let l3 = *ptr0.add(8).cast::(); + let l4 = *ptr0.add(16).cast::<*mut u8>(); + let l5 = *ptr0 + .add(16 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + let l7 = *ptr0 + .add(16 + 2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l8 = *ptr0 + .add(16 + 3 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len9 = l8; + let bytes9 = _rt::Vec::from_raw_parts(l7.cast(), len9, len9); + let result10 = Event { created_at: super::super::super::wasi::clocks::wall_clock::Datetime { - seconds: l1 as u64, - nanoseconds: l2 as u32, + seconds: l2 as u64, + nanoseconds: l3 as u32, }, - event: _rt::string_lift(bytes5), - data: _rt::string_lift(bytes8), + event: _rt::string_lift(bytes6), + data: _rt::string_lift(bytes9), + }; + result10 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Read the next available notification, blocking until one is available or + /// the timeout expires. Returns `none` if the timeout expired without + /// receiving a notification. + #[allow(async_fn_in_trait)] + pub fn notification_blocking_timeout(timeout_ns: u64) -> Option { + unsafe { + #[repr(align(8))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 24 + 4 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 24 + + 4 * ::core::mem::size_of::<*const u8>()], + ); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "durable:core/notify@2.7.0")] + unsafe extern "C" { + #[link_name = "notification-blocking-timeout"] + fn wit_import1(_: i64, _: *mut u8); + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn wit_import1(_: i64, _: *mut u8) { + unreachable!() } + wit_import1(_rt::as_i64(&timeout_ns), ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result11 = match l2 { + 0 => None, + 1 => { + let e = { + let l3 = *ptr0.add(8).cast::(); + let l4 = *ptr0.add(16).cast::(); + let l5 = *ptr0.add(24).cast::<*mut u8>(); + let l6 = *ptr0 + .add(24 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); + let l8 = *ptr0 + .add(24 + 2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l9 = *ptr0 + .add(24 + 3 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len10 = l9; + let bytes10 = _rt::Vec::from_raw_parts( + l8.cast(), + len10, + len10, + ); + Event { + created_at: super::super::super::wasi::clocks::wall_clock::Datetime { + seconds: l3 as u64, + nanoseconds: l4 as u32, + }, + event: _rt::string_lift(bytes7), + data: _rt::string_lift(bytes10), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }; + result11 } } #[allow(unused_unsafe, clippy::all)] /// Emit a notification for a task. + #[allow(async_fn_in_trait)] pub fn notify( task: i64, event: &str, data: &str, ) -> Result<(), NotifyError> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 4 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 4 + * ::core::mem::size_of::<*const u8>()], + ); let vec0 = event; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); @@ -315,10 +460,10 @@ pub mod durable { let len1 = vec1.len(); let ptr2 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/notify@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/notify@2.7.0")] + unsafe extern "C" { #[link_name = "notify"] - fn wit_import( + fn wit_import3( _: i64, _: *mut u8, _: usize, @@ -328,7 +473,7 @@ pub mod durable { ); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import( + unsafe extern "C" fn wit_import3( _: i64, _: *mut u8, _: usize, @@ -338,7 +483,7 @@ pub mod durable { ) { unreachable!() } - wit_import( + wit_import3( _rt::as_i64(&task), ptr0.cast_mut(), len0, @@ -346,50 +491,71 @@ pub mod durable { len1, ptr2, ); - let l3 = i32::from(*ptr2.add(0).cast::()); - match l3 { + let l4 = i32::from(*ptr2.add(0).cast::()); + let result10 = match l4 { 0 => { let e = (); Ok(e) } 1 => { let e = { - let l4 = i32::from(*ptr2.add(4).cast::()); - let v8 = match l4 { + let l5 = i32::from( + *ptr2.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v9 = match l5 { 0 => NotifyError::TaskNotFound, 1 => NotifyError::TaskDead, n => { debug_assert_eq!(n, 2, "invalid enum discriminant"); - let e8 = { - let l5 = *ptr2.add(8).cast::<*mut u8>(); - let l6 = *ptr2.add(12).cast::(); - let len7 = l6; - let bytes7 = _rt::Vec::from_raw_parts( - l5.cast(), - len7, - len7, + let e9 = { + let l6 = *ptr2 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l7 = *ptr2 + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, ); - _rt::string_lift(bytes7) + _rt::string_lift(bytes8) }; - NotifyError::Other(e8) + NotifyError::Other(e9) } }; - v8 + v9 }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result10 } } } } } -#[allow(dead_code)] +#[rustfmt::skip] +#[allow(dead_code, clippy::all)] pub mod wasi { - #[allow(dead_code)] pub mod clocks { - #[allow(dead_code, clippy::all)] + /// WASI Wall Clock is a clock API intended to let users query the current + /// time. The name "wall" makes an analogy to a "clock on the wall", which + /// is not necessarily monotonic as it may be reset. + /// + /// It is intended to be portable at least between Unix-family platforms and + /// Windows. + /// + /// A wall clock is a clock which measures the date and time according to + /// some external reference. + /// + /// External references may be reset, so this clock is not necessarily + /// monotonic, making it unsuitable for measuring elapsed time. + /// + /// It is intended for reporting the current date and time for humans. + #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] pub mod wall_clock { #[used] #[doc(hidden)] @@ -426,6 +592,7 @@ pub mod wasi { /// /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time + #[allow(async_fn_in_trait)] pub fn now() -> Datetime { unsafe { #[repr(align(8))] @@ -434,27 +601,29 @@ pub mod wasi { let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.0")] - extern "C" { + unsafe extern "C" { #[link_name = "now"] - fn wit_import(_: *mut u8); + fn wit_import1(_: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8) { + unsafe extern "C" fn wit_import1(_: *mut u8) { unreachable!() } - wit_import(ptr0); - let l1 = *ptr0.add(0).cast::(); - let l2 = *ptr0.add(8).cast::(); - Datetime { - seconds: l1 as u64, - nanoseconds: l2 as u32, - } + wit_import1(ptr0); + let l2 = *ptr0.add(0).cast::(); + let l3 = *ptr0.add(8).cast::(); + let result4 = Datetime { + seconds: l2 as u64, + nanoseconds: l3 as u32, + }; + result4 } } #[allow(unused_unsafe, clippy::all)] /// Query the resolution of the clock. /// /// The nanoseconds field of the output is always less than 1000000000. + #[allow(async_fn_in_trait)] pub fn resolution() -> Datetime { unsafe { #[repr(align(8))] @@ -463,41 +632,44 @@ pub mod wasi { let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.0")] - extern "C" { + unsafe extern "C" { #[link_name = "resolution"] - fn wit_import(_: *mut u8); + fn wit_import1(_: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8) { + unsafe extern "C" fn wit_import1(_: *mut u8) { unreachable!() } - wit_import(ptr0); - let l1 = *ptr0.add(0).cast::(); - let l2 = *ptr0.add(8).cast::(); - Datetime { - seconds: l1 as u64, - nanoseconds: l2 as u32, - } + wit_import1(ptr0); + let l2 = *ptr0.add(0).cast::(); + let l3 = *ptr0.add(8).cast::(); + let result4 = Datetime { + seconds: l2 as u64, + nanoseconds: l3 as u32, + }; + result4 } } } } } +#[rustfmt::skip] mod _rt { + #![allow(dead_code, clippy::all)] pub use alloc_crate::string::String; pub use alloc_crate::vec::Vec; pub unsafe fn string_lift(bytes: Vec) -> String { if cfg!(debug_assertions) { String::from_utf8(bytes).unwrap() } else { - String::from_utf8_unchecked(bytes) + unsafe { String::from_utf8_unchecked(bytes) } } } pub unsafe fn invalid_enum_discriminant() -> T { if cfg!(debug_assertions) { panic!("invalid enum discriminant") } else { - core::hint::unreachable_unchecked() + unsafe { core::hint::unreachable_unchecked() } } } pub fn as_i64(t: T) -> i64 { @@ -525,26 +697,31 @@ mod _rt { } extern crate alloc as alloc_crate; } +#[rustfmt::skip] #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:wit-bindgen:0.30.0:import-core:encoded world"] +#[unsafe( + link_section = "component-type:wit-bindgen:0.44.0:durable:core@2.7.0:import-core:encoded world" +)] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 709] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xc3\x04\x01A\x02\x01\ +#[allow(clippy::octal_escapes)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 763] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xf9\x04\x01A\x02\x01\ A\x07\x01B\x05\x01r\x02\x07secondsw\x0bnanosecondsy\x04\0\x08datetime\x03\0\0\x01\ -@\0\0\x01\x04\0\x03now\x01\x02\x04\0\x0aresolution\x01\x02\x03\x01\x1cwasi:clock\ -s/wall-clock@0.2.0\x05\0\x02\x03\0\0\x08datetime\x01B\x0e\x02\x03\x02\x01\x01\x04\ -\0\x08datetime\x03\0\0\x01@\0\0x\x04\0\x07task-id\x01\x02\x01@\0\0s\x04\0\x09tas\ -k-name\x01\x03\x04\0\x09task-data\x01\x03\x01@\0\0\x01\x04\0\x0ftask-created-at\x01\ +@\0\0\x01\x04\0\x03now\x01\x02\x04\0\x0aresolution\x01\x02\x03\0\x1cwasi:clocks/\ +wall-clock@0.2.0\x05\0\x02\x03\0\0\x08datetime\x01B\x0e\x02\x03\x02\x01\x01\x04\0\ +\x08datetime\x03\0\0\x01@\0\0x\x04\0\x07task-id\x01\x02\x01@\0\0s\x04\0\x09task-\ +name\x01\x03\x04\0\x09task-data\x01\x03\x01@\0\0\x01\x04\0\x0ftask-created-at\x01\ \x04\x01ks\x01@\x02\x05labels\x05is-db\x7f\0\x05\x04\0\x11transaction-enter\x01\x06\ -\x01@\x01\x04datas\x01\0\x04\0\x10transaction-exit\x01\x07\x03\x01\x17durable:co\ -re/core@2.5.0\x05\x02\x01B\x0b\x02\x03\x02\x01\x01\x04\0\x08datetime\x03\0\0\x01\ -r\x03\x0acreated-at\x01\x05events\x04datas\x04\0\x05event\x03\0\x02\x01q\x03\x0e\ -task-not-found\0\0\x09task-dead\0\0\x05other\x01s\0\x04\0\x0cnotify-error\x03\0\x04\ -\x01@\0\0\x03\x04\0\x15notification-blocking\x01\x06\x01j\0\x01\x05\x01@\x03\x04\ -taskx\x05events\x04datas\0\x07\x04\0\x06notify\x01\x08\x03\x01\x19durable:core/n\ -otify@2.5.0\x05\x03\x04\x01\x1edurable:core/import-core@2.5.0\x04\0\x0b\x11\x01\0\ -\x0bimport-core\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\ -\x070.215.0\x10wit-bindgen-rust\x060.30.0"; +\x01@\x01\x04datas\x01\0\x04\0\x10transaction-exit\x01\x07\x03\0\x17durable:core\ +/core@2.7.0\x05\x02\x01B\x0e\x02\x03\x02\x01\x01\x04\0\x08datetime\x03\0\0\x01r\x03\ +\x0acreated-at\x01\x05events\x04datas\x04\0\x05event\x03\0\x02\x01q\x03\x0etask-\ +not-found\0\0\x09task-dead\0\0\x05other\x01s\0\x04\0\x0cnotify-error\x03\0\x04\x01\ +@\0\0\x03\x04\0\x15notification-blocking\x01\x06\x01k\x03\x01@\x01\x0atimeout-ns\ +w\0\x07\x04\0\x1dnotification-blocking-timeout\x01\x08\x01j\0\x01\x05\x01@\x03\x04\ +taskx\x05events\x04datas\0\x09\x04\0\x06notify\x01\x0a\x03\0\x19durable:core/not\ +ify@2.7.0\x05\x03\x04\0\x1edurable:core/import-core@2.7.0\x04\0\x0b\x11\x01\0\x0b\ +import-core\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x07\ +0.236.1\x10wit-bindgen-rust\x060.44.0"; #[inline(never)] #[doc(hidden)] pub fn __link_custom_section_describing_imports() { diff --git a/crates/durable-core/src/notify.rs b/crates/durable-core/src/notify.rs index 5b31990..d4dcb06 100644 --- a/crates/durable-core/src/notify.rs +++ b/crates/durable-core/src/notify.rs @@ -53,6 +53,38 @@ pub fn wait() -> Notification { } } +/// Block this task until a new notification arrives or the timeout expires. +/// +/// Returns `Some(notification)` if a notification was received, or `None` if +/// the timeout expired without receiving a notification. +/// +/// # Traps +/// Attempting to call this function within a transaction will result in a trap +/// that instantly kills the workflow. +pub fn wait_with_timeout(timeout: Duration) -> Option { + let timeout_ns = timeout.as_nanos().min(u64::MAX as u128) as u64; + let event = crate::bindings::durable::core::notify::notification_blocking_timeout(timeout_ns); + + event.map(|event| { + let data = event.data.into_boxed_str(); + + let _: &RawValue = serde_json::from_str(&data).expect( + "durable:core/notify.notification_blocking_timeout returned an event containing \ + invalid json data", + ); + + // SAFETY: Same as in wait() - RawValue is #[repr(transparent)] around str. + let data = unsafe { std::mem::transmute::, Box>(data) }; + + Notification { + created_at: SystemTime::UNIX_EPOCH + + Duration::new(event.created_at.seconds, event.created_at.nanoseconds), + event: event.event, + data, + } + }) +} + /// Send a notification to another task. /// /// # Errors diff --git a/crates/durable-http/src/bindings.rs b/crates/durable-http/src/bindings.rs index a8bb438..6adf45b 100644 --- a/crates/durable-http/src/bindings.rs +++ b/crates/durable-http/src/bindings.rs @@ -1,8 +1,8 @@ -#[allow(dead_code)] +#[rustfmt::skip] +#[allow(dead_code, clippy::all)] pub mod durable { - #[allow(dead_code)] pub mod core { - #[allow(dead_code, clippy::all)] + #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] pub mod http { #[used] #[doc(hidden)] @@ -134,7 +134,7 @@ pub mod durable { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { Self { - handle: _rt::Resource::from_handle(handle), + handle: unsafe { _rt::Resource::from_handle(handle) }, } } #[doc(hidden)] @@ -149,16 +149,18 @@ pub mod durable { unsafe impl _rt::WasmResource for HttpError2 { #[inline] unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { - #[link_name = "[resource-drop]http-error2"] - fn drop(_: u32); - } - drop(_handle); + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { + #[link_name = "[resource-drop]http-error2"] + fn drop(_: i32); + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop(_: i32) { + unreachable!() + } + unsafe { + drop(_handle as i32); } } } @@ -174,7 +176,7 @@ pub mod durable { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { Self { - handle: _rt::Resource::from_handle(handle), + handle: unsafe { _rt::Resource::from_handle(handle) }, } } #[doc(hidden)] @@ -189,16 +191,18 @@ pub mod durable { unsafe impl _rt::WasmResource for HttpRequest2 { #[inline] unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { - #[link_name = "[resource-drop]http-request2"] - fn drop(_: u32); - } - drop(_handle); + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { + #[link_name = "[resource-drop]http-request2"] + fn drop(_: i32); + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop(_: i32) { + unreachable!() + } + unsafe { + drop(_handle as i32); } } } @@ -207,11 +211,20 @@ pub mod durable { /// /// # Parameters /// - `request` - A description of the HTTP request to make. + #[allow(async_fn_in_trait)] pub fn fetch(request: HttpRequest<'_>) -> Result { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 6 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 6 + * ::core::mem::size_of::<*const u8>()], + ); let HttpRequest { method: method0, url: url0, @@ -227,33 +240,33 @@ pub mod durable { let len2 = vec2.len(); let vec6 = headers0; let len6 = vec6.len(); - let layout6 = _rt::alloc::Layout::from_size_align_unchecked( - vec6.len() * 16, - 4, - ); - let result6 = if layout6.size() != 0 { - let ptr = _rt::alloc::alloc(layout6).cast::(); - if ptr.is_null() { - _rt::alloc::handle_alloc_error(layout6); - } - ptr - } else { - { ::core::ptr::null_mut() } - }; + let layout6 = _rt::alloc::Layout::from_size_align( + vec6.len() * (4 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + .unwrap(); + let (result6, _cleanup6) = wit_bindgen_rt::Cleanup::new(layout6); for (i, e) in vec6.into_iter().enumerate() { - let base = result6.add(i * 16); + let base = result6 + .add(i * (4 * ::core::mem::size_of::<*const u8>())); { let HttpHeaderParam { name: name3, value: value3 } = e; let vec4 = name3; let ptr4 = vec4.as_ptr().cast::(); let len4 = vec4.len(); - *base.add(4).cast::() = len4; + *base + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len4; *base.add(0).cast::<*mut u8>() = ptr4.cast_mut(); let vec5 = value3; let ptr5 = vec5.as_ptr().cast::(); let len5 = vec5.len(); - *base.add(12).cast::() = len5; - *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + *base + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::() = len5; + *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>() = ptr5.cast_mut(); } } let (result8_0, result8_1, result8_2) = match body0 { @@ -271,10 +284,10 @@ pub mod durable { }; let ptr10 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { #[link_name = "fetch"] - fn wit_import( + fn wit_import11( _: *mut u8, _: usize, _: *mut u8, @@ -290,7 +303,7 @@ pub mod durable { ); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import( + unsafe extern "C" fn wit_import11( _: *mut u8, _: usize, _: *mut u8, @@ -306,7 +319,7 @@ pub mod durable { ) { unreachable!() } - wit_import( + wit_import11( ptr1.cast_mut(), len1, ptr2.cast_mut(), @@ -320,144 +333,186 @@ pub mod durable { result9_1, ptr10, ); - let l11 = i32::from(*ptr10.add(0).cast::()); - if layout6.size() != 0 { - _rt::alloc::dealloc(result6.cast(), layout6); - } - match l11 { + let l12 = i32::from(*ptr10.add(0).cast::()); + let result34 = match l12 { 0 => { let e = { - let l12 = i32::from(*ptr10.add(4).cast::()); - let l13 = *ptr10.add(8).cast::<*mut u8>(); - let l14 = *ptr10.add(12).cast::(); - let base21 = l13; - let len21 = l14; - let mut result21 = _rt::Vec::with_capacity(len21); - for i in 0..len21 { - let base = base21.add(i * 16); - let e21 = { - let l15 = *base.add(0).cast::<*mut u8>(); - let l16 = *base.add(4).cast::(); - let len17 = l16; - let bytes17 = _rt::Vec::from_raw_parts( - l15.cast(), - len17, - len17, + let l13 = i32::from( + *ptr10 + .add(::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let l14 = *ptr10 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l15 = *ptr10 + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base22 = l14; + let len22 = l15; + let mut result22 = _rt::Vec::with_capacity(len22); + for i in 0..len22 { + let base = base22 + .add(i * (4 * ::core::mem::size_of::<*const u8>())); + let e22 = { + let l16 = *base.add(0).cast::<*mut u8>(); + let l17 = *base + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + let len18 = l17; + let bytes18 = _rt::Vec::from_raw_parts( + l16.cast(), + len18, + len18, ); - let l18 = *base.add(8).cast::<*mut u8>(); - let l19 = *base.add(12).cast::(); - let len20 = l19; + let l19 = *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l20 = *base + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len21 = l20; HttpHeaderResult { - name: _rt::string_lift(bytes17), - value: _rt::Vec::from_raw_parts(l18.cast(), len20, len20), + name: _rt::string_lift(bytes18), + value: _rt::Vec::from_raw_parts(l19.cast(), len21, len21), } }; - result21.push(e21); + result22.push(e22); } - _rt::cabi_dealloc(base21, len21 * 16, 4); - let l22 = *ptr10.add(16).cast::<*mut u8>(); - let l23 = *ptr10.add(20).cast::(); - let len24 = l23; + _rt::cabi_dealloc( + base22, + len22 * (4 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ); + let l23 = *ptr10 + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l24 = *ptr10 + .add(5 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len25 = l24; HttpResponse { - status: l12 as u16, - headers: result21, - body: _rt::Vec::from_raw_parts(l22.cast(), len24, len24), + status: l13 as u16, + headers: result22, + body: _rt::Vec::from_raw_parts(l23.cast(), len25, len25), } }; Ok(e) } 1 => { let e = { - let l25 = i32::from(*ptr10.add(4).cast::()); - let v32 = match l25 { + let l26 = i32::from( + *ptr10.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let v33 = match l26 { 0 => HttpError::Timeout, 1 => HttpError::InvalidMethod, 2 => { - let e32 = { - let l26 = *ptr10.add(8).cast::<*mut u8>(); - let l27 = *ptr10.add(12).cast::(); - let len28 = l27; - let bytes28 = _rt::Vec::from_raw_parts( - l26.cast(), - len28, - len28, + let e33 = { + let l27 = *ptr10 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l28 = *ptr10 + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len29 = l28; + let bytes29 = _rt::Vec::from_raw_parts( + l27.cast(), + len29, + len29, ); - _rt::string_lift(bytes28) + _rt::string_lift(bytes29) }; - HttpError::InvalidUrl(e32) + HttpError::InvalidUrl(e33) } 3 => HttpError::InvalidHeaderName, 4 => HttpError::InvalidHeaderValue, n => { debug_assert_eq!(n, 5, "invalid enum discriminant"); - let e32 = { - let l29 = *ptr10.add(8).cast::<*mut u8>(); - let l30 = *ptr10.add(12).cast::(); - let len31 = l30; - let bytes31 = _rt::Vec::from_raw_parts( - l29.cast(), - len31, - len31, + let e33 = { + let l30 = *ptr10 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l31 = *ptr10 + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len32 = l31; + let bytes32 = _rt::Vec::from_raw_parts( + l30.cast(), + len32, + len32, ); - _rt::string_lift(bytes31) + _rt::string_lift(bytes32) }; - HttpError::Other(e32) + HttpError::Other(e33) } }; - v32 + v33 }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result34 } } impl HttpError2 { #[allow(unused_unsafe, clippy::all)] /// The error message describing what went wrong. + #[allow(async_fn_in_trait)] pub fn message(&self) -> _rt::String { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 8]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 2 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 8], + [::core::mem::MaybeUninit::uninit(); 2 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { #[link_name = "[method]http-error2.message"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = *ptr0.add(0).cast::<*mut u8>(); - let l2 = *ptr0.add(4).cast::(); - let len3 = l2; - let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); - _rt::string_lift(bytes3) + wit_import1((self).handle() as i32, ptr0); + let l2 = *ptr0.add(0).cast::<*mut u8>(); + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + let result5 = _rt::string_lift(bytes4); + result5 } } } impl HttpError2 { #[allow(unused_unsafe, clippy::all)] /// Whether this error is related to a timeout. + #[allow(async_fn_in_trait)] pub fn is_timeout(&self) -> bool { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { #[link_name = "[method]http-error2.is-timeout"] - fn wit_import(_: i32) -> i32; + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import((self).handle() as i32); + let ret = wit_import0((self).handle() as i32); _rt::bool_lift(ret as u8) } } @@ -465,19 +520,20 @@ pub mod durable { impl HttpError2 { #[allow(unused_unsafe, clippy::all)] /// Whether this error was created while building the request. + #[allow(async_fn_in_trait)] pub fn is_builder(&self) -> bool { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { #[link_name = "[method]http-error2.is-builder"] - fn wit_import(_: i32) -> i32; + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import((self).handle() as i32); + let ret = wit_import0((self).handle() as i32); _rt::bool_lift(ret as u8) } } @@ -485,19 +541,20 @@ pub mod durable { impl HttpError2 { #[allow(unused_unsafe, clippy::all)] /// Whether this error is related to a request. + #[allow(async_fn_in_trait)] pub fn is_request(&self) -> bool { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { #[link_name = "[method]http-error2.is-request"] - fn wit_import(_: i32) -> i32; + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import((self).handle() as i32); + let ret = wit_import0((self).handle() as i32); _rt::bool_lift(ret as u8) } } @@ -506,19 +563,20 @@ pub mod durable { #[allow(unused_unsafe, clippy::all)] /// Whether this error is related to the attempt to connect while making the /// request. + #[allow(async_fn_in_trait)] pub fn is_connect(&self) -> bool { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { #[link_name = "[method]http-error2.is-connect"] - fn wit_import(_: i32) -> i32; + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import((self).handle() as i32); + let ret = wit_import0((self).handle() as i32); _rt::bool_lift(ret as u8) } } @@ -526,6 +584,7 @@ pub mod durable { impl HttpRequest2 { #[allow(unused_unsafe, clippy::all)] /// Create a new request from an HTTP method and a URL. + #[allow(async_fn_in_trait)] pub fn new(method: &str, url: &str) -> Result { unsafe { #[repr(align(4))] @@ -541,10 +600,10 @@ pub mod durable { let len1 = vec1.len(); let ptr2 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { #[link_name = "[static]http-request2.new"] - fn wit_import( + fn wit_import3( _: *mut u8, _: usize, _: *mut u8, @@ -553,7 +612,7 @@ pub mod durable { ); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import( + unsafe extern "C" fn wit_import3( _: *mut u8, _: usize, _: *mut u8, @@ -562,31 +621,33 @@ pub mod durable { ) { unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1.cast_mut(), len1, ptr2); - let l3 = i32::from(*ptr2.add(0).cast::()); - match l3 { + wit_import3(ptr0.cast_mut(), len0, ptr1.cast_mut(), len1, ptr2); + let l4 = i32::from(*ptr2.add(0).cast::()); + let result7 = match l4 { 0 => { let e = { - let l4 = *ptr2.add(4).cast::(); - HttpRequest2::from_handle(l4 as u32) + let l5 = *ptr2.add(4).cast::(); + HttpRequest2::from_handle(l5 as u32) }; Ok(e) } 1 => { let e = { - let l5 = *ptr2.add(4).cast::(); - HttpError2::from_handle(l5 as u32) + let l6 = *ptr2.add(4).cast::(); + HttpError2::from_handle(l6 as u32) }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result7 } } } impl HttpRequest2 { #[allow(unused_unsafe, clippy::all)] /// Set the HTTP method for this request. + #[allow(async_fn_in_trait)] pub fn set_method(&self, method: &str) -> Result<(), HttpError2> { unsafe { #[repr(align(4))] @@ -599,37 +660,44 @@ pub mod durable { let len0 = vec0.len(); let ptr1 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { #[link_name = "[method]http-request2.set-method"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unsafe extern "C" fn wit_import2( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ) { unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { + wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l3 = i32::from(*ptr1.add(0).cast::()); + let result5 = match l3 { 0 => { let e = (); Ok(e) } 1 => { let e = { - let l3 = *ptr1.add(4).cast::(); - HttpError2::from_handle(l3 as u32) + let l4 = *ptr1.add(4).cast::(); + HttpError2::from_handle(l4 as u32) }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result5 } } } impl HttpRequest2 { #[allow(unused_unsafe, clippy::all)] /// Set the URL for this request. + #[allow(async_fn_in_trait)] pub fn set_url(&self, url: &str) -> Result<(), HttpError2> { unsafe { #[repr(align(4))] @@ -642,31 +710,37 @@ pub mod durable { let len0 = vec0.len(); let ptr1 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { #[link_name = "[method]http-request2.set-url"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unsafe extern "C" fn wit_import2( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ) { unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { + wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l3 = i32::from(*ptr1.add(0).cast::()); + let result5 = match l3 { 0 => { let e = (); Ok(e) } 1 => { let e = { - let l3 = *ptr1.add(4).cast::(); - HttpError2::from_handle(l3 as u32) + let l4 = *ptr1.add(4).cast::(); + HttpError2::from_handle(l4 as u32) }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result5 } } } @@ -675,6 +749,7 @@ pub mod durable { /// Set all the headers for this request at once. /// /// This overrides any headers that have been previously set. + #[allow(async_fn_in_trait)] pub fn set_headers( &self, headers: &[HttpHeaderParam<'_>], @@ -687,106 +762,111 @@ pub mod durable { ); let vec3 = headers; let len3 = vec3.len(); - let layout3 = _rt::alloc::Layout::from_size_align_unchecked( - vec3.len() * 16, - 4, - ); - let result3 = if layout3.size() != 0 { - let ptr = _rt::alloc::alloc(layout3).cast::(); - if ptr.is_null() { - _rt::alloc::handle_alloc_error(layout3); - } - ptr - } else { - { ::core::ptr::null_mut() } - }; + let layout3 = _rt::alloc::Layout::from_size_align( + vec3.len() * (4 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + .unwrap(); + let (result3, _cleanup3) = wit_bindgen_rt::Cleanup::new(layout3); for (i, e) in vec3.into_iter().enumerate() { - let base = result3.add(i * 16); + let base = result3 + .add(i * (4 * ::core::mem::size_of::<*const u8>())); { let HttpHeaderParam { name: name0, value: value0 } = e; let vec1 = name0; let ptr1 = vec1.as_ptr().cast::(); let len1 = vec1.len(); - *base.add(4).cast::() = len1; + *base + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len1; *base.add(0).cast::<*mut u8>() = ptr1.cast_mut(); let vec2 = value0; let ptr2 = vec2.as_ptr().cast::(); let len2 = vec2.len(); - *base.add(12).cast::() = len2; - *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + *base + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::() = len2; + *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>() = ptr2.cast_mut(); } } let ptr4 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { #[link_name = "[method]http-request2.set-headers"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8); + fn wit_import5(_: i32, _: *mut u8, _: usize, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8) { + unsafe extern "C" fn wit_import5( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + ) { unreachable!() } - wit_import((self).handle() as i32, result3, len3, ptr4); - let l5 = i32::from(*ptr4.add(0).cast::()); - if layout3.size() != 0 { - _rt::alloc::dealloc(result3.cast(), layout3); - } - match l5 { + wit_import5((self).handle() as i32, result3, len3, ptr4); + let l6 = i32::from(*ptr4.add(0).cast::()); + let result8 = match l6 { 0 => { let e = (); Ok(e) } 1 => { let e = { - let l6 = *ptr4.add(4).cast::(); - HttpError2::from_handle(l6 as u32) + let l7 = *ptr4.add(4).cast::(); + HttpError2::from_handle(l7 as u32) }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result8 } } } impl HttpRequest2 { #[allow(unused_unsafe, clippy::all)] /// Set the request timeout, in nanoseconds. - pub fn set_timeout(&self, timeout: u64) { + #[allow(async_fn_in_trait)] + pub fn set_timeout(&self, timeout: u64) -> () { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { #[link_name = "[method]http-request2.set-timeout"] - fn wit_import(_: i32, _: i64); + fn wit_import0(_: i32, _: i64); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64) { + unsafe extern "C" fn wit_import0(_: i32, _: i64) { unreachable!() } - wit_import((self).handle() as i32, _rt::as_i64(&timeout)); + wit_import0((self).handle() as i32, _rt::as_i64(&timeout)); } } } impl HttpRequest2 { #[allow(unused_unsafe, clippy::all)] /// Set the body of this request. - pub fn set_body(&self, body: &[u8]) { + #[allow(async_fn_in_trait)] + pub fn set_body(&self, body: &[u8]) -> () { unsafe { let vec0 = body; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { #[link_name = "[method]http-request2.set-body"] - fn wit_import(_: i32, _: *mut u8, _: usize); + fn wit_import1(_: i32, _: *mut u8, _: usize); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8, _: usize) { unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0); + wit_import1((self).handle() as i32, ptr0.cast_mut(), len0); } } } @@ -801,81 +881,116 @@ pub mod durable { /// /// # Traps /// This function will trap if called from outside of a durable transaction. + #[allow(async_fn_in_trait)] pub fn fetch2(request: HttpRequest2) -> Result { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 6 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 6 + * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/http@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/http@2.7.0")] + unsafe extern "C" { #[link_name = "fetch2"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((&request).take_handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((&request).take_handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result17 = match l2 { 0 => { let e = { - let l2 = i32::from(*ptr0.add(4).cast::()); - let l3 = *ptr0.add(8).cast::<*mut u8>(); - let l4 = *ptr0.add(12).cast::(); - let base11 = l3; - let len11 = l4; - let mut result11 = _rt::Vec::with_capacity(len11); - for i in 0..len11 { - let base = base11.add(i * 16); - let e11 = { - let l5 = *base.add(0).cast::<*mut u8>(); - let l6 = *base.add(4).cast::(); - let len7 = l6; - let bytes7 = _rt::Vec::from_raw_parts( - l5.cast(), - len7, - len7, + let l3 = i32::from( + *ptr0.add(::core::mem::size_of::<*const u8>()).cast::(), + ); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l5 = *ptr0 + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base12 = l4; + let len12 = l5; + let mut result12 = _rt::Vec::with_capacity(len12); + for i in 0..len12 { + let base = base12 + .add(i * (4 * ::core::mem::size_of::<*const u8>())); + let e12 = { + let l6 = *base.add(0).cast::<*mut u8>(); + let l7 = *base + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, ); - let l8 = *base.add(8).cast::<*mut u8>(); - let l9 = *base.add(12).cast::(); - let len10 = l9; + let l9 = *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l10 = *base + .add(3 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len11 = l10; HttpHeaderResult { - name: _rt::string_lift(bytes7), - value: _rt::Vec::from_raw_parts(l8.cast(), len10, len10), + name: _rt::string_lift(bytes8), + value: _rt::Vec::from_raw_parts(l9.cast(), len11, len11), } }; - result11.push(e11); + result12.push(e12); } - _rt::cabi_dealloc(base11, len11 * 16, 4); - let l12 = *ptr0.add(16).cast::<*mut u8>(); - let l13 = *ptr0.add(20).cast::(); - let len14 = l13; + _rt::cabi_dealloc( + base12, + len12 * (4 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ); + let l13 = *ptr0 + .add(4 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l14 = *ptr0 + .add(5 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len15 = l14; HttpResponse { - status: l2 as u16, - headers: result11, - body: _rt::Vec::from_raw_parts(l12.cast(), len14, len14), + status: l3 as u16, + headers: result12, + body: _rt::Vec::from_raw_parts(l13.cast(), len15, len15), } }; Ok(e) } 1 => { let e = { - let l15 = *ptr0.add(4).cast::(); - HttpError2::from_handle(l15 as u32) + let l16 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + HttpError2::from_handle(l16 as u32) }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result17 } } } } } +#[rustfmt::skip] mod _rt { + #![allow(dead_code, clippy::all)] pub use alloc_crate::string::String; pub use alloc_crate::vec::Vec; use core::fmt; @@ -910,7 +1025,7 @@ mod _rt { impl Resource { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { - debug_assert!(handle != u32::MAX); + debug_assert!(handle != 0 && handle != u32::MAX); Self { handle: AtomicU32::new(handle), _marker: marker::PhantomData, @@ -980,21 +1095,23 @@ mod _rt { if cfg!(debug_assertions) { String::from_utf8(bytes).unwrap() } else { - String::from_utf8_unchecked(bytes) + unsafe { String::from_utf8_unchecked(bytes) } } } pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { if size == 0 { return; } - let layout = alloc::Layout::from_size_align_unchecked(size, align); - alloc::dealloc(ptr, layout); + unsafe { + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr, layout); + } } pub unsafe fn invalid_enum_discriminant() -> T { if cfg!(debug_assertions) { panic!("invalid enum discriminant") } else { - core::hint::unreachable_unchecked() + unsafe { core::hint::unreachable_unchecked() } } } pub unsafe fn bool_lift(val: u8) -> bool { @@ -1010,9 +1127,13 @@ mod _rt { } extern crate alloc as alloc_crate; } +#[rustfmt::skip] #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:wit-bindgen:0.30.0:import-http:encoded world"] +#[unsafe( + link_section = "component-type:wit-bindgen:0.44.0:durable:core@2.7.0:import-http:encoded world" +)] #[doc(hidden)] +#[allow(clippy::octal_escapes)] pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 1099] = *b"\ \0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xc9\x07\x01A\x02\x01\ A\x02\x01B-\x01p}\x01r\x02\x04names\x05value\0\x04\0\x0bhttp-header\x03\0\x01\x01\ @@ -1033,10 +1154,10 @@ lf\x15\x07headers\x03\0\x16\x04\0![method]http-request2.set-headers\x01\x19\x01@ \x02\x04self\x15\x07timeoutw\x01\0\x04\0![method]http-request2.set-timeout\x01\x1a\ \x01@\x02\x04self\x15\x04body\0\x01\0\x04\0\x1e[method]http-request2.set-body\x01\ \x1b\x01j\x01\x09\x01\x0b\x01@\x01\x07request\x07\0\x1c\x04\0\x05fetch\x01\x1d\x01\ -j\x01\x09\x01\x12\x01@\x01\x07request\x11\0\x1e\x04\0\x06fetch2\x01\x1f\x03\x01\x17\ -durable:core/http@2.5.0\x05\0\x04\x01\x1edurable:core/import-http@2.5.0\x04\0\x0b\ -\x11\x01\0\x0bimport-http\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit\ --component\x070.215.0\x10wit-bindgen-rust\x060.30.0"; +j\x01\x09\x01\x12\x01@\x01\x07request\x11\0\x1e\x04\0\x06fetch2\x01\x1f\x03\0\x17\ +durable:core/http@2.7.0\x05\0\x04\0\x1edurable:core/import-http@2.7.0\x04\0\x0b\x11\ +\x01\0\x0bimport-http\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-com\ +ponent\x070.236.1\x10wit-bindgen-rust\x060.44.0"; #[inline(never)] #[doc(hidden)] pub fn __link_custom_section_describing_imports() { diff --git a/crates/durable-runtime/src/plugin/durable/notify.rs b/crates/durable-runtime/src/plugin/durable/notify.rs index e531256..0e6ef02 100644 --- a/crates/durable-runtime/src/plugin/durable/notify.rs +++ b/crates/durable-runtime/src/plugin/durable/notify.rs @@ -118,6 +118,123 @@ impl Host for Task { Ok(data.into()) } + async fn notification_blocking_timeout( + &mut self, + timeout_ns: u64, + ) -> wasmtime::Result> { + if self.state.transaction().is_some() { + anyhow::bail!( + "durable:core/notify.notification-blocking-timeout cannot be called from within a \ + transaction" + ); + } + + let options = TransactionOptions::new("durable:core/notify.notification-blocking-timeout"); + if let Some(event) = self.state.enter::>(options).await? { + return Ok(event.map(Into::into)); + } + + let timeout = std::time::Duration::from_nanos(timeout_ns); + let user_deadline = Instant::now() + timeout; + let suspend_deadline = Instant::now() + self.state.config().suspend_timeout; + let task_id = self.state.task_id(); + let mut rx = self.state.subscribe_notifications(); + + let data = loop { + let mut tx = self.state.pool().begin().await?; + let data = poll_notification(&mut *self, &mut tx).await?; + + if let Some(data) = data { + let txn = self.state.transaction_mut().unwrap(); + txn.set_conn(tx)?; + + break Some(data); + } + + tx.rollback().await?; + + // Wait for either a notification, the user timeout, or the suspend + // timeout — whichever comes first. + enum Expired { + User, + Suspend, + } + + let expired = 'inner: loop { + tokio::select! { + biased; + + result = rx.recv() => match result { + Ok(notif) if notif.task_id == task_id => break 'inner None, + Ok(_) => continue 'inner, + Err(RecvError::Lagged(_)) => break 'inner None, + Err(RecvError::Closed) => { + return Err(anyhow::Error::new(TaskStatus::NotScheduledOnWorker)) + } + }, + _ = tokio::time::sleep_until(user_deadline) => { + break 'inner Some(Expired::User) + }, + _ = tokio::time::sleep_until(suspend_deadline) => { + break 'inner Some(Expired::Suspend) + }, + } + }; + + match expired { + // A notification signal arrived — go back to the top and poll. + None => continue, + + // The user's timeout expired. Check one more time for a + // notification that may have arrived concurrently. + Some(Expired::User) => { + let mut tx = self.state.pool().begin().await?; + let data = poll_notification(&mut *self, &mut tx).await?; + + if let Some(data) = data { + let txn = self.state.transaction_mut().unwrap(); + txn.set_conn(tx)?; + break Some(data); + } + + tx.rollback().await?; + break None; + } + + // The suspend timeout expired. Attempt to suspend the task so + // we free up the worker slot, just like notification_blocking. + Some(Expired::Suspend) => { + let mut tx = self.state.pool().begin().await?; + + sqlx::query!( + "UPDATE durable.task + SET state = 'suspended', + running_on = NULL + WHERE id = $1 + ", + self.task_id() + ) + .execute(&mut *tx) + .await?; + + if poll_notification(&mut *self, &mut tx).await?.is_some() { + // A new notification barged in while we were updating. + // Roll back the suspend and go through the main loop. + tx.rollback().await?; + continue; + } + + tx.commit().await?; + return Err(anyhow::Error::new(TaskStatus::Suspend)); + } + } + }; + + self.exit(&data).await?; + + Ok(data.map(Into::into)) + } + async fn notify( &mut self, task: i64, diff --git a/crates/durable-runtime/wit/imports.wit b/crates/durable-runtime/wit/imports.wit index 4596321..6eee86f 100644 --- a/crates/durable-runtime/wit/imports.wit +++ b/crates/durable-runtime/wit/imports.wit @@ -1,4 +1,4 @@ -package durable:core@2.6.0; +package durable:core@2.7.0; world imports { import core; diff --git a/crates/durable-runtime/wit/notify.wit b/crates/durable-runtime/wit/notify.wit index 5452738..071cc09 100644 --- a/crates/durable-runtime/wit/notify.wit +++ b/crates/durable-runtime/wit/notify.wit @@ -20,6 +20,12 @@ interface notify { /// Read the next available notification, blocking until one is available. notification-blocking: func() -> event; + /// Read the next available notification, blocking until one is available or + /// the timeout expires. Returns `none` if the timeout expired without + /// receiving a notification. + @since(version = 2.7.0) + notification-blocking-timeout: func(timeout-ns: u64) -> option; + /// Errors that can occur as when attempting to notify another task. @since(version = 2.2.0) variant notify-error { diff --git a/crates/durable-sqlx/src/bindings.rs b/crates/durable-sqlx/src/bindings.rs index 42dcdd2..1fc717b 100644 --- a/crates/durable-sqlx/src/bindings.rs +++ b/crates/durable-sqlx/src/bindings.rs @@ -1,8 +1,8 @@ -#[allow(dead_code)] +#[rustfmt::skip] +#[allow(dead_code, clippy::all)] pub mod durable { - #[allow(dead_code)] pub mod core { - #[allow(dead_code, clippy::all)] + #[allow(dead_code, async_fn_in_trait, unused_imports, clippy::all)] pub mod sql { #[used] #[doc(hidden)] @@ -21,7 +21,7 @@ pub mod durable { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { Self { - handle: _rt::Resource::from_handle(handle), + handle: unsafe { _rt::Resource::from_handle(handle) }, } } #[doc(hidden)] @@ -36,16 +36,18 @@ pub mod durable { unsafe impl _rt::WasmResource for TypeInfo { #[inline] unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { - #[link_name = "[resource-drop]type-info"] - fn drop(_: u32); - } - drop(_handle); + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { + #[link_name = "[resource-drop]type-info"] + fn drop(_: i32); + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop(_: i32) { + unreachable!() + } + unsafe { + drop(_handle as i32); } } } @@ -194,7 +196,7 @@ pub mod durable { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { Self { - handle: _rt::Resource::from_handle(handle), + handle: unsafe { _rt::Resource::from_handle(handle) }, } } #[doc(hidden)] @@ -209,16 +211,18 @@ pub mod durable { unsafe impl _rt::WasmResource for Value { #[inline] unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { - #[link_name = "[resource-drop]value"] - fn drop(_: u32); - } - drop(_handle); + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { + #[link_name = "[resource-drop]value"] + fn drop(_: i32); + } + #[cfg(not(target_arch = "wasm32"))] + unsafe extern "C" fn drop(_: i32) { + unreachable!() + } + unsafe { + drop(_handle as i32); } } } @@ -315,7 +319,16 @@ pub mod durable { } } #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq, serde::Deserialize, serde::Serialize)] + #[derive( + Clone, + Copy, + Eq, + Ord, + PartialEq, + PartialOrd, + serde::Deserialize, + serde::Serialize + )] pub enum DatabaseErrorKind { UniqueViolation, ForeignKeyViolation, @@ -352,7 +365,7 @@ pub mod durable { #[doc(hidden)] pub unsafe fn _lift(val: u8) -> DatabaseErrorKind { if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); + return unsafe { ::core::mem::transmute(val) }; } match val { 0 => DatabaseErrorKind::UniqueViolation, @@ -429,49 +442,60 @@ pub mod durable { /// This will not include length specifiers. The type name returned /// is a rough approximation of how it would be written in SQL for the /// database. + #[allow(async_fn_in_trait)] pub fn name(&self) -> _rt::String { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 8]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 2 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 8], + [::core::mem::MaybeUninit::uninit(); 2 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]type-info.name"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = *ptr0.add(0).cast::<*mut u8>(); - let l2 = *ptr0.add(4).cast::(); - let len3 = l2; - let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); - _rt::string_lift(bytes3) + wit_import1((self).handle() as i32, ptr0); + let l2 = *ptr0.add(0).cast::<*mut u8>(); + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + let result5 = _rt::string_lift(bytes4); + result5 } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] /// Whether `self` and `other` represent mutually compatible types. + #[allow(async_fn_in_trait)] pub fn compatible(&self, other: &TypeInfo) -> bool { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]type-info.compatible"] - fn wit_import(_: i32, _: i32) -> i32; + fn wit_import0(_: i32, _: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32, _: i32) -> i32 { unreachable!() } - let ret = wit_import( + let ret = wit_import0( (self).handle() as i32, (other).handle() as i32, ); @@ -482,19 +506,20 @@ pub mod durable { impl TypeInfo { #[allow(unused_unsafe, clippy::all)] /// Whether `self` and `other` represent exactly the same type. + #[allow(async_fn_in_trait)] pub fn equal(&self, other: &TypeInfo) -> bool { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]type-info.equal"] - fn wit_import(_: i32, _: i32) -> i32; + fn wit_import0(_: i32, _: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32, _: i32) -> i32 { unreachable!() } - let ret = wit_import( + let ret = wit_import0( (self).handle() as i32, (other).handle() as i32, ); @@ -505,19 +530,20 @@ pub mod durable { impl TypeInfo { #[allow(unused_unsafe, clippy::all)] /// Create a clone of this type-info. + #[allow(async_fn_in_trait)] pub fn clone(&self) -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]type-info.clone"] - fn wit_import(_: i32) -> i32; + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import((self).handle() as i32); + let ret = wit_import0((self).handle() as i32); TypeInfo::from_handle(ret as u32) } } @@ -527,110 +553,144 @@ pub mod durable { /// Serialize this type-info to json. /// /// The actual json returned by this function is not meant to be introspected. + #[allow(async_fn_in_trait)] pub fn serialize(&self) -> Result<_rt::String, _rt::String> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]type-info.serialize"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result9 = match l2 { 0 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts( - l2.cast(), - len4, - len4, + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts( + l3.cast(), + len5, + len5, ); - _rt::string_lift(bytes4) + _rt::string_lift(bytes5) }; Ok(e) } 1 => { let e = { - let l5 = *ptr0.add(4).cast::<*mut u8>(); - let l6 = *ptr0.add(8).cast::(); - let len7 = l6; - let bytes7 = _rt::Vec::from_raw_parts( - l5.cast(), - len7, - len7, + let l6 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, ); - _rt::string_lift(bytes7) + _rt::string_lift(bytes8) }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result9 } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] /// Deserialize the type-info from json. + #[allow(async_fn_in_trait)] pub fn deserialize(json: &str) -> Result { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let vec0 = json; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); let ptr1 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.deserialize"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8); + fn wit_import2(_: *mut u8, _: usize, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unsafe extern "C" fn wit_import2( + _: *mut u8, + _: usize, + _: *mut u8, + ) { unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { + wit_import2(ptr0.cast_mut(), len0, ptr1); + let l3 = i32::from(*ptr1.add(0).cast::()); + let result8 = match l3 { 0 => { let e = { - let l3 = *ptr1.add(4).cast::(); - TypeInfo::from_handle(l3 as u32) + let l4 = *ptr1 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + TypeInfo::from_handle(l4 as u32) }; Ok(e) } 1 => { let e = { - let l4 = *ptr1.add(4).cast::<*mut u8>(); - let l5 = *ptr1.add(8).cast::(); - let len6 = l5; - let bytes6 = _rt::Vec::from_raw_parts( - l4.cast(), - len6, - len6, + let l5 = *ptr1 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l6 = *ptr1 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, ); - _rt::string_lift(bytes6) + _rt::string_lift(bytes7) }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result8 } } } @@ -644,53 +704,71 @@ pub mod durable { /// /// This returns an error if there is no type with the provided name /// within the database. + #[allow(async_fn_in_trait)] pub fn with_name(name: &str) -> Result { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let vec0 = name; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); let ptr1 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.with-name"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8); + fn wit_import2(_: *mut u8, _: usize, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unsafe extern "C" fn wit_import2( + _: *mut u8, + _: usize, + _: *mut u8, + ) { unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { + wit_import2(ptr0.cast_mut(), len0, ptr1); + let l3 = i32::from(*ptr1.add(0).cast::()); + let result8 = match l3 { 0 => { let e = { - let l3 = *ptr1.add(4).cast::(); - TypeInfo::from_handle(l3 as u32) + let l4 = *ptr1 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + TypeInfo::from_handle(l4 as u32) }; Ok(e) } 1 => { let e = { - let l4 = *ptr1.add(4).cast::<*mut u8>(); - let l5 = *ptr1.add(8).cast::(); - let len6 = l5; - let bytes6 = _rt::Vec::from_raw_parts( - l4.cast(), - len6, - len6, + let l5 = *ptr1 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l6 = *ptr1 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, ); - _rt::string_lift(bytes6) + _rt::string_lift(bytes7) }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result8 } } } @@ -702,532 +780,560 @@ pub mod durable { /// name within the database. Attempting to use a type that doesn't /// exist will result in a failure when making a query. /// with-array-of: static func(name: string) -> result; + #[allow(async_fn_in_trait)] pub fn boolean() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.boolean"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn float4() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.float4"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn float8() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.float8"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int1() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.int1"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int2() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.int2"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int4() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.int4"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int8() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.int8"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn text() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.text"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn bytea() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.bytea"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn timestamptz() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.timestamptz"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn timestamp() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.timestamp"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn uuid() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.uuid"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn jsonb() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.jsonb"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn inet() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.inet"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn boolean_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.boolean-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn float4_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.float4-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn float8_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.float8-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int1_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.int1-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int2_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.int2-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int4_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.int4-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int8_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.int8-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn text_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.text-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn bytea_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.bytea-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn timestamptz_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.timestamptz-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn timestamp_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.timestamp-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn uuid_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.uuid-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn jsonb_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.jsonb-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } } impl TypeInfo { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn inet_array() -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]type-info.inet-array"] - fn wit_import() -> i32; + fn wit_import0() -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32 { + unsafe extern "C" fn wit_import0() -> i32 { unreachable!() } - let ret = wit_import(); + let ret = wit_import0(); TypeInfo::from_handle(ret as u32) } } @@ -1237,19 +1343,20 @@ pub mod durable { /// Whether this value is NULL. /// /// If this is true then all of the `as-*` methods will return none. + #[allow(async_fn_in_trait)] pub fn is_null(&self) -> bool { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.is-null"] - fn wit_import(_: i32) -> i32; + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import((self).handle() as i32); + let ret = wit_import0((self).handle() as i32); _rt::bool_lift(ret as u8) } } @@ -1257,19 +1364,20 @@ pub mod durable { impl Value { #[allow(unused_unsafe, clippy::all)] /// The type of this value. + #[allow(async_fn_in_trait)] pub fn type_info(&self) -> TypeInfo { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.type-info"] - fn wit_import(_: i32) -> i32; + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import((self).handle() as i32); + let ret = wit_import0((self).handle() as i32); TypeInfo::from_handle(ret as u32) } } @@ -1277,19 +1385,20 @@ pub mod durable { impl Value { #[allow(unused_unsafe, clippy::all)] /// Create a clone of this value. + #[allow(async_fn_in_trait)] pub fn clone(&self) -> Value { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.clone"] - fn wit_import(_: i32) -> i32; + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import((self).handle() as i32); + let ret = wit_import0((self).handle() as i32); Value::from_handle(ret as u32) } } @@ -1299,115 +1408,150 @@ pub mod durable { /// Serialize this type-info to json. /// /// The actual json returned by this function is not meant to be introspected. + #[allow(async_fn_in_trait)] pub fn serialize(&self) -> Result<_rt::String, _rt::String> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.serialize"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result9 = match l2 { 0 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts( - l2.cast(), - len4, - len4, + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts( + l3.cast(), + len5, + len5, ); - _rt::string_lift(bytes4) + _rt::string_lift(bytes5) }; Ok(e) } 1 => { let e = { - let l5 = *ptr0.add(4).cast::<*mut u8>(); - let l6 = *ptr0.add(8).cast::(); - let len7 = l6; - let bytes7 = _rt::Vec::from_raw_parts( - l5.cast(), - len7, - len7, + let l6 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l7 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, ); - _rt::string_lift(bytes7) + _rt::string_lift(bytes8) }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result9 } } } impl Value { #[allow(unused_unsafe, clippy::all)] /// Deserialize the type-info from json. + #[allow(async_fn_in_trait)] pub fn deserialize(json: &str) -> Result { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let vec0 = json; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); let ptr1 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.deserialize"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8); + fn wit_import2(_: *mut u8, _: usize, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unsafe extern "C" fn wit_import2( + _: *mut u8, + _: usize, + _: *mut u8, + ) { unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { + wit_import2(ptr0.cast_mut(), len0, ptr1); + let l3 = i32::from(*ptr1.add(0).cast::()); + let result8 = match l3 { 0 => { let e = { - let l3 = *ptr1.add(4).cast::(); - Value::from_handle(l3 as u32) + let l4 = *ptr1 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + Value::from_handle(l4 as u32) }; Ok(e) } 1 => { let e = { - let l4 = *ptr1.add(4).cast::<*mut u8>(); - let l5 = *ptr1.add(8).cast::(); - let len6 = l5; - let bytes6 = _rt::Vec::from_raw_parts( - l4.cast(), - len6, - len6, + let l5 = *ptr1 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l6 = *ptr1 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, ); - _rt::string_lift(bytes6) + _rt::string_lift(bytes7) }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result8 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_boolean(&self) -> Option { unsafe { #[repr(align(1))] @@ -1417,33 +1561,35 @@ pub mod durable { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-boolean"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result4 = match l2 { 0 => None, 1 => { let e = { - let l2 = i32::from(*ptr0.add(1).cast::()); - _rt::bool_lift(l2 as u8) + let l3 = i32::from(*ptr0.add(1).cast::()); + _rt::bool_lift(l3 as u8) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result4 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_float4(&self) -> Option { unsafe { #[repr(align(4))] @@ -1453,33 +1599,35 @@ pub mod durable { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-float4"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result4 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::(); - l2 + let l3 = *ptr0.add(4).cast::(); + l3 }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result4 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_float8(&self) -> Option { unsafe { #[repr(align(8))] @@ -1489,33 +1637,35 @@ pub mod durable { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-float8"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result4 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(8).cast::(); - l2 + let l3 = *ptr0.add(8).cast::(); + l3 }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result4 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_int1(&self) -> Option { unsafe { #[repr(align(1))] @@ -1525,33 +1675,35 @@ pub mod durable { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-int1"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result4 = match l2 { 0 => None, 1 => { let e = { - let l2 = i32::from(*ptr0.add(1).cast::()); - l2 as i8 + let l3 = i32::from(*ptr0.add(1).cast::()); + l3 as i8 }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result4 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_int2(&self) -> Option { unsafe { #[repr(align(2))] @@ -1561,33 +1713,35 @@ pub mod durable { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-int2"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result4 = match l2 { 0 => None, 1 => { let e = { - let l2 = i32::from(*ptr0.add(2).cast::()); - l2 as i16 + let l3 = i32::from(*ptr0.add(2).cast::()); + l3 as i16 }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result4 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_int4(&self) -> Option { unsafe { #[repr(align(4))] @@ -1597,33 +1751,35 @@ pub mod durable { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-int4"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result4 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::(); - l2 + let l3 = *ptr0.add(4).cast::(); + l3 }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result4 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_int8(&self) -> Option { unsafe { #[repr(align(8))] @@ -1633,114 +1789,140 @@ pub mod durable { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-int8"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result4 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(8).cast::(); - l2 + let l3 = *ptr0.add(8).cast::(); + l3 }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result4 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_text(&self) -> Option<_rt::String> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-text"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result6 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts( - l2.cast(), - len4, - len4, + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts( + l3.cast(), + len5, + len5, ); - _rt::string_lift(bytes4) + _rt::string_lift(bytes5) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result6 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_bytea(&self) -> Option<_rt::Vec> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-bytea"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result6 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + _rt::Vec::from_raw_parts(l3.cast(), len5, len5) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result6 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_timestamptz(&self) -> Option { unsafe { #[repr(align(8))] @@ -1750,39 +1932,41 @@ pub mod durable { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-timestamptz"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result6 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(8).cast::(); - let l3 = *ptr0.add(16).cast::(); - let l4 = *ptr0.add(20).cast::(); + let l3 = *ptr0.add(8).cast::(); + let l4 = *ptr0.add(16).cast::(); + let l5 = *ptr0.add(20).cast::(); Timestamptz { - seconds: l2, - subsec_nanos: l3 as u32, - offset: l4, + seconds: l3, + subsec_nanos: l4 as u32, + offset: l5, } }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result6 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_timestamp(&self) -> Option { unsafe { #[repr(align(8))] @@ -1792,37 +1976,39 @@ pub mod durable { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-timestamp"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result5 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(8).cast::(); - let l3 = *ptr0.add(16).cast::(); + let l3 = *ptr0.add(8).cast::(); + let l4 = *ptr0.add(16).cast::(); Timestamp { - seconds: l2, - subsec_nanos: l3 as u32, + seconds: l3, + subsec_nanos: l4 as u32, } }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result5 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_uuid(&self) -> Option { unsafe { #[repr(align(8))] @@ -1832,81 +2018,95 @@ pub mod durable { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-uuid"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result5 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(8).cast::(); - let l3 = *ptr0.add(16).cast::(); + let l3 = *ptr0.add(8).cast::(); + let l4 = *ptr0.add(16).cast::(); Uuid { - hi: l2 as u64, - lo: l3 as u64, + hi: l3 as u64, + lo: l4 as u64, } }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result5 } } } impl Value { #[allow(unused_unsafe, clippy::all)] /// Note that this function works for both json and jsonb types. + #[allow(async_fn_in_trait)] pub fn as_json(&self) -> Option<_rt::String> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-json"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result6 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts( - l2.cast(), - len4, - len4, + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts( + l3.cast(), + len5, + len5, ); - _rt::string_lift(bytes4) + _rt::string_lift(bytes5) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result6 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_inet(&self) -> Option { unsafe { #[repr(align(8))] @@ -1916,721 +2116,913 @@ pub mod durable { ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-inet"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result10 = match l2 { 0 => None, 1 => { let e = { - let l2 = i32::from(*ptr0.add(8).cast::()); - let v8 = match l2 { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v9 = match l3 { 0 => { - let e8 = { - let l3 = *ptr0.add(16).cast::(); - let l4 = i32::from(*ptr0.add(20).cast::()); + let e9 = { + let l4 = *ptr0.add(16).cast::(); + let l5 = i32::from(*ptr0.add(20).cast::()); Ipv4Network { - addr: l3 as u32, - prefix: l4 as u8, + addr: l4 as u32, + prefix: l5 as u8, } }; - IpNetwork::V4(e8) + IpNetwork::V4(e9) } n => { debug_assert_eq!(n, 1, "invalid enum discriminant"); - let e8 = { - let l5 = *ptr0.add(16).cast::(); - let l6 = *ptr0.add(24).cast::(); - let l7 = i32::from(*ptr0.add(32).cast::()); + let e9 = { + let l6 = *ptr0.add(16).cast::(); + let l7 = *ptr0.add(24).cast::(); + let l8 = i32::from(*ptr0.add(32).cast::()); Ipv6Network { - addr: (l5 as u64, l6 as u64), - prefix: l7 as u8, + addr: (l6 as u64, l7 as u64), + prefix: l8 as u8, } }; - IpNetwork::V6(e8) + IpNetwork::V6(e9) } }; - v8 + v9 }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result10 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_boolean_array(&self) -> Option<_rt::Vec> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-boolean-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result7 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let base5 = l2; - let len5 = l3; - let mut result5 = _rt::Vec::with_capacity(len5); - for i in 0..len5 { - let base = base5.add(i * 1); - let e5 = { - let l4 = i32::from(*base.add(0).cast::()); - _rt::bool_lift(l4 as u8) + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base6 = l3; + let len6 = l4; + let mut result6 = _rt::Vec::with_capacity(len6); + for i in 0..len6 { + let base = base6.add(i * 1); + let e6 = { + let l5 = i32::from(*base.add(0).cast::()); + _rt::bool_lift(l5 as u8) }; - result5.push(e5); + result6.push(e6); } - _rt::cabi_dealloc(base5, len5 * 1, 1); - result5 + _rt::cabi_dealloc(base6, len6 * 1, 1); + result6 }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result7 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_float4_array(&self) -> Option<_rt::Vec> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-float4-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result6 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + _rt::Vec::from_raw_parts(l3.cast(), len5, len5) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result6 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_float8_array(&self) -> Option<_rt::Vec> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-float8-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result6 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + _rt::Vec::from_raw_parts(l3.cast(), len5, len5) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result6 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_int1_array(&self) -> Option<_rt::Vec> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-int1-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result6 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + _rt::Vec::from_raw_parts(l3.cast(), len5, len5) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result6 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_int2_array(&self) -> Option<_rt::Vec> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-int2-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result6 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + _rt::Vec::from_raw_parts(l3.cast(), len5, len5) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result6 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_int4_array(&self) -> Option<_rt::Vec> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-int4-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result6 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + _rt::Vec::from_raw_parts(l3.cast(), len5, len5) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result6 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_int8_array(&self) -> Option<_rt::Vec> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-int8-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result6 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + _rt::Vec::from_raw_parts(l3.cast(), len5, len5) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result6 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_text_array(&self) -> Option<_rt::Vec<_rt::String>> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-text-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result9 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let base7 = l2; - let len7 = l3; - let mut result7 = _rt::Vec::with_capacity(len7); - for i in 0..len7 { - let base = base7.add(i * 8); - let e7 = { - let l4 = *base.add(0).cast::<*mut u8>(); - let l5 = *base.add(4).cast::(); - let len6 = l5; - let bytes6 = _rt::Vec::from_raw_parts( - l4.cast(), - len6, - len6, + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base8 = l3; + let len8 = l4; + let mut result8 = _rt::Vec::with_capacity(len8); + for i in 0..len8 { + let base = base8 + .add(i * (2 * ::core::mem::size_of::<*const u8>())); + let e8 = { + let l5 = *base.add(0).cast::<*mut u8>(); + let l6 = *base + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, ); - _rt::string_lift(bytes6) + _rt::string_lift(bytes7) }; - result7.push(e7); + result8.push(e8); } - _rt::cabi_dealloc(base7, len7 * 8, 4); - result7 + _rt::cabi_dealloc( + base8, + len8 * (2 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ); + result8 }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result9 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_bytea_array(&self) -> Option<_rt::Vec<_rt::Vec>> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-bytea-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result9 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let base7 = l2; - let len7 = l3; - let mut result7 = _rt::Vec::with_capacity(len7); - for i in 0..len7 { - let base = base7.add(i * 8); - let e7 = { - let l4 = *base.add(0).cast::<*mut u8>(); - let l5 = *base.add(4).cast::(); - let len6 = l5; - _rt::Vec::from_raw_parts(l4.cast(), len6, len6) + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base8 = l3; + let len8 = l4; + let mut result8 = _rt::Vec::with_capacity(len8); + for i in 0..len8 { + let base = base8 + .add(i * (2 * ::core::mem::size_of::<*const u8>())); + let e8 = { + let l5 = *base.add(0).cast::<*mut u8>(); + let l6 = *base + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + let len7 = l6; + _rt::Vec::from_raw_parts(l5.cast(), len7, len7) }; - result7.push(e7); + result8.push(e8); } - _rt::cabi_dealloc(base7, len7 * 8, 4); - result7 + _rt::cabi_dealloc( + base8, + len8 * (2 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ); + result8 }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result9 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_timestamptz_array(&self) -> Option<_rt::Vec> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-timestamptz-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result6 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + _rt::Vec::from_raw_parts(l3.cast(), len5, len5) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result6 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_timestamp_array(&self) -> Option<_rt::Vec> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-timestamp-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result6 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + _rt::Vec::from_raw_parts(l3.cast(), len5, len5) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result6 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_uuid_array(&self) -> Option<_rt::Vec> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-uuid-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result6 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len5 = l4; + _rt::Vec::from_raw_parts(l3.cast(), len5, len5) }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result6 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_json_array(&self) -> Option<_rt::Vec<_rt::String>> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-json-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result9 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let base7 = l2; - let len7 = l3; - let mut result7 = _rt::Vec::with_capacity(len7); - for i in 0..len7 { - let base = base7.add(i * 8); - let e7 = { - let l4 = *base.add(0).cast::<*mut u8>(); - let l5 = *base.add(4).cast::(); - let len6 = l5; - let bytes6 = _rt::Vec::from_raw_parts( - l4.cast(), - len6, - len6, + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base8 = l3; + let len8 = l4; + let mut result8 = _rt::Vec::with_capacity(len8); + for i in 0..len8 { + let base = base8 + .add(i * (2 * ::core::mem::size_of::<*const u8>())); + let e8 = { + let l5 = *base.add(0).cast::<*mut u8>(); + let l6 = *base + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, ); - _rt::string_lift(bytes6) + _rt::string_lift(bytes7) }; - result7.push(e7); + result8.push(e8); } - _rt::cabi_dealloc(base7, len7 * 8, 4); - result7 + _rt::cabi_dealloc( + base8, + len8 * (2 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ); + result8 }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result9 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn as_inet_array(&self) -> Option<_rt::Vec> { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[method]value.as-inet-array"] - fn wit_import(_: i32, _: *mut u8); + fn wit_import1(_: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { + unsafe extern "C" fn wit_import1(_: i32, _: *mut u8) { unreachable!() } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1((self).handle() as i32, ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result13 = match l2 { 0 => None, 1 => { let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let base11 = l2; - let len11 = l3; - let mut result11 = _rt::Vec::with_capacity(len11); - for i in 0..len11 { - let base = base11.add(i * 32); - let e11 = { - let l4 = i32::from(*base.add(0).cast::()); - let v10 = match l4 { + let l3 = *ptr0 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l4 = *ptr0 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base12 = l3; + let len12 = l4; + let mut result12 = _rt::Vec::with_capacity(len12); + for i in 0..len12 { + let base = base12.add(i * 32); + let e12 = { + let l5 = i32::from(*base.add(0).cast::()); + let v11 = match l5 { 0 => { - let e10 = { - let l5 = *base.add(8).cast::(); - let l6 = i32::from(*base.add(12).cast::()); + let e11 = { + let l6 = *base.add(8).cast::(); + let l7 = i32::from(*base.add(12).cast::()); Ipv4Network { - addr: l5 as u32, - prefix: l6 as u8, + addr: l6 as u32, + prefix: l7 as u8, } }; - IpNetwork::V4(e10) + IpNetwork::V4(e11) } n => { debug_assert_eq!(n, 1, "invalid enum discriminant"); - let e10 = { - let l7 = *base.add(8).cast::(); - let l8 = *base.add(16).cast::(); - let l9 = i32::from(*base.add(24).cast::()); + let e11 = { + let l8 = *base.add(8).cast::(); + let l9 = *base.add(16).cast::(); + let l10 = i32::from(*base.add(24).cast::()); Ipv6Network { - addr: (l7 as u64, l8 as u64), - prefix: l9 as u8, + addr: (l8 as u64, l9 as u64), + prefix: l10 as u8, } }; - IpNetwork::V6(e10) + IpNetwork::V6(e11) } }; - v10 + v11 }; - result11.push(e11); + result12.push(e12); } - _rt::cabi_dealloc(base11, len11 * 32, 8); - result11 + _rt::cabi_dealloc(base12, len12 * 32, 8); + result12 }; Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result13 } } } impl Value { #[allow(unused_unsafe, clippy::all)] /// Create a null value with the provided type info. + #[allow(async_fn_in_trait)] pub fn null(tyinfo: TypeInfo) -> Value { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.null"] - fn wit_import(_: i32) -> i32; + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import((&tyinfo).take_handle() as i32); + let ret = wit_import0((&tyinfo).take_handle() as i32); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn boolean(value: bool) -> Value { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.boolean"] - fn wit_import(_: i32) -> i32; + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import( + let ret = wit_import0( match &value { true => 1, false => 0, @@ -2642,164 +3034,173 @@ pub mod durable { } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn float4(value: f32) -> Value { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.float4"] - fn wit_import(_: f32) -> i32; + fn wit_import0(_: f32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: f32) -> i32 { + unsafe extern "C" fn wit_import0(_: f32) -> i32 { unreachable!() } - let ret = wit_import(_rt::as_f32(&value)); + let ret = wit_import0(_rt::as_f32(&value)); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn float8(value: f64) -> Value { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.float8"] - fn wit_import(_: f64) -> i32; + fn wit_import0(_: f64) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: f64) -> i32 { + unsafe extern "C" fn wit_import0(_: f64) -> i32 { unreachable!() } - let ret = wit_import(_rt::as_f64(&value)); + let ret = wit_import0(_rt::as_f64(&value)); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int1(value: i8) -> Value { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.int1"] - fn wit_import(_: i32) -> i32; + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import(_rt::as_i32(&value)); + let ret = wit_import0(_rt::as_i32(&value)); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int2(value: i16) -> Value { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.int2"] - fn wit_import(_: i32) -> i32; + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import(_rt::as_i32(&value)); + let ret = wit_import0(_rt::as_i32(&value)); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int4(value: i32) -> Value { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.int4"] - fn wit_import(_: i32) -> i32; + fn wit_import0(_: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32) -> i32 { + unsafe extern "C" fn wit_import0(_: i32) -> i32 { unreachable!() } - let ret = wit_import(_rt::as_i32(&value)); + let ret = wit_import0(_rt::as_i32(&value)); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int8(value: i64) -> Value { unsafe { #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.int8"] - fn wit_import(_: i64) -> i32; + fn wit_import0(_: i64) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64) -> i32 { + unsafe extern "C" fn wit_import0(_: i64) -> i32 { unreachable!() } - let ret = wit_import(_rt::as_i64(&value)); + let ret = wit_import0(_rt::as_i64(&value)); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn text(value: &str) -> Value { unsafe { let vec0 = value; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.text"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import1(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(ptr0.cast_mut(), len0); + let ret = wit_import1(ptr0.cast_mut(), len0); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn bytea(value: &[u8]) -> Value { unsafe { let vec0 = value; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.bytea"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import1(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(ptr0.cast_mut(), len0); + let ret = wit_import1(ptr0.cast_mut(), len0); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn timestamptz(value: Timestamptz) -> Value { unsafe { let Timestamptz { @@ -2808,16 +3209,16 @@ pub mod durable { offset: offset0, } = value; #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.timestamptz"] - fn wit_import(_: i64, _: i32, _: i32) -> i32; + fn wit_import1(_: i64, _: i32, _: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i32, _: i32) -> i32 { + unsafe extern "C" fn wit_import1(_: i64, _: i32, _: i32) -> i32 { unreachable!() } - let ret = wit_import( + let ret = wit_import1( _rt::as_i64(seconds0), _rt::as_i32(subsec_nanos0), _rt::as_i32(offset0), @@ -2828,6 +3229,7 @@ pub mod durable { } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn timestamp(value: Timestamp) -> Value { unsafe { let Timestamp { @@ -2835,16 +3237,16 @@ pub mod durable { subsec_nanos: subsec_nanos0, } = value; #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.timestamp"] - fn wit_import(_: i64, _: i32) -> i32; + fn wit_import1(_: i64, _: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i32) -> i32 { + unsafe extern "C" fn wit_import1(_: i64, _: i32) -> i32 { unreachable!() } - let ret = wit_import( + let ret = wit_import1( _rt::as_i64(seconds0), _rt::as_i32(subsec_nanos0), ); @@ -2854,54 +3256,63 @@ pub mod durable { } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn uuid(value: Uuid) -> Value { unsafe { let Uuid { hi: hi0, lo: lo0 } = value; #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.uuid"] - fn wit_import(_: i64, _: i64) -> i32; + fn wit_import1(_: i64, _: i64) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i64) -> i32 { + unsafe extern "C" fn wit_import1(_: i64, _: i64) -> i32 { unreachable!() } - let ret = wit_import(_rt::as_i64(hi0), _rt::as_i64(lo0)); + let ret = wit_import1(_rt::as_i64(hi0), _rt::as_i64(lo0)); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn jsonb(value: &str) -> Value { unsafe { let vec0 = value; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.jsonb"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import1(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(ptr0.cast_mut(), len0); + let ret = wit_import1(ptr0.cast_mut(), len0); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn inet(value: IpNetwork) -> Result { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let (result3_0, result3_1, result3_2, result3_3) = match value { IpNetwork::V4(e) => { @@ -2926,62 +3337,80 @@ pub mod durable { }; let ptr4 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.inet"] - fn wit_import(_: i32, _: i64, _: i64, _: i32, _: *mut u8); + fn wit_import5(_: i32, _: i64, _: i64, _: i32, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i64, _: i32, _: *mut u8) { + unsafe extern "C" fn wit_import5( + _: i32, + _: i64, + _: i64, + _: i32, + _: *mut u8, + ) { unreachable!() } - wit_import(result3_0, result3_1, result3_2, result3_3, ptr4); - let l5 = i32::from(*ptr4.add(0).cast::()); - match l5 { + wit_import5(result3_0, result3_1, result3_2, result3_3, ptr4); + let l6 = i32::from(*ptr4.add(0).cast::()); + let result11 = match l6 { 0 => { let e = { - let l6 = *ptr4.add(4).cast::(); - Value::from_handle(l6 as u32) + let l7 = *ptr4 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + Value::from_handle(l7 as u32) }; Ok(e) } 1 => { let e = { - let l7 = *ptr4.add(4).cast::<*mut u8>(); - let l8 = *ptr4.add(8).cast::(); - let len9 = l8; - let bytes9 = _rt::Vec::from_raw_parts( - l7.cast(), - len9, - len9, + let l8 = *ptr4 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l9 = *ptr4 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len10 = l9; + let bytes10 = _rt::Vec::from_raw_parts( + l8.cast(), + len10, + len10, ); - _rt::string_lift(bytes9) + _rt::string_lift(bytes10) }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result11 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn enum_value(value: &str, tyinfo: &TypeInfo) -> Value { unsafe { let vec0 = value; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.enum-value"] - fn wit_import(_: *mut u8, _: usize, _: i32) -> i32; + fn wit_import1(_: *mut u8, _: usize, _: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32) -> i32 { + unsafe extern "C" fn wit_import1( + _: *mut u8, + _: usize, + _: i32, + ) -> i32 { unreachable!() } - let ret = wit_import( + let ret = wit_import1( ptr0.cast_mut(), len0, (tyinfo).handle() as i32, @@ -2992,23 +3421,17 @@ pub mod durable { } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn boolean_array(value: &[bool]) -> Value { unsafe { let vec0 = value; let len0 = vec0.len(); - let layout0 = _rt::alloc::Layout::from_size_align_unchecked( - vec0.len() * 1, - 1, - ); - let result0 = if layout0.size() != 0 { - let ptr = _rt::alloc::alloc(layout0).cast::(); - if ptr.is_null() { - _rt::alloc::handle_alloc_error(layout0); - } - ptr - } else { - { ::core::ptr::null_mut() } - }; + let layout0 = _rt::alloc::Layout::from_size_align( + vec0.len() * 1, + 1, + ) + .unwrap(); + let (result0, _cleanup0) = wit_bindgen_rt::Cleanup::new(layout0); for (i, e) in vec0.into_iter().enumerate() { let base = result0.add(i * 1); { @@ -3019,386 +3442,374 @@ pub mod durable { } } #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.boolean-array"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import1(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(result0, len0); - if layout0.size() != 0 { - _rt::alloc::dealloc(result0.cast(), layout0); - } + let ret = wit_import1(result0, len0); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn float4_array(value: &[f32]) -> Value { unsafe { let vec0 = value; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.float4-array"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import1(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(ptr0.cast_mut(), len0); + let ret = wit_import1(ptr0.cast_mut(), len0); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn float8_array(value: &[f64]) -> Value { unsafe { let vec0 = value; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.float8-array"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import1(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(ptr0.cast_mut(), len0); + let ret = wit_import1(ptr0.cast_mut(), len0); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int1_array(value: &[i8]) -> Value { unsafe { let vec0 = value; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.int1-array"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import1(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(ptr0.cast_mut(), len0); + let ret = wit_import1(ptr0.cast_mut(), len0); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int2_array(value: &[i16]) -> Value { unsafe { let vec0 = value; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.int2-array"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import1(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(ptr0.cast_mut(), len0); + let ret = wit_import1(ptr0.cast_mut(), len0); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int4_array(value: &[i32]) -> Value { unsafe { let vec0 = value; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.int4-array"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import1(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(ptr0.cast_mut(), len0); + let ret = wit_import1(ptr0.cast_mut(), len0); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn int8_array(value: &[i64]) -> Value { unsafe { let vec0 = value; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.int8-array"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import1(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(ptr0.cast_mut(), len0); + let ret = wit_import1(ptr0.cast_mut(), len0); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn text_array(value: &[&str]) -> Value { unsafe { let vec1 = value; let len1 = vec1.len(); - let layout1 = _rt::alloc::Layout::from_size_align_unchecked( - vec1.len() * 8, - 4, - ); - let result1 = if layout1.size() != 0 { - let ptr = _rt::alloc::alloc(layout1).cast::(); - if ptr.is_null() { - _rt::alloc::handle_alloc_error(layout1); - } - ptr - } else { - { ::core::ptr::null_mut() } - }; + let layout1 = _rt::alloc::Layout::from_size_align( + vec1.len() * (2 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + .unwrap(); + let (result1, _cleanup1) = wit_bindgen_rt::Cleanup::new(layout1); for (i, e) in vec1.into_iter().enumerate() { - let base = result1.add(i * 8); + let base = result1 + .add(i * (2 * ::core::mem::size_of::<*const u8>())); { let vec0 = e; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); - *base.add(4).cast::() = len0; + *base + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; *base.add(0).cast::<*mut u8>() = ptr0.cast_mut(); } } #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.text-array"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import2(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import2(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(result1, len1); - if layout1.size() != 0 { - _rt::alloc::dealloc(result1.cast(), layout1); - } + let ret = wit_import2(result1, len1); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn bytea_array(value: &[&[u8]]) -> Value { unsafe { let vec1 = value; let len1 = vec1.len(); - let layout1 = _rt::alloc::Layout::from_size_align_unchecked( - vec1.len() * 8, - 4, - ); - let result1 = if layout1.size() != 0 { - let ptr = _rt::alloc::alloc(layout1).cast::(); - if ptr.is_null() { - _rt::alloc::handle_alloc_error(layout1); - } - ptr - } else { - { ::core::ptr::null_mut() } - }; + let layout1 = _rt::alloc::Layout::from_size_align( + vec1.len() * (2 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + .unwrap(); + let (result1, _cleanup1) = wit_bindgen_rt::Cleanup::new(layout1); for (i, e) in vec1.into_iter().enumerate() { - let base = result1.add(i * 8); + let base = result1 + .add(i * (2 * ::core::mem::size_of::<*const u8>())); { let vec0 = e; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); - *base.add(4).cast::() = len0; + *base + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; *base.add(0).cast::<*mut u8>() = ptr0.cast_mut(); } } #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.bytea-array"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import2(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import2(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(result1, len1); - if layout1.size() != 0 { - _rt::alloc::dealloc(result1.cast(), layout1); - } + let ret = wit_import2(result1, len1); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn timestamptz_array(value: &[Timestamptz]) -> Value { unsafe { let vec0 = value; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.timestamptz-array"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import1(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(ptr0.cast_mut(), len0); + let ret = wit_import1(ptr0.cast_mut(), len0); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn timestamp_array(value: &[Timestamp]) -> Value { unsafe { let vec0 = value; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.timestamp-array"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import1(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(ptr0.cast_mut(), len0); + let ret = wit_import1(ptr0.cast_mut(), len0); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn uuid_array(value: &[Uuid]) -> Value { unsafe { let vec0 = value; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.uuid-array"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import1(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import1(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(ptr0.cast_mut(), len0); + let ret = wit_import1(ptr0.cast_mut(), len0); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn jsonb_array(value: &[&str]) -> Value { unsafe { let vec1 = value; let len1 = vec1.len(); - let layout1 = _rt::alloc::Layout::from_size_align_unchecked( - vec1.len() * 8, - 4, - ); - let result1 = if layout1.size() != 0 { - let ptr = _rt::alloc::alloc(layout1).cast::(); - if ptr.is_null() { - _rt::alloc::handle_alloc_error(layout1); - } - ptr - } else { - { ::core::ptr::null_mut() } - }; + let layout1 = _rt::alloc::Layout::from_size_align( + vec1.len() * (2 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + .unwrap(); + let (result1, _cleanup1) = wit_bindgen_rt::Cleanup::new(layout1); for (i, e) in vec1.into_iter().enumerate() { - let base = result1.add(i * 8); + let base = result1 + .add(i * (2 * ::core::mem::size_of::<*const u8>())); { let vec0 = e; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); - *base.add(4).cast::() = len0; + *base + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; *base.add(0).cast::<*mut u8>() = ptr0.cast_mut(); } } #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.jsonb-array"] - fn wit_import(_: *mut u8, _: usize) -> i32; + fn wit_import2(_: *mut u8, _: usize) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize) -> i32 { + unsafe extern "C" fn wit_import2(_: *mut u8, _: usize) -> i32 { unreachable!() } - let ret = wit_import(result1, len1); - if layout1.size() != 0 { - _rt::alloc::dealloc(result1.cast(), layout1); - } + let ret = wit_import2(result1, len1); Value::from_handle(ret as u32) } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn inet_array(value: &[IpNetwork]) -> Result { unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit; 12]); + #[cfg_attr(target_pointer_width = "64", repr(align(8)))] + #[cfg_attr(target_pointer_width = "32", repr(align(4)))] + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 3 * ::core::mem::size_of::<*const u8>()], + ); let mut ret_area = RetArea( - [::core::mem::MaybeUninit::uninit(); 12], + [::core::mem::MaybeUninit::uninit(); 3 + * ::core::mem::size_of::<*const u8>()], ); let vec3 = value; let len3 = vec3.len(); - let layout3 = _rt::alloc::Layout::from_size_align_unchecked( - vec3.len() * 32, - 8, - ); - let result3 = if layout3.size() != 0 { - let ptr = _rt::alloc::alloc(layout3).cast::(); - if ptr.is_null() { - _rt::alloc::handle_alloc_error(layout3); - } - ptr - } else { - { ::core::ptr::null_mut() } - }; + let layout3 = _rt::alloc::Layout::from_size_align( + vec3.len() * 32, + 8, + ) + .unwrap(); + let (result3, _cleanup3) = wit_bindgen_rt::Cleanup::new(layout3); for (i, e) in vec3.into_iter().enumerate() { let base = result3.add(i * 32); { @@ -3422,90 +3833,96 @@ pub mod durable { } let ptr4 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.inet-array"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8); + fn wit_import5(_: *mut u8, _: usize, _: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8) { + unsafe extern "C" fn wit_import5( + _: *mut u8, + _: usize, + _: *mut u8, + ) { unreachable!() } - wit_import(result3, len3, ptr4); - let l5 = i32::from(*ptr4.add(0).cast::()); - if layout3.size() != 0 { - _rt::alloc::dealloc(result3.cast(), layout3); - } - match l5 { + wit_import5(result3, len3, ptr4); + let l6 = i32::from(*ptr4.add(0).cast::()); + let result11 = match l6 { 0 => { let e = { - let l6 = *ptr4.add(4).cast::(); - Value::from_handle(l6 as u32) + let l7 = *ptr4 + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + Value::from_handle(l7 as u32) }; Ok(e) } 1 => { let e = { - let l7 = *ptr4.add(4).cast::<*mut u8>(); - let l8 = *ptr4.add(8).cast::(); - let len9 = l8; - let bytes9 = _rt::Vec::from_raw_parts( - l7.cast(), - len9, - len9, + let l8 = *ptr4 + .add(::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l9 = *ptr4 + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len10 = l9; + let bytes10 = _rt::Vec::from_raw_parts( + l8.cast(), + len10, + len10, ); - _rt::string_lift(bytes9) + _rt::string_lift(bytes10) }; Err(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result11 } } } impl Value { #[allow(unused_unsafe, clippy::all)] + #[allow(async_fn_in_trait)] pub fn enum_array(value: &[&str], tyinfo: &TypeInfo) -> Value { unsafe { let vec1 = value; let len1 = vec1.len(); - let layout1 = _rt::alloc::Layout::from_size_align_unchecked( - vec1.len() * 8, - 4, - ); - let result1 = if layout1.size() != 0 { - let ptr = _rt::alloc::alloc(layout1).cast::(); - if ptr.is_null() { - _rt::alloc::handle_alloc_error(layout1); - } - ptr - } else { - { ::core::ptr::null_mut() } - }; + let layout1 = _rt::alloc::Layout::from_size_align( + vec1.len() * (2 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ) + .unwrap(); + let (result1, _cleanup1) = wit_bindgen_rt::Cleanup::new(layout1); for (i, e) in vec1.into_iter().enumerate() { - let base = result1.add(i * 8); + let base = result1 + .add(i * (2 * ::core::mem::size_of::<*const u8>())); { let vec0 = e; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); - *base.add(4).cast::() = len0; + *base + .add(::core::mem::size_of::<*const u8>()) + .cast::() = len0; *base.add(0).cast::<*mut u8>() = ptr0.cast_mut(); } } #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "[static]value.enum-array"] - fn wit_import(_: *mut u8, _: usize, _: i32) -> i32; + fn wit_import2(_: *mut u8, _: usize, _: i32) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32) -> i32 { + unsafe extern "C" fn wit_import2( + _: *mut u8, + _: usize, + _: i32, + ) -> i32 { unreachable!() } - let ret = wit_import(result1, len1, (tyinfo).handle() as i32); - if layout1.size() != 0 { - _rt::alloc::dealloc(result1.cast(), layout1); - } + let ret = wit_import2(result1, len1, (tyinfo).handle() as i32); Value::from_handle(ret as u32) } } @@ -3518,26 +3935,17 @@ pub mod durable { /// /// Calling query again while there are still results from a previous query /// results in the remaining unconsumed rows being discarded. - pub fn query(sql: &str, params: _rt::Vec, options: Options) { + #[allow(async_fn_in_trait)] + pub fn query(sql: &str, params: _rt::Vec, options: Options) -> () { unsafe { let vec0 = sql; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); let vec1 = ¶ms; let len1 = vec1.len(); - let layout1 = _rt::alloc::Layout::from_size_align_unchecked( - vec1.len() * 4, - 4, - ); - let result1 = if layout1.size() != 0 { - let ptr = _rt::alloc::alloc(layout1).cast::(); - if ptr.is_null() { - _rt::alloc::handle_alloc_error(layout1); - } - ptr - } else { - { ::core::ptr::null_mut() } - }; + let layout1 = _rt::alloc::Layout::from_size_align(vec1.len() * 4, 4) + .unwrap(); + let (result1, _cleanup1) = wit_bindgen_rt::Cleanup::new(layout1); for (i, e) in vec1.into_iter().enumerate() { let base = result1.add(i * 4); { @@ -3546,10 +3954,10 @@ pub mod durable { } let Options { limit: limit2, persistent: persistent2 } = options; #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "query"] - fn wit_import( + fn wit_import3( _: *mut u8, _: usize, _: *mut u8, @@ -3559,7 +3967,7 @@ pub mod durable { ); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import( + unsafe extern "C" fn wit_import3( _: *mut u8, _: usize, _: *mut u8, @@ -3569,7 +3977,7 @@ pub mod durable { ) { unreachable!() } - wit_import( + wit_import3( ptr0.cast_mut(), len0, result1, @@ -3580,222 +3988,290 @@ pub mod durable { false => 0, }, ); - if layout1.size() != 0 { - _rt::alloc::dealloc(result1.cast(), layout1); - } } } #[allow(unused_unsafe, clippy::all)] /// Fetch either a query result or a single row from the query. + #[allow(async_fn_in_trait)] pub fn fetch() -> Option> { unsafe { #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit; 72]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 72]); + struct RetArea( + [::core::mem::MaybeUninit< + u8, + >; 24 + 12 * ::core::mem::size_of::<*const u8>()], + ); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 24 + + 12 * ::core::mem::size_of::<*const u8>()], + ); let ptr0 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "durable:core/sql@2.5.0")] - extern "C" { + #[link(wasm_import_module = "durable:core/sql@2.7.0")] + unsafe extern "C" { #[link_name = "fetch"] - fn wit_import(_: *mut u8); + fn wit_import1(_: *mut u8); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8) { + unsafe extern "C" fn wit_import1(_: *mut u8) { unreachable!() } - wit_import(ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { + wit_import1(ptr0); + let l2 = i32::from(*ptr0.add(0).cast::()); + let result50 = match l2 { 0 => None, 1 => { let e = { - let l2 = i32::from(*ptr0.add(8).cast::()); - match l2 { + let l3 = i32::from(*ptr0.add(8).cast::()); + match l3 { 0 => { let e = { - let l3 = i32::from(*ptr0.add(16).cast::()); - let v12 = match l3 { + let l4 = i32::from(*ptr0.add(16).cast::()); + let v13 = match l4 { 0 => { - let e12 = { - let l4 = *ptr0.add(24).cast::(); - l4 as u64 + let e13 = { + let l5 = *ptr0.add(24).cast::(); + l5 as u64 }; - QueryResult::Count(e12) + QueryResult::Count(e13) } n => { debug_assert_eq!(n, 1, "invalid enum discriminant"); - let e12 = { - let l5 = *ptr0.add(24).cast::<*mut u8>(); - let l6 = *ptr0.add(28).cast::(); - let base11 = l5; - let len11 = l6; - let mut result11 = _rt::Vec::with_capacity(len11); - for i in 0..len11 { - let base = base11.add(i * 12); - let e11 = { - let l7 = *base.add(0).cast::<*mut u8>(); - let l8 = *base.add(4).cast::(); - let len9 = l8; - let bytes9 = _rt::Vec::from_raw_parts( - l7.cast(), - len9, - len9, + let e13 = { + let l6 = *ptr0.add(24).cast::<*mut u8>(); + let l7 = *ptr0 + .add(24 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let base12 = l6; + let len12 = l7; + let mut result12 = _rt::Vec::with_capacity(len12); + for i in 0..len12 { + let base = base12 + .add(i * (3 * ::core::mem::size_of::<*const u8>())); + let e12 = { + let l8 = *base.add(0).cast::<*mut u8>(); + let l9 = *base + .add(::core::mem::size_of::<*const u8>()) + .cast::(); + let len10 = l9; + let bytes10 = _rt::Vec::from_raw_parts( + l8.cast(), + len10, + len10, ); - let l10 = *base.add(8).cast::(); + let l11 = *base + .add(2 * ::core::mem::size_of::<*const u8>()) + .cast::(); Column { - name: _rt::string_lift(bytes9), - value: Value::from_handle(l10 as u32), + name: _rt::string_lift(bytes10), + value: Value::from_handle(l11 as u32), } }; - result11.push(e11); + result12.push(e12); } - _rt::cabi_dealloc(base11, len11 * 12, 4); - Row { columns: result11 } + _rt::cabi_dealloc( + base12, + len12 * (3 * ::core::mem::size_of::<*const u8>()), + ::core::mem::size_of::<*const u8>(), + ); + Row { columns: result12 } }; - QueryResult::Row(e12) + QueryResult::Row(e13) } }; - v12 + v13 }; Ok(e) } 1 => { let e = { - let l13 = i32::from(*ptr0.add(16).cast::()); - let v48 = match l13 { + let l14 = i32::from(*ptr0.add(16).cast::()); + let v49 = match l14 { 0 => { - let e48 = { - let l14 = *ptr0.add(20).cast::<*mut u8>(); - let l15 = *ptr0.add(24).cast::(); - let len16 = l15; - let bytes16 = _rt::Vec::from_raw_parts( - l14.cast(), - len16, - len16, + let e49 = { + let l15 = *ptr0 + .add(16 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l16 = *ptr0 + .add(16 + 2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len17 = l16; + let bytes17 = _rt::Vec::from_raw_parts( + l15.cast(), + len17, + len17, ); - let l17 = *ptr0.add(28).cast::<*mut u8>(); - let l18 = *ptr0.add(32).cast::(); - let len19 = l18; - let bytes19 = _rt::Vec::from_raw_parts( - l17.cast(), - len19, - len19, + let l18 = *ptr0 + .add(16 + 3 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l19 = *ptr0 + .add(16 + 4 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len20 = l19; + let bytes20 = _rt::Vec::from_raw_parts( + l18.cast(), + len20, + len20, ); ColumnDecodeError { - index: _rt::string_lift(bytes16), - source: _rt::string_lift(bytes19), + index: _rt::string_lift(bytes17), + source: _rt::string_lift(bytes20), } }; - Error::ColumnDecode(e48) + Error::ColumnDecode(e49) } 1 => { - let e48 = { - let l20 = *ptr0.add(20).cast::<*mut u8>(); - let l21 = *ptr0.add(24).cast::(); - let len22 = l21; - let bytes22 = _rt::Vec::from_raw_parts( - l20.cast(), - len22, - len22, + let e49 = { + let l21 = *ptr0 + .add(16 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l22 = *ptr0 + .add(16 + 2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len23 = l22; + let bytes23 = _rt::Vec::from_raw_parts( + l21.cast(), + len23, + len23, ); - _rt::string_lift(bytes22) + _rt::string_lift(bytes23) }; - Error::TypeNotFound(e48) + Error::TypeNotFound(e49) } 2 => { - let e48 = { - let l23 = *ptr0.add(20).cast::<*mut u8>(); - let l24 = *ptr0.add(24).cast::(); - let len25 = l24; - let bytes25 = _rt::Vec::from_raw_parts( - l23.cast(), - len25, - len25, + let e49 = { + let l24 = *ptr0 + .add(16 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l25 = *ptr0 + .add(16 + 2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len26 = l25; + let bytes26 = _rt::Vec::from_raw_parts( + l24.cast(), + len26, + len26, ); - _rt::string_lift(bytes25) + _rt::string_lift(bytes26) }; - Error::Encode(e48) + Error::Encode(e49) } 3 => { - let e48 = { - let l26 = *ptr0.add(20).cast::<*mut u8>(); - let l27 = *ptr0.add(24).cast::(); - let len28 = l27; - let bytes28 = _rt::Vec::from_raw_parts( - l26.cast(), - len28, - len28, + let e49 = { + let l27 = *ptr0 + .add(16 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l28 = *ptr0 + .add(16 + 2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len29 = l28; + let bytes29 = _rt::Vec::from_raw_parts( + l27.cast(), + len29, + len29, ); - _rt::string_lift(bytes28) + _rt::string_lift(bytes29) }; - Error::Decode(e48) + Error::Decode(e49) } 4 => { - let e48 = { - let l29 = *ptr0.add(20).cast::<*mut u8>(); - let l30 = *ptr0.add(24).cast::(); - let len31 = l30; - let bytes31 = _rt::Vec::from_raw_parts( - l29.cast(), - len31, - len31, + let e49 = { + let l30 = *ptr0 + .add(16 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l31 = *ptr0 + .add(16 + 2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len32 = l31; + let bytes32 = _rt::Vec::from_raw_parts( + l30.cast(), + len32, + len32, + ); + let l33 = i32::from( + *ptr0 + .add(16 + 3 * ::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let l34 = i32::from( + *ptr0 + .add(16 + 4 * ::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let l38 = i32::from( + *ptr0 + .add(16 + 7 * ::core::mem::size_of::<*const u8>()) + .cast::(), + ); + let l42 = i32::from( + *ptr0 + .add(16 + 10 * ::core::mem::size_of::<*const u8>()) + .cast::(), ); - let l32 = i32::from(*ptr0.add(28).cast::()); - let l33 = i32::from(*ptr0.add(32).cast::()); - let l37 = i32::from(*ptr0.add(44).cast::()); - let l41 = i32::from(*ptr0.add(56).cast::()); DatabaseError { - message: _rt::string_lift(bytes31), - kind: DatabaseErrorKind::_lift(l32 as u8), - code: match l33 { + message: _rt::string_lift(bytes32), + kind: DatabaseErrorKind::_lift(l33 as u8), + code: match l34 { 0 => None, 1 => { let e = { - let l34 = *ptr0.add(36).cast::<*mut u8>(); - let l35 = *ptr0.add(40).cast::(); - let len36 = l35; - let bytes36 = _rt::Vec::from_raw_parts( - l34.cast(), - len36, - len36, + let l35 = *ptr0 + .add(16 + 5 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l36 = *ptr0 + .add(16 + 6 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len37 = l36; + let bytes37 = _rt::Vec::from_raw_parts( + l35.cast(), + len37, + len37, ); - _rt::string_lift(bytes36) + _rt::string_lift(bytes37) }; Some(e) } _ => _rt::invalid_enum_discriminant(), }, - constraint: match l37 { + constraint: match l38 { 0 => None, 1 => { let e = { - let l38 = *ptr0.add(48).cast::<*mut u8>(); - let l39 = *ptr0.add(52).cast::(); - let len40 = l39; - let bytes40 = _rt::Vec::from_raw_parts( - l38.cast(), - len40, - len40, + let l39 = *ptr0 + .add(16 + 8 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l40 = *ptr0 + .add(16 + 9 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len41 = l40; + let bytes41 = _rt::Vec::from_raw_parts( + l39.cast(), + len41, + len41, ); - _rt::string_lift(bytes40) + _rt::string_lift(bytes41) }; Some(e) } _ => _rt::invalid_enum_discriminant(), }, - table: match l41 { + table: match l42 { 0 => None, 1 => { let e = { - let l42 = *ptr0.add(60).cast::<*mut u8>(); - let l43 = *ptr0.add(64).cast::(); - let len44 = l43; - let bytes44 = _rt::Vec::from_raw_parts( - l42.cast(), - len44, - len44, + let l43 = *ptr0 + .add(16 + 11 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l44 = *ptr0 + .add(16 + 12 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len45 = l44; + let bytes45 = _rt::Vec::from_raw_parts( + l43.cast(), + len45, + len45, ); - _rt::string_lift(bytes44) + _rt::string_lift(bytes45) }; Some(e) } @@ -3803,25 +4279,29 @@ pub mod durable { }, } }; - Error::Database(e48) + Error::Database(e49) } n => { debug_assert_eq!(n, 5, "invalid enum discriminant"); - let e48 = { - let l45 = *ptr0.add(20).cast::<*mut u8>(); - let l46 = *ptr0.add(24).cast::(); - let len47 = l46; - let bytes47 = _rt::Vec::from_raw_parts( - l45.cast(), - len47, - len47, + let e49 = { + let l46 = *ptr0 + .add(16 + 1 * ::core::mem::size_of::<*const u8>()) + .cast::<*mut u8>(); + let l47 = *ptr0 + .add(16 + 2 * ::core::mem::size_of::<*const u8>()) + .cast::(); + let len48 = l47; + let bytes48 = _rt::Vec::from_raw_parts( + l46.cast(), + len48, + len48, ); - _rt::string_lift(bytes47) + _rt::string_lift(bytes48) }; - Error::Other(e48) + Error::Other(e49) } }; - v48 + v49 }; Err(e) } @@ -3831,13 +4311,16 @@ pub mod durable { Some(e) } _ => _rt::invalid_enum_discriminant(), - } + }; + result50 } } } } } +#[rustfmt::skip] mod _rt { + #![allow(dead_code, clippy::all)] use core::fmt; use core::marker; use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; @@ -3870,7 +4353,7 @@ mod _rt { impl Resource { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { - debug_assert!(handle != u32::MAX); + debug_assert!(handle != 0 && handle != u32::MAX); Self { handle: AtomicU32::new(handle), _marker: marker::PhantomData, @@ -3918,7 +4401,7 @@ mod _rt { if cfg!(debug_assertions) { String::from_utf8(bytes).unwrap() } else { - String::from_utf8_unchecked(bytes) + unsafe { String::from_utf8_unchecked(bytes) } } } pub unsafe fn bool_lift(val: u8) -> bool { @@ -3936,15 +4419,17 @@ mod _rt { if cfg!(debug_assertions) { panic!("invalid enum discriminant") } else { - core::hint::unreachable_unchecked() + unsafe { core::hint::unreachable_unchecked() } } } pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { if size == 0 { return; } - let layout = alloc::Layout::from_size_align_unchecked(size, align); - alloc::dealloc(ptr, layout); + unsafe { + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr, layout); + } } pub fn as_f32(t: T) -> f32 { t.as_f32() @@ -4065,9 +4550,13 @@ mod _rt { pub use alloc_crate::alloc; extern crate alloc as alloc_crate; } +#[rustfmt::skip] #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:wit-bindgen:0.30.0:import-sql:encoded world"] +#[unsafe( + link_section = "component-type:wit-bindgen:0.44.0:durable:core@2.7.0:import-sql:encoded world" +)] #[doc(hidden)] +#[allow(clippy::octal_escapes)] pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 4877] = *b"\ \0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\x8c%\x01A\x02\x01A\x02\ \x01B\xfc\x01\x04\0\x09type-info\x03\x01\x01r\x02\x07secondsx\x0csubsec-nanosy\x04\ @@ -4164,9 +4653,9 @@ atic]value.timestamptz-array\x01\x8d\x01\x01@\x01\x05value\xec\0\0\x0f\x04\0\x1d \x05value\xe3\0\x06tyinfo\"\0\x0f\x04\0\x18[static]value.enum-array\x01\x91\x01\x01\ p\x0f\x01@\x03\x03sqls\x06params\x92\x01\x07options\x18\x01\0\x04\0\x05query\x01\ \x93\x01\x01j\x01\x16\x01!\x01k\x94\x01\x01@\0\0\x95\x01\x04\0\x05fetch\x01\x96\x01\ -\x03\x01\x16durable:core/sql@2.5.0\x05\0\x04\x01\x1ddurable:core/import-sql@2.5.\ -0\x04\0\x0b\x10\x01\0\x0aimport-sql\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\ -\x0dwit-component\x070.215.0\x10wit-bindgen-rust\x060.30.0"; +\x03\0\x16durable:core/sql@2.7.0\x05\0\x04\0\x1ddurable:core/import-sql@2.7.0\x04\ +\0\x0b\x10\x01\0\x0aimport-sql\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0d\ +wit-component\x070.236.1\x10wit-bindgen-rust\x060.44.0"; #[inline(never)] #[doc(hidden)] pub fn __link_custom_section_describing_imports() { diff --git a/crates/durable-test-workflows/src/bin/notify-wait-timeout-wakeup.rs b/crates/durable-test-workflows/src/bin/notify-wait-timeout-wakeup.rs new file mode 100644 index 0000000..480c988 --- /dev/null +++ b/crates/durable-test-workflows/src/bin/notify-wait-timeout-wakeup.rs @@ -0,0 +1,12 @@ +use std::time::Duration; + +use durable::notify; + +fn main() { + // Wait with a very long timeout. The test harness will deliver a + // notification while we are blocked here. If the wake-up path works, this + // should return well before the timeout. + let result = notify::wait_with_timeout(Duration::from_secs(120)); + let notif = result.expect("expected to receive a notification before timeout"); + assert_eq!(notif.event, "wakeup"); +} diff --git a/crates/durable-test-workflows/src/bin/notify-wait-timeout.rs b/crates/durable-test-workflows/src/bin/notify-wait-timeout.rs new file mode 100644 index 0000000..7db2a2b --- /dev/null +++ b/crates/durable-test-workflows/src/bin/notify-wait-timeout.rs @@ -0,0 +1,22 @@ +use std::time::Duration; + +use durable::notify; + +fn main() { + // First, attempt a wait with a short timeout that should expire (no + // notification pending). + let result = notify::wait_with_timeout(Duration::from_millis(100)); + assert!(result.is_none(), "expected timeout with no notification"); + + // Now notify ourselves so the next wait_with_timeout will succeed. + let task = durable::task(); + notify::notify(task.id(), "test-event", &"hello timeout").unwrap(); + + // Wait with a generous timeout - should receive the notification. + let result = notify::wait_with_timeout(Duration::from_secs(30)); + let notif = result.expect("expected to receive a notification"); + assert_eq!(notif.event, "test-event"); + + let data: String = notif.json().expect("invalid json data"); + assert_eq!(data, "hello timeout"); +} diff --git a/crates/durable-test/tests/it/dst_notify.rs b/crates/durable-test/tests/it/dst_notify.rs new file mode 100644 index 0000000..1d58b6f --- /dev/null +++ b/crates/durable-test/tests/it/dst_notify.rs @@ -0,0 +1,449 @@ +//! Deterministic simulation tests for `notification_blocking_timeout`. +//! +//! These tests use the DST infrastructure (DstScheduler, DstClock, DstEntropy, +//! DstEventSource) to get precise control over when notifications are +//! delivered, when the clock advances, and when the worker suspends tasks. + +use std::sync::Arc; +use std::time::Duration; + +use anyhow::Context; +use chrono::Utc; +use durable_client::DurableClient; +use durable_runtime::dst::{DstClock, DstEntropy, DstEventSource, DstScheduler}; +use durable_runtime::Config; +use tokio::time::timeout; + +/// With a DST event source that never delivers notification events and a +/// zero suspend timeout, the task should suspend immediately. After we inject +/// a notification via the database (client API) and poke the event source, +/// the task should wake up and complete — well before the workflow's 120s +/// user timeout. +#[sqlx::test] +async fn dst_notify_timeout_suspend_then_wake(pool: sqlx::PgPool) -> anyhow::Result<()> { + let scheduler = Arc::new(DstScheduler::new(42)); + let clock = Arc::new(DstClock::new(Utc::now())); + let entropy = Arc::new(DstEntropy::new(42)); + let (event_source, event_handle) = DstEventSource::new(); + + // Zero suspend timeout: the task will suspend as soon as it enters the + // notification wait loop, freeing the worker slot immediately. + let config = Config::new() + .suspend_margin(Duration::ZERO) + .suspend_timeout(Duration::ZERO); + + let _guard = durable_test::spawn_worker_with_dst_events( + pool.clone(), + config, + scheduler.clone(), + clock.clone(), + entropy.clone(), + Box::new(event_source), + ) + .await?; + + let client = DurableClient::new(pool.clone())?; + let program = crate::load_binary(&client, "notify-wait-timeout-wakeup.wasm").await?; + + let task = client + .launch("dst suspend then wake", &program, &serde_json::json!(null)) + .await?; + + // Inject a task event so the worker picks up the new task. + event_handle.send_task(task.id(), None); + + // Wait for the task to reach the suspended state. The zero suspend timeout + // means it should suspend almost immediately after entering + // notification_blocking_timeout. + let wait_for_suspend = async { + loop { + let suspended = sqlx::query_scalar!( + r#" + SELECT state = 'suspended' as "state!" + FROM durable.task + WHERE id = $1 + "#, + task.id() + ) + .fetch_one(&pool) + .await?; + + if suspended { + break; + } + + tokio::task::yield_now().await; + } + + anyhow::Ok(()) + }; + + timeout(Duration::from_secs(30), wait_for_suspend) + .await + .context("task did not suspend within 30s")??; + + // Now deliver the notification through the database. The DB trigger will + // set the task back to 'ready'. + task.notify("wakeup", &(), &client).await?; + + // Poke the event source so the worker sees the task became ready again. + event_handle.send_task(task.id(), None); + + // The task should replay and complete quickly. + let start = tokio::time::Instant::now(); + let status = timeout(Duration::from_secs(30), task.wait(&client)) + .await + .context("task did not complete within 30s of notification")??; + let elapsed = start.elapsed(); + + assert!(status.success(), "task should have succeeded"); + assert!( + elapsed < Duration::from_secs(15), + "task took {elapsed:?} after notification, expected < 15s" + ); + + Ok(()) +} + +/// With a controlled event source, inject a notification event at a precise +/// moment while the task is actively waiting in +/// `notification_blocking_timeout`. The task should wake up and complete +/// promptly without needing to suspend. +#[sqlx::test] +async fn dst_notify_timeout_wake_before_suspend(pool: sqlx::PgPool) -> anyhow::Result<()> { + let scheduler = Arc::new(DstScheduler::new(42)); + let clock = Arc::new(DstClock::new(Utc::now())); + let entropy = Arc::new(DstEntropy::new(42)); + let (event_source, event_handle) = DstEventSource::new(); + + // Use a long suspend timeout so suspension does NOT happen during this test. + let config = Config::new() + .suspend_margin(Duration::from_secs(1)) + .suspend_timeout(Duration::from_secs(300)); + + let _guard = durable_test::spawn_worker_with_dst_events( + pool.clone(), + config, + scheduler.clone(), + clock.clone(), + entropy.clone(), + Box::new(event_source), + ) + .await?; + + let client = DurableClient::new(pool.clone())?; + let program = crate::load_binary(&client, "notify-wait-timeout-wakeup.wasm").await?; + + let task = client + .launch( + "dst wake before suspend", + &program, + &serde_json::json!(null), + ) + .await?; + + // Tell the worker about the new task. + event_handle.send_task(task.id(), None); + + // Give the task time to start and enter the wait loop. + tokio::time::sleep(Duration::from_secs(2)).await; + + // Insert the notification via the database. + task.notify("wakeup", &(), &client).await?; + + // Inject the notification event through the DST event source so the + // worker's broadcast channel fires immediately. + event_handle.send_notification(task.id(), "wakeup".into()); + + // The task should complete very quickly now. + let start = tokio::time::Instant::now(); + let status = timeout(Duration::from_secs(15), task.wait(&client)) + .await + .context("task did not complete within 15s of notification")??; + let elapsed = start.elapsed(); + + assert!(status.success(), "task should have succeeded"); + assert!( + elapsed < Duration::from_secs(10), + "task took {elapsed:?} after notification, expected < 10s" + ); + + // Verify the task was never suspended — it should have been woken + // directly by the broadcast channel. + let suspend_events: Vec<_> = scheduler + .events() + .iter() + .filter(|e| { + matches!( + e, + durable_runtime::scheduler::ScheduleEvent::TaskSuspended { .. } + ) + }) + .cloned() + .collect(); + // TaskSuspended events for our task should be absent (the scheduler may + // not emit this event at all in the current code, so an empty list is + // fine — the key assertion is the timing above). + let _ = suspend_events; + + Ok(()) +} + +/// With a zero suspend timeout, verify that the task goes through a full +/// suspend → notification → resume → complete cycle, and that the +/// DstScheduler records the expected sequence of events. +#[sqlx::test] +async fn dst_notify_timeout_records_scheduler_events(pool: sqlx::PgPool) -> anyhow::Result<()> { + let scheduler = Arc::new(DstScheduler::new(42)); + let clock = Arc::new(DstClock::new(Utc::now())); + let entropy = Arc::new(DstEntropy::new(42)); + let (event_source, event_handle) = DstEventSource::new(); + + let config = Config::new() + .suspend_margin(Duration::ZERO) + .suspend_timeout(Duration::ZERO); + + let _guard = durable_test::spawn_worker_with_dst_events( + pool.clone(), + config, + scheduler.clone(), + clock.clone(), + entropy.clone(), + Box::new(event_source), + ) + .await?; + + let client = DurableClient::new(pool.clone())?; + let program = crate::load_binary(&client, "notify-wait-timeout-wakeup.wasm").await?; + + let task = client + .launch( + "dst scheduler events test", + &program, + &serde_json::json!(null), + ) + .await?; + + // Kick off the task. + event_handle.send_task(task.id(), None); + + // Wait for the task to become suspended. + timeout(Duration::from_secs(30), async { + loop { + let suspended = sqlx::query_scalar!( + r#" + SELECT state = 'suspended' as "state!" + FROM durable.task + WHERE id = $1 + "#, + task.id() + ) + .fetch_one(&pool) + .await?; + + if suspended { + break; + } + + tokio::task::yield_now().await; + } + + anyhow::Ok(()) + }) + .await + .context("task did not suspend within 30s")??; + + // The scheduler should have recorded a TaskClaimed event for our task. + let claimed = scheduler.events().iter().any(|e| { + matches!(e, durable_runtime::scheduler::ScheduleEvent::TaskClaimed { task_id, .. } if *task_id == task.id()) + }); + assert!(claimed, "expected TaskClaimed event for task {}", task.id()); + + // Now deliver notification and wake the task. + task.notify("wakeup", &(), &client).await?; + event_handle.send_task(task.id(), None); + + let status = timeout(Duration::from_secs(30), task.wait(&client)) + .await + .context("task did not complete within 30s of notification")??; + assert!(status.success()); + + // After completion, TaskClaimed should appear at least twice (initial + // claim + claim after resume from suspension). + let claim_count = scheduler + .events() + .iter() + .filter(|e| { + matches!(e, durable_runtime::scheduler::ScheduleEvent::TaskClaimed { task_id, .. } if *task_id == task.id()) + }) + .count(); + assert!( + claim_count >= 2, + "expected at least 2 TaskClaimed events (initial + after resume), got {claim_count}" + ); + + // TaskCompleted should have fired exactly once. + let complete_count = scheduler + .events() + .iter() + .filter(|e| { + matches!(e, durable_runtime::scheduler::ScheduleEvent::TaskCompleted { task_id, .. } if *task_id == task.id()) + }) + .count(); + assert_eq!( + complete_count, 1, + "expected exactly 1 TaskCompleted event, got {complete_count}" + ); + + Ok(()) +} + +/// When the worker's internal notification broadcast channel lags (more than +/// 128 events buffered before the task's receiver drains them), the +/// `notification_blocking_timeout` implementation handles `RecvError::Lagged` +/// by breaking out of the inner select loop and re-polling the database. +/// +/// This test floods the broadcast channel with notifications for *other* +/// tasks, inserts the real notification into the database, then sends one +/// more event to tip the channel past capacity. The task should recover from +/// the lag, find its notification in the DB, and complete successfully. +#[sqlx::test] +async fn dst_notify_timeout_recovers_from_lag(pool: sqlx::PgPool) -> anyhow::Result<()> { + let scheduler = Arc::new(DstScheduler::new(42)); + let clock = Arc::new(DstClock::new(Utc::now())); + let entropy = Arc::new(DstEntropy::new(42)); + let (event_source, event_handle) = DstEventSource::new(); + + // Long suspend timeout so the task stays active (no suspension). + let config = Config::new() + .suspend_margin(Duration::from_secs(1)) + .suspend_timeout(Duration::from_secs(300)); + + let _guard = durable_test::spawn_worker_with_dst_events( + pool.clone(), + config, + scheduler.clone(), + clock.clone(), + entropy.clone(), + Box::new(event_source), + ) + .await?; + + let client = DurableClient::new(pool.clone())?; + let program = crate::load_binary(&client, "notify-wait-timeout-wakeup.wasm").await?; + + let task = client + .launch("dst lag recovery", &program, &serde_json::json!(null)) + .await?; + + // Tell the worker about the new task. + event_handle.send_task(task.id(), None); + + // Give the task time to start and enter the wait loop, subscribing to + // the broadcast channel. + tokio::time::sleep(Duration::from_secs(2)).await; + + // Insert the real notification into the database so it will be found + // when the task re-polls after recovering from the lag. + task.notify("wakeup", &(), &client).await?; + + // Flood the broadcast channel with 200 notification events for a + // non-existent task. The channel capacity is 128, so the task's + // receiver will lag and return RecvError::Lagged on its next recv(). + for i in 0..200 { + event_handle.send_notification(999_999 + i, format!("flood-{i}")); + } + + // Also deliver the real notification event through the broadcast + // channel. If the flood caused lag, the task will recover via the + // Lagged path and re-poll the database. If it did not cause lag + // (because the worker and task interleaved event processing), this + // event ensures the task still wakes up and finds the notification in + // the database. + event_handle.send_notification(task.id(), "wakeup".into()); + + // The task should find the notification quickly — either through lag + // recovery (re-poll after RecvError::Lagged) or through the normal + // broadcast path. + let start = tokio::time::Instant::now(); + let status = timeout(Duration::from_secs(15), task.wait(&client)) + .await + .context("task did not complete within 15s")??; + let elapsed = start.elapsed(); + + assert!(status.success(), "task should have succeeded"); + assert!( + elapsed < Duration::from_secs(10), + "task took {elapsed:?} after lag flood, expected < 10s" + ); + + Ok(()) +} + +/// Similar to the lag recovery test above, but the notification arrives +/// *after* the lag event. This exercises the path where lag causes a re-poll +/// that finds nothing, the task loops back into the select, and then the +/// real notification arrives normally. +#[sqlx::test] +async fn dst_notify_timeout_recovers_from_lag_then_notified( + pool: sqlx::PgPool, +) -> anyhow::Result<()> { + let scheduler = Arc::new(DstScheduler::new(42)); + let clock = Arc::new(DstClock::new(Utc::now())); + let entropy = Arc::new(DstEntropy::new(42)); + let (event_source, event_handle) = DstEventSource::new(); + + let config = Config::new() + .suspend_margin(Duration::from_secs(1)) + .suspend_timeout(Duration::from_secs(300)); + + let _guard = durable_test::spawn_worker_with_dst_events( + pool.clone(), + config, + scheduler.clone(), + clock.clone(), + entropy.clone(), + Box::new(event_source), + ) + .await?; + + let client = DurableClient::new(pool.clone())?; + let program = crate::load_binary(&client, "notify-wait-timeout-wakeup.wasm").await?; + + let task = client + .launch("dst lag then notify", &program, &serde_json::json!(null)) + .await?; + + event_handle.send_task(task.id(), None); + + // Let the task enter the wait loop. + tokio::time::sleep(Duration::from_secs(2)).await; + + // Flood the broadcast channel to cause lag — but do NOT insert the + // notification into the DB yet. + for i in 0..200 { + event_handle.send_notification(999_999 + i, format!("flood-{i}")); + } + + // Give the task a moment to process the lag and re-poll (finding nothing). + tokio::time::sleep(Duration::from_millis(500)).await; + + // Now insert the real notification and deliver it through the event + // source so the broadcast channel fires normally. + task.notify("wakeup", &(), &client).await?; + event_handle.send_notification(task.id(), "wakeup".into()); + + let start = tokio::time::Instant::now(); + let status = timeout(Duration::from_secs(15), task.wait(&client)) + .await + .context("task did not complete within 15s — recovery after lag may have failed")??; + let elapsed = start.elapsed(); + + assert!(status.success(), "task should have succeeded"); + assert!( + elapsed < Duration::from_secs(10), + "task took {elapsed:?} after notification, expected < 10s" + ); + + Ok(()) +} diff --git a/crates/durable-test/tests/it/main.rs b/crates/durable-test/tests/it/main.rs index 18be088..138749b 100644 --- a/crates/durable-test/tests/it/main.rs +++ b/crates/durable-test/tests/it/main.rs @@ -4,6 +4,7 @@ use anyhow::Context; use durable_client::{DurableClient, Program, ProgramOptions}; mod basic; +mod dst_notify; mod notify; mod shutdown; mod sqlx; diff --git a/crates/durable-test/tests/it/notify.rs b/crates/durable-test/tests/it/notify.rs index f2946c5..80d00f5 100644 --- a/crates/durable-test/tests/it/notify.rs +++ b/crates/durable-test/tests/it/notify.rs @@ -4,6 +4,7 @@ use anyhow::Context; use durable_client::DurableClient; use durable_runtime::Config; use sqlx::postgres::PgListener; +use tokio::time::timeout; #[sqlx::test] async fn notify_self(pool: sqlx::PgPool) -> anyhow::Result<()> { @@ -168,3 +169,150 @@ async fn notify_multiple_workers(pool: sqlx::PgPool) -> anyhow::Result<()> { Ok(()) } + +#[sqlx::test] +async fn notify_wait_timeout(pool: sqlx::PgPool) -> anyhow::Result<()> { + let _guard = durable_test::spawn_worker(pool.clone()).await?; + let client = DurableClient::new(pool)?; + let program = crate::load_binary(&client, "notify-wait-timeout.wasm").await?; + + let task = client + .launch( + "notify wait timeout test", + &program, + &serde_json::json!(null), + ) + .await?; + + let status = match timeout(Duration::from_secs(60), task.wait(&client)).await { + Ok(result) => result?, + Err(_) => anyhow::bail!("task failed to complete in under 60s"), + }; + assert!(status.success()); + + Ok(()) +} + +/// Verify that `wait_with_timeout` wakes up promptly when a notification +/// arrives mid-wait, rather than sleeping until the timeout expires. +#[sqlx::test] +async fn notify_wait_timeout_wakeup(pool: sqlx::PgPool) -> anyhow::Result<()> { + let _guard = durable_test::spawn_worker(pool.clone()).await?; + let client = DurableClient::new(pool)?; + let program = crate::load_binary(&client, "notify-wait-timeout-wakeup.wasm").await?; + + let task = client + .launch( + "notify wait timeout wakeup test", + &program, + &serde_json::json!(null), + ) + .await?; + + // Give the task a moment to start waiting, then deliver the notification. + tokio::time::sleep(Duration::from_secs(2)).await; + task.notify("wakeup", &(), &client).await?; + + // The workflow has a 120s timeout. If wake-up works, it should complete + // well within 15s of us sending the notification. + let start = tokio::time::Instant::now(); + let status = match timeout(Duration::from_secs(15), task.wait(&client)).await { + Ok(result) => result?, + Err(_) => anyhow::bail!( + "task did not complete within 15s of notification — wake-up is not timely" + ), + }; + let elapsed = start.elapsed(); + assert!(status.success()); + + // Sanity check: it should have completed in a few seconds, not anywhere + // near the 120s timeout the workflow specified. + assert!( + elapsed < Duration::from_secs(10), + "task took {elapsed:?} to complete after notification, expected < 10s" + ); + + Ok(()) +} + +/// Verify that `wait_with_timeout` correctly suspends the task when the +/// suspend timeout fires before the user timeout, and that sending a +/// notification after suspension wakes the task up and delivers the result +/// in a timely manner. +#[sqlx::test] +async fn notify_wait_timeout_after_suspend(pool: sqlx::PgPool) -> anyhow::Result<()> { + let client = DurableClient::new(pool.clone())?; + let program = crate::load_binary(&client, "notify-wait-timeout-wakeup.wasm").await?; + + let task = client + .launch( + "notify wait timeout after suspend test", + &program, + &serde_json::json!(null), + ) + .await?; + + // Listen for the task-suspend event so we know when it's actually + // suspended. + let mut listener = PgListener::connect_with(&pool).await?; + listener.listen("durable:task-suspend").await?; + + // Use a zero suspend timeout to force the task to suspend immediately + // rather than holding a worker slot. + let _guard = durable_test::spawn_worker_with( + pool.clone(), + Config::new() + .suspend_margin(Duration::ZERO) + .suspend_timeout(Duration::ZERO), + ) + .await?; + + // Wait until the task is confirmed suspended. + let wait_for_suspend = async { + loop { + let _ = listener.try_recv().await?; + + let suspended = sqlx::query_scalar!( + r#" + SELECT state = 'suspended' as "state!" + FROM durable.task + WHERE id = $1 + "#, + task.id() + ) + .fetch_one(&pool) + .await?; + + if suspended { + break; + } + } + + anyhow::Ok(()) + }; + + tokio::time::timeout(Duration::from_secs(30), wait_for_suspend) + .await + .context("task failed to suspend itself within 30s")??; + + // Now send a notification. The DB trigger should wake the task from + // suspension and a worker should pick it up. + task.notify("wakeup", &(), &client).await?; + + // The workflow specified a 120s user timeout. If the suspend/wake path + // works, the task should complete well within 30s of the notification. + let start = tokio::time::Instant::now(); + let status = tokio::time::timeout(Duration::from_secs(30), task.wait(&client)) + .await + .context("task failed to complete within 30s of notification")?; + let status = status?; + let elapsed = start.elapsed(); + + assert!(status.success()); + assert!( + elapsed < Duration::from_secs(15), + "task took {elapsed:?} to complete after notification, expected < 15s" + ); + + Ok(()) +} diff --git a/crates/durable/src/notify.rs b/crates/durable/src/notify.rs index 34facbf..d5d9c20 100644 --- a/crates/durable/src/notify.rs +++ b/crates/durable/src/notify.rs @@ -10,6 +10,8 @@ //! just needs to arrange for a notification to be posted to the right task, and //! it will pick up where it left off. +use std::time::Duration; + #[doc(inline)] pub use durable_core::notify::{Notification, NotifyError, NotifyErrorKind}; use serde::Serialize; @@ -29,6 +31,18 @@ pub fn wait() -> Notification { durable_core::notify::wait() } +/// Block this workflow until a new notification arrives or the timeout expires. +/// +/// Returns `Some(notification)` if a notification was received before the +/// timeout, or `None` if the timeout expired without receiving a notification. +/// +/// # Traps +/// Attempting to call this function within a transaction will result in a trap +/// that instantly kills the workflow. +pub fn wait_with_timeout(timeout: Duration) -> Option { + durable_core::notify::wait_with_timeout(timeout) +} + /// Send a notification to another durable task. /// /// # Errors