From 66c58693205cdb53cd4d8d35d6d7e4a44d58716a Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Fri, 26 Jul 2024 14:39:17 +0200 Subject: [PATCH 1/6] Improvements --- golem-rust/src/bindings.rs | 4864 ++++++++++++++------- golem-rust/wit/deps.lock | 53 + golem-rust/wit/deps.toml | 1 + golem-rust/wit/deps/all/main.wit | 1 + golem-rust/wit/deps/golem/golem-host.wit | 470 +- golem-rust/wit/deps/wasm-rpc/wasm-rpc.wit | 11 + 6 files changed, 3489 insertions(+), 1911 deletions(-) create mode 100644 golem-rust/wit/deps.lock create mode 100644 golem-rust/wit/deps.toml create mode 100644 golem-rust/wit/deps/all/main.wit diff --git a/golem-rust/src/bindings.rs b/golem-rust/src/bindings.rs index 67a3baa..367fdd2 100644 --- a/golem-rust/src/bindings.rs +++ b/golem-rust/src/bindings.rs @@ -86,7 +86,7 @@ pub mod golem { /// The maximum delay between retries pub max_delay: Duration, /// Multiplier applied to the delay on each retry to implement exponential backoff - pub multiplier: u32, + pub multiplier: f64, } impl ::core::fmt::Debug for RetryPolicy { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { @@ -818,7 +818,7 @@ pub mod golem { } #[allow(unused_unsafe, clippy::all)] /// Create a new promise - pub fn golem_create_promise() -> PromiseId { + pub fn create_promise() -> PromiseId { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit; 32]); @@ -827,7 +827,7 @@ pub mod golem { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "golem:api/host@0.2.0")] extern "C" { - #[link_name = "golem-create-promise"] + #[link_name = "create-promise"] fn wit_import(_: *mut u8); } @@ -860,7 +860,7 @@ pub mod golem { #[allow(unused_unsafe, clippy::all)] /// Suspends execution until the given promise gets completed, and returns the payload passed to /// the promise completion. - pub fn golem_await_promise(promise_id: &PromiseId) -> _rt::Vec { + pub fn await_promise(promise_id: &PromiseId) -> _rt::Vec { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit; 8]); @@ -885,7 +885,7 @@ pub mod golem { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "golem:api/host@0.2.0")] extern "C" { - #[link_name = "golem-await-promise"] + #[link_name = "await-promise"] fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64, _: *mut u8); } @@ -910,7 +910,7 @@ pub mod golem { #[allow(unused_unsafe, clippy::all)] /// Completes the given promise with the given payload. Returns true if the promise was completed, false /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. - pub fn golem_complete_promise(promise_id: &PromiseId, data: &[u8]) -> bool { + pub fn complete_promise(promise_id: &PromiseId, data: &[u8]) -> bool { unsafe { let PromiseId { worker_id: worker_id0, @@ -935,7 +935,7 @@ pub mod golem { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "golem:api/host@0.2.0")] extern "C" { - #[link_name = "golem-complete-promise"] + #[link_name = "complete-promise"] fn wit_import( _: i64, _: i64, @@ -973,7 +973,7 @@ pub mod golem { } #[allow(unused_unsafe, clippy::all)] /// Deletes the given promise - pub fn golem_delete_promise(promise_id: &PromiseId) { + pub fn delete_promise(promise_id: &PromiseId) { unsafe { let PromiseId { worker_id: worker_id0, @@ -995,7 +995,7 @@ pub mod golem { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "golem:api/host@0.2.0")] extern "C" { - #[link_name = "golem-delete-promise"] + #[link_name = "delete-promise"] fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: i64); } @@ -1165,12 +1165,12 @@ pub mod golem { let l1 = *ptr0.add(0).cast::(); let l2 = *ptr0.add(8).cast::(); let l3 = *ptr0.add(16).cast::(); - let l4 = *ptr0.add(24).cast::(); + let l4 = *ptr0.add(24).cast::(); RetryPolicy { max_attempts: l1 as u32, min_delay: l2 as u64, max_delay: l3 as u64, - multiplier: l4 as u32, + multiplier: l4, } } } @@ -1190,18 +1190,18 @@ pub mod golem { #[link(wasm_import_module = "golem:api/host@0.2.0")] extern "C" { #[link_name = "set-retry-policy"] - fn wit_import(_: i32, _: i64, _: i64, _: i32); + fn wit_import(_: i32, _: i64, _: i64, _: f64); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i64, _: i32) { + fn wit_import(_: i32, _: i64, _: i64, _: f64) { unreachable!() } wit_import( _rt::as_i32(max_attempts0), _rt::as_i64(min_delay0), _rt::as_i64(max_delay0), - _rt::as_i32(multiplier0), + _rt::as_f64(multiplier0), ); } } @@ -1373,6 +1373,212 @@ pub mod golem { ); } } + #[allow(unused_unsafe, clippy::all)] + /// Get current worker metadata + pub fn get_self_metadata() -> WorkerMetadata { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 64]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 64]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-self-metadata"] + fn wit_import(_: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *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 base11 = l6; + let len11 = l7; + let mut result11 = _rt::Vec::with_capacity(len11); + for i in 0..len11 { + let base = base11.add(i * 8); + let e11 = { + let l8 = *base.add(0).cast::<*mut u8>(); + let l9 = *base.add(4).cast::(); + let len10 = l9; + let bytes10 = _rt::Vec::from_raw_parts(l8.cast(), len10, len10); + + _rt::string_lift(bytes10) + }; + result11.push(e11); + } + _rt::cabi_dealloc(base11, len11 * 8, 4); + let l12 = *ptr0.add(32).cast::<*mut u8>(); + let l13 = *ptr0.add(36).cast::(); + let base20 = l12; + let len20 = l13; + let mut result20 = _rt::Vec::with_capacity(len20); + for i in 0..len20 { + let base = base20.add(i * 16); + let e20 = { + let l14 = *base.add(0).cast::<*mut u8>(); + let l15 = *base.add(4).cast::(); + let len16 = l15; + let bytes16 = _rt::Vec::from_raw_parts(l14.cast(), len16, len16); + let l17 = *base.add(8).cast::<*mut u8>(); + let l18 = *base.add(12).cast::(); + let len19 = l18; + let bytes19 = _rt::Vec::from_raw_parts(l17.cast(), len19, len19); + + (_rt::string_lift(bytes16), _rt::string_lift(bytes19)) + }; + result20.push(e20); + } + _rt::cabi_dealloc(base20, len20 * 16, 4); + let l21 = i32::from(*ptr0.add(40).cast::()); + let l22 = *ptr0.add(48).cast::(); + let l23 = *ptr0.add(56).cast::(); + WorkerMetadata { + worker_id: WorkerId { + component_id: ComponentId { + uuid: Uuid { + high_bits: l1 as u64, + low_bits: l2 as u64, + }, + }, + worker_name: _rt::string_lift(bytes5), + }, + args: result11, + env: result20, + status: WorkerStatus::_lift(l21 as u8), + component_version: l22 as u64, + retry_count: l23 as u64, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Get worker metadata + pub fn get_worker_metadata(worker_id: &WorkerId) -> Option { + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit; 72]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 72]); + let WorkerId { + component_id: component_id0, + worker_name: worker_name0, + } = worker_id; + let ComponentId { uuid: uuid1 } = component_id0; + let Uuid { + high_bits: high_bits2, + low_bits: low_bits2, + } = uuid1; + let vec3 = worker_name0; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + let ptr4 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:api/host@0.2.0")] + extern "C" { + #[link_name = "get-worker-metadata"] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i64, _: *mut u8, _: usize, _: *mut u8) { + unreachable!() + } + wit_import( + _rt::as_i64(high_bits2), + _rt::as_i64(low_bits2), + ptr3.cast_mut(), + len3, + ptr4, + ); + let l5 = i32::from(*ptr4.add(0).cast::()); + match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr4.add(8).cast::(); + let l7 = *ptr4.add(16).cast::(); + let l8 = *ptr4.add(24).cast::<*mut u8>(); + let l9 = *ptr4.add(28).cast::(); + let len10 = l9; + let bytes10 = _rt::Vec::from_raw_parts(l8.cast(), len10, len10); + let l11 = *ptr4.add(32).cast::<*mut u8>(); + let l12 = *ptr4.add(36).cast::(); + let base16 = l11; + let len16 = l12; + let mut result16 = _rt::Vec::with_capacity(len16); + for i in 0..len16 { + let base = base16.add(i * 8); + let e16 = { + let l13 = *base.add(0).cast::<*mut u8>(); + let l14 = *base.add(4).cast::(); + let len15 = l14; + let bytes15 = + _rt::Vec::from_raw_parts(l13.cast(), len15, len15); + + _rt::string_lift(bytes15) + }; + result16.push(e16); + } + _rt::cabi_dealloc(base16, len16 * 8, 4); + let l17 = *ptr4.add(40).cast::<*mut u8>(); + let l18 = *ptr4.add(44).cast::(); + let base25 = l17; + let len25 = l18; + let mut result25 = _rt::Vec::with_capacity(len25); + for i in 0..len25 { + let base = base25.add(i * 16); + let e25 = { + let l19 = *base.add(0).cast::<*mut u8>(); + let l20 = *base.add(4).cast::(); + let len21 = l20; + let bytes21 = + _rt::Vec::from_raw_parts(l19.cast(), len21, len21); + let l22 = *base.add(8).cast::<*mut u8>(); + let l23 = *base.add(12).cast::(); + let len24 = l23; + let bytes24 = + _rt::Vec::from_raw_parts(l22.cast(), len24, len24); + + (_rt::string_lift(bytes21), _rt::string_lift(bytes24)) + }; + result25.push(e25); + } + _rt::cabi_dealloc(base25, len25 * 16, 4); + let l26 = i32::from(*ptr4.add(48).cast::()); + let l27 = *ptr4.add(56).cast::(); + let l28 = *ptr4.add(64).cast::(); + + WorkerMetadata { + worker_id: WorkerId { + component_id: ComponentId { + uuid: Uuid { + high_bits: l6 as u64, + low_bits: l7 as u64, + }, + }, + worker_name: _rt::string_lift(bytes10), + }, + args: result16, + env: result25, + status: WorkerStatus::_lift(l26 as u8), + component_version: l27 as u64, + retry_count: l28 as u64, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } } } #[allow(dead_code)] @@ -1385,8 +1591,18 @@ pub mod golem { static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; use super::super::super::_rt; + pub type Pollable = super::super::super::wasi::io::poll::Pollable; pub type NodeIndex = i32; #[derive(Clone)] + pub struct Uri { + pub value: _rt::String, + } + impl ::core::fmt::Debug for Uri { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Uri").field("value", &self.value).finish() + } + } + #[derive(Clone)] pub enum WitNode { RecordValue(_rt::Vec), VariantValue((u32, Option)), @@ -1409,6 +1625,7 @@ pub mod golem { PrimChar(char), PrimBool(bool), PrimString(_rt::String), + Handle((Uri, u64)), } impl ::core::fmt::Debug for WitNode { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { @@ -1460,6 +1677,7 @@ pub mod golem { WitNode::PrimString(e) => { f.debug_tuple("WitNode::PrimString").field(e).finish() } + WitNode::Handle(e) => f.debug_tuple("WitNode::Handle").field(e).finish(), } } } @@ -1475,15 +1693,6 @@ pub mod golem { } } #[derive(Clone)] - pub struct Uri { - pub value: _rt::String, - } - impl ::core::fmt::Debug for Uri { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Uri").field("value", &self.value).finish() - } - } - #[derive(Clone)] pub enum RpcError { ProtocolError(_rt::String), Denied(_rt::String), @@ -1559,6 +1768,50 @@ pub mod golem { } } + #[derive(Debug)] + #[repr(transparent)] + pub struct FutureInvokeResult { + handle: _rt::Resource, + } + + impl FutureInvokeResult { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + Self { + handle: _rt::Resource::from_handle(handle), + } + } + + #[doc(hidden)] + pub fn take_handle(&self) -> u32 { + _rt::Resource::take_handle(&self.handle) + } + + #[doc(hidden)] + pub fn handle(&self) -> u32 { + _rt::Resource::handle(&self.handle) + } + } + + unsafe impl _rt::WasmResource for FutureInvokeResult { + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[resource-drop]future-invoke-result"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + impl WasmRpc { #[allow(unused_unsafe, clippy::all)] pub fn new(location: &Uri) -> Self { @@ -1599,14 +1852,14 @@ pub mod golem { let vec0 = function_name; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); - let vec9 = function_params; - let len9 = vec9.len(); - let layout9 = - _rt::alloc::Layout::from_size_align_unchecked(vec9.len() * 8, 4); - let result9 = if layout9.size() != 0 { - let ptr = _rt::alloc::alloc(layout9).cast::(); + let vec12 = function_params; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); if ptr.is_null() { - _rt::alloc::handle_alloc_error(layout9); + _rt::alloc::handle_alloc_error(layout12); } ptr } else { @@ -1614,20 +1867,20 @@ pub mod golem { ::core::ptr::null_mut() } }; - for (i, e) in vec9.into_iter().enumerate() { - let base = result9.add(i * 8); + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 8); { let WitValue { nodes: nodes1 } = e; - let vec8 = nodes1; - let len8 = vec8.len(); - let layout8 = _rt::alloc::Layout::from_size_align_unchecked( - vec8.len() * 24, + let vec11 = nodes1; + let len11 = vec11.len(); + let layout11 = _rt::alloc::Layout::from_size_align_unchecked( + vec11.len() * 24, 8, ); - let result8 = if layout8.size() != 0 { - let ptr = _rt::alloc::alloc(layout8).cast::(); + let result11 = if layout11.size() != 0 { + let ptr = _rt::alloc::alloc(layout11).cast::(); if ptr.is_null() { - _rt::alloc::handle_alloc_error(layout8); + _rt::alloc::handle_alloc_error(layout11); } ptr } else { @@ -1635,8 +1888,8 @@ pub mod golem { ::core::ptr::null_mut() } }; - for (i, e) in vec8.into_iter().enumerate() { - let base = result8.add(i * 24); + for (i, e) in vec11.into_iter().enumerate() { + let base = result11.add(i * 24); { match e { WitNode::RecordValue(e) => { @@ -1828,15 +2081,26 @@ pub mod golem { *base.add(12).cast::() = len7; *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); } + WitNode::Handle(e) => { + *base.add(0).cast::() = (21i32) as u8; + let (t8_0, t8_1) = e; + let Uri { value: value9 } = t8_0; + let vec10 = value9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = ptr10.cast_mut(); + *base.add(16).cast::() = _rt::as_i64(t8_1); + } } } } - *base.add(4).cast::() = len8; - *base.add(0).cast::<*mut u8>() = result8; - cleanup_list.extend_from_slice(&[(result8, layout8)]); + *base.add(4).cast::() = len11; + *base.add(0).cast::<*mut u8>() = result11; + cleanup_list.extend_from_slice(&[(result11, layout11)]); } } - let ptr10 = ret_area.0.as_mut_ptr().cast::(); + let ptr13 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "golem:rpc/types@0.1.0")] extern "C" { @@ -1866,118 +2130,104 @@ pub mod golem { (self).handle() as i32, ptr0.cast_mut(), len0, - result9, - len9, - ptr10, + result12, + len12, + ptr13, ); - let l11 = i32::from(*ptr10.add(0).cast::()); - if layout9.size() != 0 { - _rt::alloc::dealloc(result9.cast(), layout9); + let l14 = i32::from(*ptr13.add(0).cast::()); + if layout12.size() != 0 { + _rt::alloc::dealloc(result12.cast(), layout12); } for (ptr, layout) in cleanup_list { if layout.size() != 0 { _rt::alloc::dealloc(ptr.cast(), layout); } } - match l11 { + match l14 { 0 => { let e = { - let l12 = *ptr10.add(4).cast::<*mut u8>(); - let l13 = *ptr10.add(8).cast::(); - let base55 = l12; - let len55 = l13; - let mut result55 = _rt::Vec::with_capacity(len55); - for i in 0..len55 { - let base = base55.add(i * 24); - let e55 = { - let l14 = i32::from(*base.add(0).cast::()); - let v54 = match l14 { + let l15 = *ptr13.add(4).cast::<*mut u8>(); + let l16 = *ptr13.add(8).cast::(); + let base62 = l15; + let len62 = l16; + let mut result62 = _rt::Vec::with_capacity(len62); + for i in 0..len62 { + let base = base62.add(i * 24); + let e62 = { + let l17 = i32::from(*base.add(0).cast::()); + let v61 = match l17 { 0 => { - let e54 = { - let l15 = *base.add(8).cast::<*mut u8>(); - let l16 = *base.add(12).cast::(); - let len17 = l16; + let e61 = { + let l18 = *base.add(8).cast::<*mut u8>(); + let l19 = *base.add(12).cast::(); + let len20 = l19; _rt::Vec::from_raw_parts( - l15.cast(), - len17, - len17, + l18.cast(), + len20, + len20, ) }; - WitNode::RecordValue(e54) + WitNode::RecordValue(e61) } 1 => { - let e54 = + let e61 = { - let l18 = *base.add(8).cast::(); - let l19 = i32::from( + let l21 = *base.add(8).cast::(); + let l22 = i32::from( *base.add(12).cast::(), ); - (l18 as u32, match l19 { + (l21 as u32, match l22 { 0 => None, 1 => { let e = { - let l20 = *base.add(16).cast::(); + let l23 = *base.add(16).cast::(); - l20 + l23 }; Some(e) } _ => _rt::invalid_enum_discriminant(), }) }; - WitNode::VariantValue(e54) + WitNode::VariantValue(e61) } 2 => { - let e54 = { - let l21 = *base.add(8).cast::(); + let e61 = { + let l24 = *base.add(8).cast::(); - l21 as u32 + l24 as u32 }; - WitNode::EnumValue(e54) + WitNode::EnumValue(e61) } 3 => { - let e54 = { - let l22 = *base.add(8).cast::<*mut u8>(); - let l23 = *base.add(12).cast::(); - let base25 = l22; - let len25 = l23; - let mut result25 = - _rt::Vec::with_capacity(len25); - for i in 0..len25 { - let base = base25.add(i * 1); - let e25 = { - let l24 = i32::from( + let e61 = { + let l25 = *base.add(8).cast::<*mut u8>(); + let l26 = *base.add(12).cast::(); + let base28 = l25; + let len28 = l26; + let mut result28 = + _rt::Vec::with_capacity(len28); + for i in 0..len28 { + let base = base28.add(i * 1); + let e28 = { + let l27 = i32::from( *base.add(0).cast::(), ); - _rt::bool_lift(l24 as u8) + _rt::bool_lift(l27 as u8) }; - result25.push(e25); + result28.push(e28); } - _rt::cabi_dealloc(base25, len25 * 1, 1); + _rt::cabi_dealloc(base28, len28 * 1, 1); - result25 + result28 }; - WitNode::FlagsValue(e54) + WitNode::FlagsValue(e61) } 4 => { - let e54 = { - let l26 = *base.add(8).cast::<*mut u8>(); - let l27 = *base.add(12).cast::(); - let len28 = l27; - - _rt::Vec::from_raw_parts( - l26.cast(), - len28, - len28, - ) - }; - WitNode::TupleValue(e54) - } - 5 => { - let e54 = { + let e61 = { let l29 = *base.add(8).cast::<*mut u8>(); let l30 = *base.add(12).cast::(); let len31 = l30; @@ -1988,48 +2238,62 @@ pub mod golem { len31, ) }; - WitNode::ListValue(e54) + WitNode::TupleValue(e61) + } + 5 => { + let e61 = { + let l32 = *base.add(8).cast::<*mut u8>(); + let l33 = *base.add(12).cast::(); + let len34 = l33; + + _rt::Vec::from_raw_parts( + l32.cast(), + len34, + len34, + ) + }; + WitNode::ListValue(e61) } 6 => { - let e54 = { - let l32 = + let e61 = { + let l35 = i32::from(*base.add(8).cast::()); - match l32 { + match l35 { 0 => None, 1 => { let e = { - let l33 = + let l36 = *base.add(12).cast::(); - l33 + l36 }; Some(e) } _ => _rt::invalid_enum_discriminant(), } }; - WitNode::OptionValue(e54) + WitNode::OptionValue(e61) } 7 => { - let e54 = { - let l34 = + let e61 = { + let l37 = i32::from(*base.add(8).cast::()); - match l34 { + match l37 { 0 => { let e = { - let l35 = i32::from( + let l38 = i32::from( *base.add(12).cast::(), ); - match l35 { + match l38 { 0 => None, 1 => { let e = { - let l36 = *base.add(16).cast::(); + let l39 = *base.add(16).cast::(); - l36 + l39 }; Some(e) } @@ -2040,17 +2304,17 @@ pub mod golem { } 1 => { let e = { - let l37 = i32::from( + let l40 = i32::from( *base.add(12).cast::(), ); - match l37 { + match l40 { 0 => None, 1 => { let e = { - let l38 = *base.add(16).cast::(); + let l41 = *base.add(16).cast::(); - l38 + l41 }; Some(e) } @@ -2062,210 +2326,1439 @@ pub mod golem { _ => _rt::invalid_enum_discriminant(), } }; - WitNode::ResultValue(e54) + WitNode::ResultValue(e61) } 8 => { - let e54 = { - let l39 = + let e61 = { + let l42 = i32::from(*base.add(8).cast::()); - l39 as u8 + l42 as u8 }; - WitNode::PrimU8(e54) + WitNode::PrimU8(e61) } 9 => { - let e54 = { - let l40 = + let e61 = { + let l43 = i32::from(*base.add(8).cast::()); - l40 as u16 + l43 as u16 }; - WitNode::PrimU16(e54) + WitNode::PrimU16(e61) } 10 => { - let e54 = { - let l41 = *base.add(8).cast::(); + let e61 = { + let l44 = *base.add(8).cast::(); - l41 as u32 + l44 as u32 }; - WitNode::PrimU32(e54) + WitNode::PrimU32(e61) } 11 => { - let e54 = { - let l42 = *base.add(8).cast::(); + let e61 = { + let l45 = *base.add(8).cast::(); - l42 as u64 + l45 as u64 }; - WitNode::PrimU64(e54) + WitNode::PrimU64(e61) } 12 => { - let e54 = { - let l43 = + let e61 = { + let l46 = i32::from(*base.add(8).cast::()); - l43 as i8 + l46 as i8 }; - WitNode::PrimS8(e54) + WitNode::PrimS8(e61) } 13 => { - let e54 = { - let l44 = + let e61 = { + let l47 = i32::from(*base.add(8).cast::()); - l44 as i16 + l47 as i16 }; - WitNode::PrimS16(e54) + WitNode::PrimS16(e61) } 14 => { - let e54 = { - let l45 = *base.add(8).cast::(); + let e61 = { + let l48 = *base.add(8).cast::(); - l45 + l48 }; - WitNode::PrimS32(e54) + WitNode::PrimS32(e61) } 15 => { - let e54 = { - let l46 = *base.add(8).cast::(); + let e61 = { + let l49 = *base.add(8).cast::(); - l46 + l49 }; - WitNode::PrimS64(e54) + WitNode::PrimS64(e61) } 16 => { - let e54 = { - let l47 = *base.add(8).cast::(); + let e61 = { + let l50 = *base.add(8).cast::(); - l47 + l50 }; - WitNode::PrimFloat32(e54) + WitNode::PrimFloat32(e61) } 17 => { - let e54 = { - let l48 = *base.add(8).cast::(); + let e61 = { + let l51 = *base.add(8).cast::(); - l48 + l51 }; - WitNode::PrimFloat64(e54) + WitNode::PrimFloat64(e61) } 18 => { - let e54 = { - let l49 = *base.add(8).cast::(); + let e61 = { + let l52 = *base.add(8).cast::(); + + _rt::char_lift(l52 as u32) + }; + WitNode::PrimChar(e61) + } + 19 => { + let e61 = { + let l53 = + i32::from(*base.add(8).cast::()); + + _rt::bool_lift(l53 as u8) + }; + WitNode::PrimBool(e61) + } + 20 => { + let e61 = { + let l54 = *base.add(8).cast::<*mut u8>(); + let l55 = *base.add(12).cast::(); + let len56 = l55; + let bytes56 = _rt::Vec::from_raw_parts( + l54.cast(), + len56, + len56, + ); + + _rt::string_lift(bytes56) + }; + WitNode::PrimString(e61) + } + n => { + debug_assert_eq!( + n, 21, + "invalid enum discriminant" + ); + let e61 = { + let l57 = *base.add(8).cast::<*mut u8>(); + let l58 = *base.add(12).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts( + l57.cast(), + len59, + len59, + ); + let l60 = *base.add(16).cast::(); + + ( + Uri { + value: _rt::string_lift(bytes59), + }, + l60 as u64, + ) + }; + WitNode::Handle(e61) + } + }; + + v61 + }; + result62.push(e62); + } + _rt::cabi_dealloc(base62, len62 * 24, 8); + + WitValue { nodes: result62 } + }; + Ok(e) + } + 1 => { + let e = { + let l63 = i32::from(*ptr13.add(4).cast::()); + let v76 = match l63 { + 0 => { + let e76 = { + let l64 = *ptr13.add(8).cast::<*mut u8>(); + let l65 = *ptr13.add(12).cast::(); + let len66 = l65; + let bytes66 = _rt::Vec::from_raw_parts( + l64.cast(), + len66, + len66, + ); + + _rt::string_lift(bytes66) + }; + RpcError::ProtocolError(e76) + } + 1 => { + let e76 = { + let l67 = *ptr13.add(8).cast::<*mut u8>(); + let l68 = *ptr13.add(12).cast::(); + let len69 = l68; + let bytes69 = _rt::Vec::from_raw_parts( + l67.cast(), + len69, + len69, + ); + + _rt::string_lift(bytes69) + }; + RpcError::Denied(e76) + } + 2 => { + let e76 = { + let l70 = *ptr13.add(8).cast::<*mut u8>(); + let l71 = *ptr13.add(12).cast::(); + let len72 = l71; + let bytes72 = _rt::Vec::from_raw_parts( + l70.cast(), + len72, + len72, + ); + + _rt::string_lift(bytes72) + }; + RpcError::NotFound(e76) + } + n => { + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e76 = { + let l73 = *ptr13.add(8).cast::<*mut u8>(); + let l74 = *ptr13.add(12).cast::(); + let len75 = l74; + let bytes75 = _rt::Vec::from_raw_parts( + l73.cast(), + len75, + len75, + ); + + _rt::string_lift(bytes75) + }; + RpcError::RemoteInternalError(e76) + } + }; + + v76 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn invoke( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> Result<(), RpcError> { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec12 = function_params; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 8); + { + let WitValue { nodes: nodes1 } = e; + let vec11 = nodes1; + let len11 = vec11.len(); + let layout11 = _rt::alloc::Layout::from_size_align_unchecked( + vec11.len() * 24, + 8, + ); + let result11 = if layout11.size() != 0 { + let ptr = _rt::alloc::alloc(layout11).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout11); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec11.into_iter().enumerate() { + let base = result11.add(i * 24); + { + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + } + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } + WitNode::Handle(e) => { + *base.add(0).cast::() = (21i32) as u8; + let (t8_0, t8_1) = e; + let Uri { value: value9 } = t8_0; + let vec10 = value9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = ptr10.cast_mut(); + *base.add(16).cast::() = _rt::as_i64(t8_1); + } + } + } + } + *base.add(4).cast::() = len11; + *base.add(0).cast::<*mut u8>() = result11; + cleanup_list.extend_from_slice(&[(result11, layout11)]); + } + } + let ptr13 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.invoke"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + _: *mut u8, + ) { + unreachable!() + } + wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result12, + len12, + ptr13, + ); + let l14 = i32::from(*ptr13.add(0).cast::()); + if layout12.size() != 0 { + _rt::alloc::dealloc(result12.cast(), layout12); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + match l14 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l15 = i32::from(*ptr13.add(4).cast::()); + let v28 = match l15 { + 0 => { + let e28 = { + let l16 = *ptr13.add(8).cast::<*mut u8>(); + let l17 = *ptr13.add(12).cast::(); + let len18 = l17; + let bytes18 = _rt::Vec::from_raw_parts( + l16.cast(), + len18, + len18, + ); + + _rt::string_lift(bytes18) + }; + RpcError::ProtocolError(e28) + } + 1 => { + let e28 = { + let l19 = *ptr13.add(8).cast::<*mut u8>(); + let l20 = *ptr13.add(12).cast::(); + let len21 = l20; + let bytes21 = _rt::Vec::from_raw_parts( + l19.cast(), + len21, + len21, + ); + + _rt::string_lift(bytes21) + }; + RpcError::Denied(e28) + } + 2 => { + let e28 = { + let l22 = *ptr13.add(8).cast::<*mut u8>(); + let l23 = *ptr13.add(12).cast::(); + let len24 = l23; + let bytes24 = _rt::Vec::from_raw_parts( + l22.cast(), + len24, + len24, + ); + + _rt::string_lift(bytes24) + }; + RpcError::NotFound(e28) + } + n => { + debug_assert_eq!(n, 3, "invalid enum discriminant"); + let e28 = { + let l25 = *ptr13.add(8).cast::<*mut u8>(); + let l26 = *ptr13.add(12).cast::(); + let len27 = l26; + let bytes27 = _rt::Vec::from_raw_parts( + l25.cast(), + len27, + len27, + ); + + _rt::string_lift(bytes27) + }; + RpcError::RemoteInternalError(e28) + } + }; + + v28 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl WasmRpc { + #[allow(unused_unsafe, clippy::all)] + pub fn async_invoke_and_await( + &self, + function_name: &str, + function_params: &[WitValue], + ) -> FutureInvokeResult { + unsafe { + let mut cleanup_list = _rt::Vec::new(); + let vec0 = function_name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec12 = function_params; + let len12 = vec12.len(); + let layout12 = + _rt::alloc::Layout::from_size_align_unchecked(vec12.len() * 8, 4); + let result12 = if layout12.size() != 0 { + let ptr = _rt::alloc::alloc(layout12).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout12); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec12.into_iter().enumerate() { + let base = result12.add(i * 8); + { + let WitValue { nodes: nodes1 } = e; + let vec11 = nodes1; + let len11 = vec11.len(); + let layout11 = _rt::alloc::Layout::from_size_align_unchecked( + vec11.len() * 24, + 8, + ); + let result11 = if layout11.size() != 0 { + let ptr = _rt::alloc::alloc(layout11).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout11); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec11.into_iter().enumerate() { + let base = result11.add(i * 24); + { + match e { + WitNode::RecordValue(e) => { + *base.add(0).cast::() = (0i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + WitNode::VariantValue(e) => { + *base.add(0).cast::() = (1i32) as u8; + let (t3_0, t3_1) = e; + *base.add(8).cast::() = _rt::as_i32(t3_0); + match t3_1 { + Some(e) => { + *base.add(12).cast::() = (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = (0i32) as u8; + } + }; + } + WitNode::EnumValue(e) => { + *base.add(0).cast::() = (2i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::FlagsValue(e) => { + *base.add(0).cast::() = (3i32) as u8; + let vec4 = e; + let len4 = vec4.len(); + let layout4 = + _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 1, + 1, + ); + let result4 = if layout4.size() != 0 { + let ptr = + _rt::alloc::alloc(layout4).cast::(); + if ptr.is_null() { + _rt::alloc::handle_alloc_error(layout4); + } + ptr + } else { + { + ::core::ptr::null_mut() + } + }; + for (i, e) in vec4.into_iter().enumerate() { + let base = result4.add(i * 1); + { + *base.add(0).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + } + *base.add(12).cast::() = len4; + *base.add(8).cast::<*mut u8>() = result4; + cleanup_list + .extend_from_slice(&[(result4, layout4)]); + } + WitNode::TupleValue(e) => { + *base.add(0).cast::() = (4i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *base.add(12).cast::() = len5; + *base.add(8).cast::<*mut u8>() = ptr5.cast_mut(); + } + WitNode::ListValue(e) => { + *base.add(0).cast::() = (5i32) as u8; + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + *base.add(12).cast::() = len6; + *base.add(8).cast::<*mut u8>() = ptr6.cast_mut(); + } + WitNode::OptionValue(e) => { + *base.add(0).cast::() = (6i32) as u8; + match e { + Some(e) => { + *base.add(8).cast::() = (1i32) as u8; + *base.add(12).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(8).cast::() = (0i32) as u8; + } + }; + } + WitNode::ResultValue(e) => { + *base.add(0).cast::() = (7i32) as u8; + match e { + Ok(e) => { + *base.add(8).cast::() = (0i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + Err(e) => { + *base.add(8).cast::() = (1i32) as u8; + match e { + Some(e) => { + *base.add(12).cast::() = + (1i32) as u8; + *base.add(16).cast::() = + _rt::as_i32(e); + } + None => { + *base.add(12).cast::() = + (0i32) as u8; + } + }; + } + }; + } + WitNode::PrimU8(e) => { + *base.add(0).cast::() = (8i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimU16(e) => { + *base.add(0).cast::() = (9i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimU32(e) => { + *base.add(0).cast::() = (10i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimU64(e) => { + *base.add(0).cast::() = (11i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimS8(e) => { + *base.add(0).cast::() = (12i32) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; + } + WitNode::PrimS16(e) => { + *base.add(0).cast::() = (13i32) as u8; + *base.add(8).cast::() = + (_rt::as_i32(e)) as u16; + } + WitNode::PrimS32(e) => { + *base.add(0).cast::() = (14i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimS64(e) => { + *base.add(0).cast::() = (15i32) as u8; + *base.add(8).cast::() = _rt::as_i64(e); + } + WitNode::PrimFloat32(e) => { + *base.add(0).cast::() = (16i32) as u8; + *base.add(8).cast::() = _rt::as_f32(e); + } + WitNode::PrimFloat64(e) => { + *base.add(0).cast::() = (17i32) as u8; + *base.add(8).cast::() = _rt::as_f64(e); + } + WitNode::PrimChar(e) => { + *base.add(0).cast::() = (18i32) as u8; + *base.add(8).cast::() = _rt::as_i32(e); + } + WitNode::PrimBool(e) => { + *base.add(0).cast::() = (19i32) as u8; + *base.add(8).cast::() = (match e { + true => 1, + false => 0, + }) + as u8; + } + WitNode::PrimString(e) => { + *base.add(0).cast::() = (20i32) as u8; + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + *base.add(12).cast::() = len7; + *base.add(8).cast::<*mut u8>() = ptr7.cast_mut(); + } + WitNode::Handle(e) => { + *base.add(0).cast::() = (21i32) as u8; + let (t8_0, t8_1) = e; + let Uri { value: value9 } = t8_0; + let vec10 = value9; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + *base.add(12).cast::() = len10; + *base.add(8).cast::<*mut u8>() = ptr10.cast_mut(); + *base.add(16).cast::() = _rt::as_i64(t8_1); + } + } + } + } + *base.add(4).cast::() = len11; + *base.add(0).cast::<*mut u8>() = result11; + cleanup_list.extend_from_slice(&[(result11, layout11)]); + } + } + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]wasm-rpc.async-invoke-and-await"] + fn wit_import( + _: i32, + _: *mut u8, + _: usize, + _: *mut u8, + _: usize, + ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, _: usize) -> i32 { + unreachable!() + } + let ret = wit_import( + (self).handle() as i32, + ptr0.cast_mut(), + len0, + result12, + len12, + ); + if layout12.size() != 0 { + _rt::alloc::dealloc(result12.cast(), layout12); + } + for (ptr, layout) in cleanup_list { + if layout.size() != 0 { + _rt::alloc::dealloc(ptr.cast(), layout); + } + } + FutureInvokeResult::from_handle(ret as u32) + } + } + } + impl FutureInvokeResult { + #[allow(unused_unsafe, clippy::all)] + pub fn subscribe(&self) -> Pollable { + unsafe { + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]future-invoke-result.subscribe"] + fn wit_import(_: i32) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32) -> i32 { + unreachable!() + } + let ret = wit_import((self).handle() as i32); + super::super::super::wasi::io::poll::Pollable::from_handle(ret as u32) + } + } + } + impl FutureInvokeResult { + #[allow(unused_unsafe, clippy::all)] + pub fn get(&self) -> Option> { + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit; 20]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 20]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "golem:rpc/types@0.1.0")] + extern "C" { + #[link_name = "[method]future-invoke-result.get"] + fn wit_import(_: i32, _: *mut u8); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + + match l2 { + 0 => { + let e = { + let l3 = *ptr0.add(8).cast::<*mut u8>(); + let l4 = *ptr0.add(12).cast::(); + let base50 = l3; + let len50 = l4; + let mut result50 = _rt::Vec::with_capacity(len50); + for i in 0..len50 { + let base = base50.add(i * 24); + let e50 = { + let l5 = + i32::from(*base.add(0).cast::()); + let v49 = match l5 { + 0 => { + let e49 = { + let l6 = *base + .add(8) + .cast::<*mut u8>(); + let l7 = *base + .add(12) + .cast::(); + let len8 = l7; + + _rt::Vec::from_raw_parts( + l6.cast(), + len8, + len8, + ) + }; + WitNode::RecordValue(e49) + } + 1 => { + let e49 = { + let l9 = + *base.add(8).cast::(); + let l10 = i32::from( + *base.add(12).cast::(), + ); + + (l9 as u32, match l10 { + 0 => None, + 1 => { + let e = { + let l11 = *base.add(16).cast::(); + + l11 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }) + }; + WitNode::VariantValue(e49) + } + 2 => { + let e49 = { + let l12 = + *base.add(8).cast::(); + + l12 as u32 + }; + WitNode::EnumValue(e49) + } + 3 => { + let e49 = { + let l13 = *base + .add(8) + .cast::<*mut u8>(); + let l14 = *base + .add(12) + .cast::(); + let base16 = l13; + let len16 = l14; + let mut result16 = + _rt::Vec::with_capacity( + len16, + ); + for i in 0..len16 { + let base = + base16.add(i * 1); + let e16 = { + let l15 = i32::from( + *base + .add(0) + .cast::(), + ); + + _rt::bool_lift( + l15 as u8, + ) + }; + result16.push(e16); + } + _rt::cabi_dealloc( + base16, + len16 * 1, + 1, + ); + + result16 + }; + WitNode::FlagsValue(e49) + } + 4 => { + let e49 = { + let l17 = *base + .add(8) + .cast::<*mut u8>(); + let l18 = *base + .add(12) + .cast::(); + let len19 = l18; + + _rt::Vec::from_raw_parts( + l17.cast(), + len19, + len19, + ) + }; + WitNode::TupleValue(e49) + } + 5 => { + let e49 = { + let l20 = *base + .add(8) + .cast::<*mut u8>(); + let l21 = *base + .add(12) + .cast::(); + let len22 = l21; + + _rt::Vec::from_raw_parts( + l20.cast(), + len22, + len22, + ) + }; + WitNode::ListValue(e49) + } + 6 => { + let e49 = { + let l23 = i32::from( + *base.add(8).cast::(), + ); + + match l23 { + 0 => None, + 1 => { + let e = { + let l24 = *base.add(12).cast::(); + + l24 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::OptionValue(e49) + } + 7 => { + let e49 = { + let l25 = i32::from( + *base.add(8).cast::(), + ); + + match l25 { + 0 => { + let e = { + let l26 = i32::from(*base.add(12).cast::()); + + match l26 { + 0 => None, + 1 => { + let e = { + let l27 = *base.add(16).cast::(); + + l27 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Ok(e) + } + 1 => { + let e = { + let l28 = i32::from(*base.add(12).cast::()); + + match l28 { + 0 => None, + 1 => { + let e = { + let l29 = *base.add(16).cast::(); + + l29 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + WitNode::ResultValue(e49) + } + 8 => { + let e49 = { + let l30 = i32::from( + *base.add(8).cast::(), + ); + + l30 as u8 + }; + WitNode::PrimU8(e49) + } + 9 => { + let e49 = { + let l31 = i32::from( + *base.add(8).cast::(), + ); + + l31 as u16 + }; + WitNode::PrimU16(e49) + } + 10 => { + let e49 = { + let l32 = + *base.add(8).cast::(); + + l32 as u32 + }; + WitNode::PrimU32(e49) + } + 11 => { + let e49 = { + let l33 = + *base.add(8).cast::(); + + l33 as u64 + }; + WitNode::PrimU64(e49) + } + 12 => { + let e49 = { + let l34 = i32::from( + *base.add(8).cast::(), + ); + + l34 as i8 + }; + WitNode::PrimS8(e49) + } + 13 => { + let e49 = { + let l35 = i32::from( + *base.add(8).cast::(), + ); + + l35 as i16 + }; + WitNode::PrimS16(e49) + } + 14 => { + let e49 = { + let l36 = + *base.add(8).cast::(); + + l36 + }; + WitNode::PrimS32(e49) + } + 15 => { + let e49 = { + let l37 = + *base.add(8).cast::(); + + l37 + }; + WitNode::PrimS64(e49) + } + 16 => { + let e49 = { + let l38 = + *base.add(8).cast::(); + + l38 + }; + WitNode::PrimFloat32(e49) + } + 17 => { + let e49 = { + let l39 = + *base.add(8).cast::(); + + l39 + }; + WitNode::PrimFloat64(e49) + } + 18 => { + let e49 = { + let l40 = + *base.add(8).cast::(); - _rt::char_lift(l49 as u32) - }; - WitNode::PrimChar(e54) - } - 19 => { - let e54 = { - let l50 = - i32::from(*base.add(8).cast::()); + _rt::char_lift(l40 as u32) + }; + WitNode::PrimChar(e49) + } + 19 => { + let e49 = { + let l41 = i32::from( + *base.add(8).cast::(), + ); - _rt::bool_lift(l50 as u8) - }; - WitNode::PrimBool(e54) - } - n => { - debug_assert_eq!( - n, 20, - "invalid enum discriminant" - ); - let e54 = { - let l51 = *base.add(8).cast::<*mut u8>(); - let l52 = *base.add(12).cast::(); - let len53 = l52; - let bytes53 = _rt::Vec::from_raw_parts( - l51.cast(), - len53, - len53, - ); + _rt::bool_lift(l41 as u8) + }; + WitNode::PrimBool(e49) + } + 20 => { + let e49 = { + let l42 = *base + .add(8) + .cast::<*mut u8>(); + let l43 = *base + .add(12) + .cast::(); + let len44 = l43; + let bytes44 = + _rt::Vec::from_raw_parts( + l42.cast(), + len44, + len44, + ); + + _rt::string_lift(bytes44) + }; + WitNode::PrimString(e49) + } + n => { + debug_assert_eq!( + n, 21, + "invalid enum discriminant" + ); + let e49 = { + let l45 = *base + .add(8) + .cast::<*mut u8>(); + let l46 = *base + .add(12) + .cast::(); + let len47 = l46; + let bytes47 = + _rt::Vec::from_raw_parts( + l45.cast(), + len47, + len47, + ); + let l48 = + *base.add(16).cast::(); + + ( + Uri { + value: _rt::string_lift( + bytes47, + ), + }, + l48 as u64, + ) + }; + WitNode::Handle(e49) + } + }; - _rt::string_lift(bytes53) + v49 }; - WitNode::PrimString(e54) + result50.push(e50); } - }; - - v54 - }; - result55.push(e55); - } - _rt::cabi_dealloc(base55, len55 * 24, 8); - - WitValue { nodes: result55 } - }; - Ok(e) - } - 1 => { - let e = { - let l56 = i32::from(*ptr10.add(4).cast::()); - let v69 = match l56 { - 0 => { - let e69 = { - let l57 = *ptr10.add(8).cast::<*mut u8>(); - let l58 = *ptr10.add(12).cast::(); - let len59 = l58; - let bytes59 = _rt::Vec::from_raw_parts( - l57.cast(), - len59, - len59, - ); + _rt::cabi_dealloc(base50, len50 * 24, 8); - _rt::string_lift(bytes59) + WitValue { nodes: result50 } }; - RpcError::ProtocolError(e69) + Ok(e) } 1 => { - let e69 = { - let l60 = *ptr10.add(8).cast::<*mut u8>(); - let l61 = *ptr10.add(12).cast::(); - let len62 = l61; - let bytes62 = _rt::Vec::from_raw_parts( - l60.cast(), - len62, - len62, - ); + let e = { + let l51 = i32::from(*ptr0.add(8).cast::()); + let v64 = match l51 { + 0 => { + let e64 = { + let l52 = + *ptr0.add(12).cast::<*mut u8>(); + let l53 = *ptr0.add(16).cast::(); + let len54 = l53; + let bytes54 = _rt::Vec::from_raw_parts( + l52.cast(), + len54, + len54, + ); - _rt::string_lift(bytes62) - }; - RpcError::Denied(e69) - } - 2 => { - let e69 = { - let l63 = *ptr10.add(8).cast::<*mut u8>(); - let l64 = *ptr10.add(12).cast::(); - let len65 = l64; - let bytes65 = _rt::Vec::from_raw_parts( - l63.cast(), - len65, - len65, - ); + _rt::string_lift(bytes54) + }; + RpcError::ProtocolError(e64) + } + 1 => { + let e64 = { + let l55 = + *ptr0.add(12).cast::<*mut u8>(); + let l56 = *ptr0.add(16).cast::(); + let len57 = l56; + let bytes57 = _rt::Vec::from_raw_parts( + l55.cast(), + len57, + len57, + ); - _rt::string_lift(bytes65) - }; - RpcError::NotFound(e69) - } - n => { - debug_assert_eq!(n, 3, "invalid enum discriminant"); - let e69 = { - let l66 = *ptr10.add(8).cast::<*mut u8>(); - let l67 = *ptr10.add(12).cast::(); - let len68 = l67; - let bytes68 = _rt::Vec::from_raw_parts( - l66.cast(), - len68, - len68, - ); + _rt::string_lift(bytes57) + }; + RpcError::Denied(e64) + } + 2 => { + let e64 = { + let l58 = + *ptr0.add(12).cast::<*mut u8>(); + let l59 = *ptr0.add(16).cast::(); + let len60 = l59; + let bytes60 = _rt::Vec::from_raw_parts( + l58.cast(), + len60, + len60, + ); + + _rt::string_lift(bytes60) + }; + RpcError::NotFound(e64) + } + n => { + debug_assert_eq!( + n, 3, + "invalid enum discriminant" + ); + let e64 = { + let l61 = + *ptr0.add(12).cast::<*mut u8>(); + let l62 = *ptr0.add(16).cast::(); + let len63 = l62; + let bytes63 = _rt::Vec::from_raw_parts( + l61.cast(), + len63, + len63, + ); + + _rt::string_lift(bytes63) + }; + RpcError::RemoteInternalError(e64) + } + }; - _rt::string_lift(bytes68) + v64 }; - RpcError::RemoteInternalError(e69) + Err(e) } - }; - - v69 + _ => _rt::invalid_enum_discriminant(), + } }; - Err(e) + Some(e) } _ => _rt::invalid_enum_discriminant(), } @@ -4367,44 +5860,44 @@ pub mod wasi { } pub fn message(&self) -> &'static str { match self { - ErrorCode::Access => "Permission denied, similar to `EACCES` in POSIX.", - ErrorCode::WouldBlock => "Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.", - ErrorCode::Already => "Connection already in progress, similar to `EALREADY` in POSIX.", - ErrorCode::BadDescriptor => "Bad descriptor, similar to `EBADF` in POSIX.", - ErrorCode::Busy => "Device or resource busy, similar to `EBUSY` in POSIX.", - ErrorCode::Deadlock => "Resource deadlock would occur, similar to `EDEADLK` in POSIX.", - ErrorCode::Quota => "Storage quota exceeded, similar to `EDQUOT` in POSIX.", - ErrorCode::Exist => "File exists, similar to `EEXIST` in POSIX.", - ErrorCode::FileTooLarge => "File too large, similar to `EFBIG` in POSIX.", - ErrorCode::IllegalByteSequence => "Illegal byte sequence, similar to `EILSEQ` in POSIX.", - ErrorCode::InProgress => "Operation in progress, similar to `EINPROGRESS` in POSIX.", - ErrorCode::Interrupted => "Interrupted function, similar to `EINTR` in POSIX.", - ErrorCode::Invalid => "Invalid argument, similar to `EINVAL` in POSIX.", - ErrorCode::Io => "I/O error, similar to `EIO` in POSIX.", - ErrorCode::IsDirectory => "Is a directory, similar to `EISDIR` in POSIX.", - ErrorCode::Loop => "Too many levels of symbolic links, similar to `ELOOP` in POSIX.", - ErrorCode::TooManyLinks => "Too many links, similar to `EMLINK` in POSIX.", - ErrorCode::MessageSize => "Message too large, similar to `EMSGSIZE` in POSIX.", - ErrorCode::NameTooLong => "Filename too long, similar to `ENAMETOOLONG` in POSIX.", - ErrorCode::NoDevice => "No such device, similar to `ENODEV` in POSIX.", - ErrorCode::NoEntry => "No such file or directory, similar to `ENOENT` in POSIX.", - ErrorCode::NoLock => "No locks available, similar to `ENOLCK` in POSIX.", - ErrorCode::InsufficientMemory => "Not enough space, similar to `ENOMEM` in POSIX.", - ErrorCode::InsufficientSpace => "No space left on device, similar to `ENOSPC` in POSIX.", - ErrorCode::NotDirectory => "Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.", - ErrorCode::NotEmpty => "Directory not empty, similar to `ENOTEMPTY` in POSIX.", - ErrorCode::NotRecoverable => "State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.", - ErrorCode::Unsupported => "Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.", - ErrorCode::NoTty => "Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.", - ErrorCode::NoSuchDevice => "No such device or address, similar to `ENXIO` in POSIX.", - ErrorCode::Overflow => "Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX.", - ErrorCode::NotPermitted => "Operation not permitted, similar to `EPERM` in POSIX.", - ErrorCode::Pipe => "Broken pipe, similar to `EPIPE` in POSIX.", - ErrorCode::ReadOnly => "Read-only file system, similar to `EROFS` in POSIX.", - ErrorCode::InvalidSeek => "Invalid seek, similar to `ESPIPE` in POSIX.", - ErrorCode::TextFileBusy => "Text file busy, similar to `ETXTBSY` in POSIX.", - ErrorCode::CrossDevice => "Cross-device link, similar to `EXDEV` in POSIX.", - } + ErrorCode::Access => "Permission denied, similar to `EACCES` in POSIX.", + ErrorCode::WouldBlock => "Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX.", + ErrorCode::Already => "Connection already in progress, similar to `EALREADY` in POSIX.", + ErrorCode::BadDescriptor => "Bad descriptor, similar to `EBADF` in POSIX.", + ErrorCode::Busy => "Device or resource busy, similar to `EBUSY` in POSIX.", + ErrorCode::Deadlock => "Resource deadlock would occur, similar to `EDEADLK` in POSIX.", + ErrorCode::Quota => "Storage quota exceeded, similar to `EDQUOT` in POSIX.", + ErrorCode::Exist => "File exists, similar to `EEXIST` in POSIX.", + ErrorCode::FileTooLarge => "File too large, similar to `EFBIG` in POSIX.", + ErrorCode::IllegalByteSequence => "Illegal byte sequence, similar to `EILSEQ` in POSIX.", + ErrorCode::InProgress => "Operation in progress, similar to `EINPROGRESS` in POSIX.", + ErrorCode::Interrupted => "Interrupted function, similar to `EINTR` in POSIX.", + ErrorCode::Invalid => "Invalid argument, similar to `EINVAL` in POSIX.", + ErrorCode::Io => "I/O error, similar to `EIO` in POSIX.", + ErrorCode::IsDirectory => "Is a directory, similar to `EISDIR` in POSIX.", + ErrorCode::Loop => "Too many levels of symbolic links, similar to `ELOOP` in POSIX.", + ErrorCode::TooManyLinks => "Too many links, similar to `EMLINK` in POSIX.", + ErrorCode::MessageSize => "Message too large, similar to `EMSGSIZE` in POSIX.", + ErrorCode::NameTooLong => "Filename too long, similar to `ENAMETOOLONG` in POSIX.", + ErrorCode::NoDevice => "No such device, similar to `ENODEV` in POSIX.", + ErrorCode::NoEntry => "No such file or directory, similar to `ENOENT` in POSIX.", + ErrorCode::NoLock => "No locks available, similar to `ENOLCK` in POSIX.", + ErrorCode::InsufficientMemory => "Not enough space, similar to `ENOMEM` in POSIX.", + ErrorCode::InsufficientSpace => "No space left on device, similar to `ENOSPC` in POSIX.", + ErrorCode::NotDirectory => "Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.", + ErrorCode::NotEmpty => "Directory not empty, similar to `ENOTEMPTY` in POSIX.", + ErrorCode::NotRecoverable => "State not recoverable, similar to `ENOTRECOVERABLE` in POSIX.", + ErrorCode::Unsupported => "Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.", + ErrorCode::NoTty => "Inappropriate I/O control operation, similar to `ENOTTY` in POSIX.", + ErrorCode::NoSuchDevice => "No such device or address, similar to `ENXIO` in POSIX.", + ErrorCode::Overflow => "Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX.", + ErrorCode::NotPermitted => "Operation not permitted, similar to `EPERM` in POSIX.", + ErrorCode::Pipe => "Broken pipe, similar to `EPIPE` in POSIX.", + ErrorCode::ReadOnly => "Read-only file system, similar to `EROFS` in POSIX.", + ErrorCode::InvalidSeek => "Invalid seek, similar to `ESPIPE` in POSIX.", + ErrorCode::TextFileBusy => "Text file busy, similar to `ETXTBSY` in POSIX.", + ErrorCode::CrossDevice => "Cross-device link, similar to `EXDEV` in POSIX.", + } } } impl ::core::fmt::Debug for ErrorCode { @@ -5468,9 +6961,9 @@ pub mod wasi { let l7 = *ptr0.add(48).cast::(); super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l6 as u64, - nanoseconds: l7 as u32, - } + seconds: l6 as u64, + nanoseconds: l7 as u32, + } }; Some(e) } @@ -5484,9 +6977,9 @@ pub mod wasi { let l10 = *ptr0.add(72).cast::(); super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l9 as u64, - nanoseconds: l10 as u32, - } + seconds: l9 as u64, + nanoseconds: l10 as u32, + } }; Some(e) } @@ -5500,9 +6993,9 @@ pub mod wasi { let l13 = *ptr0.add(96).cast::(); super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l12 as u64, - nanoseconds: l13 as u32, - } + seconds: l12 as u64, + nanoseconds: l13 as u32, + } }; Some(e) } @@ -5589,9 +7082,9 @@ pub mod wasi { let l9 = *ptr2.add(48).cast::(); super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l8 as u64, - nanoseconds: l9 as u32, - } + seconds: l8 as u64, + nanoseconds: l9 as u32, + } }; Some(e) } @@ -5605,9 +7098,9 @@ pub mod wasi { let l12 = *ptr2.add(72).cast::(); super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l11 as u64, - nanoseconds: l12 as u32, - } + seconds: l11 as u64, + nanoseconds: l12 as u32, + } }; Some(e) } @@ -5621,9 +7114,9 @@ pub mod wasi { let l15 = *ptr2.add(96).cast::(); super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l14 as u64, - nanoseconds: l15 as u32, - } + seconds: l14 as u64, + nanoseconds: l15 as u32, + } }; Some(e) } @@ -10441,529 +11934,534 @@ pub mod wasi { 0 => None, 1 => { let e = { - let l2 = i32::from(*ptr0.add(8).cast::()); - - match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr0.add(16).cast::()); - - match l3 { - 0 => { - let e = - { - let l4 = i32::from( - *ptr0.add(24).cast::(), - ); - - match l4 { - 0 => None, - 1 => { - let e = { - let l5 = *ptr0.add(28).cast::(); - - Fields::from_handle(l5 as u32) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from( - *ptr0.add(24).cast::(), - ); - let v68 = match l6 { - 0 => { - ErrorCode::DnsTimeout - } - 1 => { - let e68 = { - let l7 = i32::from(*ptr0.add(32).cast::()); - let l11 = i32::from(*ptr0.add(44).cast::()); - - DnsErrorPayload{ - rcode: match l7 { - 0 => None, - 1 => { - let e = { - let l8 = *ptr0.add(36).cast::<*mut u8>(); - let l9 = *ptr0.add(40).cast::(); - let len10 = l9; - let bytes10 = _rt::Vec::from_raw_parts(l8.cast(), len10, len10); - - _rt::string_lift(bytes10) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - info_code: match l11 { - 0 => None, - 1 => { - let e = { - let l12 = i32::from(*ptr0.add(46).cast::()); - - l12 as u16 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::DnsError(e68) - } - 2 => { - ErrorCode::DestinationNotFound - } - 3 => { - ErrorCode::DestinationUnavailable - } - 4 => { - ErrorCode::DestinationIpProhibited - } - 5 => { - ErrorCode::DestinationIpUnroutable - } - 6 => { - ErrorCode::ConnectionRefused - } - 7 => { - ErrorCode::ConnectionTerminated - } - 8 => { - ErrorCode::ConnectionTimeout - } - 9 => { - ErrorCode::ConnectionReadTimeout - } - 10 => { - ErrorCode::ConnectionWriteTimeout - } - 11 => { - ErrorCode::ConnectionLimitReached - } - 12 => { - ErrorCode::TlsProtocolError - } - 13 => { - ErrorCode::TlsCertificateError - } - 14 => { - let e68 = { - let l13 = i32::from(*ptr0.add(32).cast::()); - let l15 = i32::from(*ptr0.add(36).cast::()); - - TlsAlertReceivedPayload{ - alert_id: match l13 { - 0 => None, - 1 => { - let e = { - let l14 = i32::from(*ptr0.add(33).cast::()); - - l14 as u8 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - alert_message: match l15 { - 0 => None, - 1 => { - let e = { - let l16 = *ptr0.add(40).cast::<*mut u8>(); - let l17 = *ptr0.add(44).cast::(); - let len18 = l17; - let bytes18 = _rt::Vec::from_raw_parts(l16.cast(), len18, len18); - - _rt::string_lift(bytes18) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::TlsAlertReceived(e68) - } - 15 => { - ErrorCode::HttpRequestDenied - } - 16 => { - ErrorCode::HttpRequestLengthRequired - } - 17 => { - let e68 = { - let l19 = i32::from(*ptr0.add(32).cast::()); - - match l19 { - 0 => None, - 1 => { - let e = { - let l20 = *ptr0.add(40).cast::(); - - l20 as u64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestBodySize(e68) - } - 18 => { - ErrorCode::HttpRequestMethodInvalid - } - 19 => { - ErrorCode::HttpRequestUriInvalid - } - 20 => { - ErrorCode::HttpRequestUriTooLong - } - 21 => { - let e68 = { - let l21 = i32::from(*ptr0.add(32).cast::()); - - match l21 { - 0 => None, - 1 => { - let e = { - let l22 = *ptr0.add(36).cast::(); - - l22 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSectionSize(e68) - } - 22 => { - let e68 = { - let l23 = i32::from(*ptr0.add(32).cast::()); - - match l23 { - 0 => None, - 1 => { - let e = { - let l24 = i32::from(*ptr0.add(36).cast::()); - let l28 = i32::from(*ptr0.add(48).cast::()); - - FieldSizePayload{ - field_name: match l24 { - 0 => None, - 1 => { - let e = { - let l25 = *ptr0.add(40).cast::<*mut u8>(); - let l26 = *ptr0.add(44).cast::(); - let len27 = l26; - let bytes27 = _rt::Vec::from_raw_parts(l25.cast(), len27, len27); - - _rt::string_lift(bytes27) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l28 { - 0 => None, - 1 => { - let e = { - let l29 = *ptr0.add(52).cast::(); - - l29 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSize(e68) - } - 23 => { - let e68 = { - let l30 = i32::from(*ptr0.add(32).cast::()); - - match l30 { - 0 => None, - 1 => { - let e = { - let l31 = *ptr0.add(36).cast::(); - - l31 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestTrailerSectionSize(e68) - } - 24 => { - let e68 = { - let l32 = i32::from(*ptr0.add(32).cast::()); - let l36 = i32::from(*ptr0.add(44).cast::()); - - FieldSizePayload{ - field_name: match l32 { - 0 => None, - 1 => { - let e = { - let l33 = *ptr0.add(36).cast::<*mut u8>(); - let l34 = *ptr0.add(40).cast::(); - let len35 = l34; - let bytes35 = _rt::Vec::from_raw_parts(l33.cast(), len35, len35); - - _rt::string_lift(bytes35) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l36 { - 0 => None, - 1 => { - let e = { - let l37 = *ptr0.add(48).cast::(); - - l37 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpRequestTrailerSize(e68) - } - 25 => { - ErrorCode::HttpResponseIncomplete - } - 26 => { - let e68 = { - let l38 = i32::from(*ptr0.add(32).cast::()); - - match l38 { - 0 => None, - 1 => { - let e = { - let l39 = *ptr0.add(36).cast::(); - - l39 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseHeaderSectionSize(e68) - } - 27 => { - let e68 = { - let l40 = i32::from(*ptr0.add(32).cast::()); - let l44 = i32::from(*ptr0.add(44).cast::()); - - FieldSizePayload{ - field_name: match l40 { - 0 => None, - 1 => { - let e = { - let l41 = *ptr0.add(36).cast::<*mut u8>(); - let l42 = *ptr0.add(40).cast::(); - let len43 = l42; - let bytes43 = _rt::Vec::from_raw_parts(l41.cast(), len43, len43); - - _rt::string_lift(bytes43) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l44 { - 0 => None, - 1 => { - let e = { - let l45 = *ptr0.add(48).cast::(); - - l45 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseHeaderSize(e68) - } - 28 => { - let e68 = { - let l46 = i32::from(*ptr0.add(32).cast::()); - - match l46 { - 0 => None, - 1 => { - let e = { - let l47 = *ptr0.add(40).cast::(); - - l47 as u64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseBodySize(e68) - } - 29 => { - let e68 = { - let l48 = i32::from(*ptr0.add(32).cast::()); - - match l48 { - 0 => None, - 1 => { - let e = { - let l49 = *ptr0.add(36).cast::(); - - l49 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTrailerSectionSize(e68) - } - 30 => { - let e68 = { - let l50 = i32::from(*ptr0.add(32).cast::()); - let l54 = i32::from(*ptr0.add(44).cast::()); - - FieldSizePayload{ - field_name: match l50 { - 0 => None, - 1 => { - let e = { - let l51 = *ptr0.add(36).cast::<*mut u8>(); - let l52 = *ptr0.add(40).cast::(); - let len53 = l52; - let bytes53 = _rt::Vec::from_raw_parts(l51.cast(), len53, len53); - - _rt::string_lift(bytes53) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l54 { - 0 => None, - 1 => { - let e = { - let l55 = *ptr0.add(48).cast::(); - - l55 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseTrailerSize(e68) - } - 31 => { - let e68 = { - let l56 = i32::from(*ptr0.add(32).cast::()); + let l2 = i32::from(*ptr0.add(8).cast::()); - match l56 { - 0 => None, - 1 => { - let e = { - let l57 = *ptr0.add(36).cast::<*mut u8>(); - let l58 = *ptr0.add(40).cast::(); - let len59 = l58; - let bytes59 = _rt::Vec::from_raw_parts(l57.cast(), len59, len59); - - _rt::string_lift(bytes59) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTransferCoding(e68) - } - 32 => { - let e68 = { - let l60 = i32::from(*ptr0.add(32).cast::()); + match l2 { + 0 => { + let e = { + let l3 = i32::from(*ptr0.add(16).cast::()); - match l60 { - 0 => None, - 1 => { - let e = { - let l61 = *ptr0.add(36).cast::<*mut u8>(); - let l62 = *ptr0.add(40).cast::(); - let len63 = l62; - let bytes63 = _rt::Vec::from_raw_parts(l61.cast(), len63, len63); - - _rt::string_lift(bytes63) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseContentCoding(e68) - } - 33 => { - ErrorCode::HttpResponseTimeout - } - 34 => { - ErrorCode::HttpUpgradeFailed - } - 35 => { - ErrorCode::HttpProtocolError - } - 36 => { - ErrorCode::LoopDetected - } - 37 => { - ErrorCode::ConfigurationError - } - n => { - debug_assert_eq!(n, 38, "invalid enum discriminant"); - let e68 = { - let l64 = i32::from(*ptr0.add(32).cast::()); + match l3 { + 0 => { + let e = { + let l4 = i32::from( + *ptr0.add(24).cast::(), + ); - match l64 { - 0 => None, - 1 => { - let e = { - let l65 = *ptr0.add(36).cast::<*mut u8>(); - let l66 = *ptr0.add(40).cast::(); - let len67 = l66; - let bytes67 = _rt::Vec::from_raw_parts(l65.cast(), len67, len67); - - _rt::string_lift(bytes67) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::InternalError(e68) - } - }; + match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr0 + .add(28) + .cast::(); + + Fields::from_handle( + l5 as u32, + ) + }; + Some(e) + } + _ => { + _rt::invalid_enum_discriminant() + } + } + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from( + *ptr0.add(24).cast::(), + ); + let v68 = match l6 { + 0 => { + ErrorCode::DnsTimeout + } + 1 => { + let e68 = { + let l7 = i32::from(*ptr0.add(32).cast::()); + let l11 = i32::from(*ptr0.add(44).cast::()); + + DnsErrorPayload{ + rcode: match l7 { + 0 => None, + 1 => { + let e = { + let l8 = *ptr0.add(36).cast::<*mut u8>(); + let l9 = *ptr0.add(40).cast::(); + let len10 = l9; + let bytes10 = _rt::Vec::from_raw_parts(l8.cast(), len10, len10); + + _rt::string_lift(bytes10) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + info_code: match l11 { + 0 => None, + 1 => { + let e = { + let l12 = i32::from(*ptr0.add(46).cast::()); + + l12 as u16 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::DnsError(e68) + } + 2 => { + ErrorCode::DestinationNotFound + } + 3 => { + ErrorCode::DestinationUnavailable + } + 4 => { + ErrorCode::DestinationIpProhibited + } + 5 => { + ErrorCode::DestinationIpUnroutable + } + 6 => { + ErrorCode::ConnectionRefused + } + 7 => { + ErrorCode::ConnectionTerminated + } + 8 => { + ErrorCode::ConnectionTimeout + } + 9 => { + ErrorCode::ConnectionReadTimeout + } + 10 => { + ErrorCode::ConnectionWriteTimeout + } + 11 => { + ErrorCode::ConnectionLimitReached + } + 12 => { + ErrorCode::TlsProtocolError + } + 13 => { + ErrorCode::TlsCertificateError + } + 14 => { + let e68 = { + let l13 = i32::from(*ptr0.add(32).cast::()); + let l15 = i32::from(*ptr0.add(36).cast::()); + + TlsAlertReceivedPayload{ + alert_id: match l13 { + 0 => None, + 1 => { + let e = { + let l14 = i32::from(*ptr0.add(33).cast::()); + + l14 as u8 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + alert_message: match l15 { + 0 => None, + 1 => { + let e = { + let l16 = *ptr0.add(40).cast::<*mut u8>(); + let l17 = *ptr0.add(44).cast::(); + let len18 = l17; + let bytes18 = _rt::Vec::from_raw_parts(l16.cast(), len18, len18); + + _rt::string_lift(bytes18) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::TlsAlertReceived(e68) + } + 15 => { + ErrorCode::HttpRequestDenied + } + 16 => { + ErrorCode::HttpRequestLengthRequired + } + 17 => { + let e68 = { + let l19 = i32::from(*ptr0.add(32).cast::()); + + match l19 { + 0 => None, + 1 => { + let e = { + let l20 = *ptr0.add(40).cast::(); + + l20 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestBodySize(e68) + } + 18 => { + ErrorCode::HttpRequestMethodInvalid + } + 19 => { + ErrorCode::HttpRequestUriInvalid + } + 20 => { + ErrorCode::HttpRequestUriTooLong + } + 21 => { + let e68 = { + let l21 = i32::from(*ptr0.add(32).cast::()); + + match l21 { + 0 => None, + 1 => { + let e = { + let l22 = *ptr0.add(36).cast::(); + + l22 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSectionSize(e68) + } + 22 => { + let e68 = { + let l23 = i32::from(*ptr0.add(32).cast::()); + + match l23 { + 0 => None, + 1 => { + let e = { + let l24 = i32::from(*ptr0.add(36).cast::()); + let l28 = i32::from(*ptr0.add(48).cast::()); + + FieldSizePayload{ + field_name: match l24 { + 0 => None, + 1 => { + let e = { + let l25 = *ptr0.add(40).cast::<*mut u8>(); + let l26 = *ptr0.add(44).cast::(); + let len27 = l26; + let bytes27 = _rt::Vec::from_raw_parts(l25.cast(), len27, len27); + + _rt::string_lift(bytes27) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l28 { + 0 => None, + 1 => { + let e = { + let l29 = *ptr0.add(52).cast::(); + + l29 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSize(e68) + } + 23 => { + let e68 = { + let l30 = i32::from(*ptr0.add(32).cast::()); + + match l30 { + 0 => None, + 1 => { + let e = { + let l31 = *ptr0.add(36).cast::(); + + l31 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestTrailerSectionSize(e68) + } + 24 => { + let e68 = { + let l32 = i32::from(*ptr0.add(32).cast::()); + let l36 = i32::from(*ptr0.add(44).cast::()); + + FieldSizePayload{ + field_name: match l32 { + 0 => None, + 1 => { + let e = { + let l33 = *ptr0.add(36).cast::<*mut u8>(); + let l34 = *ptr0.add(40).cast::(); + let len35 = l34; + let bytes35 = _rt::Vec::from_raw_parts(l33.cast(), len35, len35); + + _rt::string_lift(bytes35) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l36 { + 0 => None, + 1 => { + let e = { + let l37 = *ptr0.add(48).cast::(); + + l37 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpRequestTrailerSize(e68) + } + 25 => { + ErrorCode::HttpResponseIncomplete + } + 26 => { + let e68 = { + let l38 = i32::from(*ptr0.add(32).cast::()); + + match l38 { + 0 => None, + 1 => { + let e = { + let l39 = *ptr0.add(36).cast::(); + + l39 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseHeaderSectionSize(e68) + } + 27 => { + let e68 = { + let l40 = i32::from(*ptr0.add(32).cast::()); + let l44 = i32::from(*ptr0.add(44).cast::()); + + FieldSizePayload{ + field_name: match l40 { + 0 => None, + 1 => { + let e = { + let l41 = *ptr0.add(36).cast::<*mut u8>(); + let l42 = *ptr0.add(40).cast::(); + let len43 = l42; + let bytes43 = _rt::Vec::from_raw_parts(l41.cast(), len43, len43); + + _rt::string_lift(bytes43) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l44 { + 0 => None, + 1 => { + let e = { + let l45 = *ptr0.add(48).cast::(); + + l45 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseHeaderSize(e68) + } + 28 => { + let e68 = { + let l46 = i32::from(*ptr0.add(32).cast::()); + + match l46 { + 0 => None, + 1 => { + let e = { + let l47 = *ptr0.add(40).cast::(); + + l47 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseBodySize(e68) + } + 29 => { + let e68 = { + let l48 = i32::from(*ptr0.add(32).cast::()); + + match l48 { + 0 => None, + 1 => { + let e = { + let l49 = *ptr0.add(36).cast::(); + + l49 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTrailerSectionSize(e68) + } + 30 => { + let e68 = { + let l50 = i32::from(*ptr0.add(32).cast::()); + let l54 = i32::from(*ptr0.add(44).cast::()); + + FieldSizePayload{ + field_name: match l50 { + 0 => None, + 1 => { + let e = { + let l51 = *ptr0.add(36).cast::<*mut u8>(); + let l52 = *ptr0.add(40).cast::(); + let len53 = l52; + let bytes53 = _rt::Vec::from_raw_parts(l51.cast(), len53, len53); + + _rt::string_lift(bytes53) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l54 { + 0 => None, + 1 => { + let e = { + let l55 = *ptr0.add(48).cast::(); + + l55 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseTrailerSize(e68) + } + 31 => { + let e68 = { + let l56 = i32::from(*ptr0.add(32).cast::()); + + match l56 { + 0 => None, + 1 => { + let e = { + let l57 = *ptr0.add(36).cast::<*mut u8>(); + let l58 = *ptr0.add(40).cast::(); + let len59 = l58; + let bytes59 = _rt::Vec::from_raw_parts(l57.cast(), len59, len59); + + _rt::string_lift(bytes59) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTransferCoding(e68) + } + 32 => { + let e68 = { + let l60 = i32::from(*ptr0.add(32).cast::()); + + match l60 { + 0 => None, + 1 => { + let e = { + let l61 = *ptr0.add(36).cast::<*mut u8>(); + let l62 = *ptr0.add(40).cast::(); + let len63 = l62; + let bytes63 = _rt::Vec::from_raw_parts(l61.cast(), len63, len63); + + _rt::string_lift(bytes63) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseContentCoding(e68) + } + 33 => { + ErrorCode::HttpResponseTimeout + } + 34 => { + ErrorCode::HttpUpgradeFailed + } + 35 => { + ErrorCode::HttpProtocolError + } + 36 => { + ErrorCode::LoopDetected + } + 37 => { + ErrorCode::ConfigurationError + } + n => { + debug_assert_eq!(n, 38, "invalid enum discriminant"); + let e68 = { + let l64 = i32::from(*ptr0.add(32).cast::()); + + match l64 { + 0 => None, + 1 => { + let e = { + let l65 = *ptr0.add(36).cast::<*mut u8>(); + let l66 = *ptr0.add(40).cast::(); + let len67 = l66; + let bytes67 = _rt::Vec::from_raw_parts(l65.cast(), len67, len67); + + _rt::string_lift(bytes67) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::InternalError(e68) + } + }; v68 }; @@ -11396,34 +12894,34 @@ pub mod wasi { ); FieldSizePayload{ - field_name: match l21 { - 0 => None, - 1 => { - let e = { - let l22 = *ptr1.add(24).cast::<*mut u8>(); - let l23 = *ptr1.add(28).cast::(); - let len24 = l23; - let bytes24 = _rt::Vec::from_raw_parts(l22.cast(), len24, len24); - - _rt::string_lift(bytes24) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l25 { - 0 => None, - 1 => { - let e = { - let l26 = *ptr1.add(36).cast::(); + field_name: match l21 { + 0 => None, + 1 => { + let e = { + let l22 = *ptr1.add(24).cast::<*mut u8>(); + let l23 = *ptr1.add(28).cast::(); + let len24 = l23; + let bytes24 = _rt::Vec::from_raw_parts(l22.cast(), len24, len24); + + _rt::string_lift(bytes24) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l25 { + 0 => None, + 1 => { + let e = { + let l26 = *ptr1.add(36).cast::(); - l26 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } + l26 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } }; Some(e) } @@ -11791,528 +13289,528 @@ pub mod wasi { #[link(wasm_import_module = "wasi:http/types@0.2.0")] extern "C" { #[link_name = "[method]future-incoming-response.get"] - fn wit_import(_: i32, _: *mut u8); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8) { - unreachable!() - } - wit_import((self).handle() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = i32::from(*ptr0.add(8).cast::()); - - match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr0.add(16).cast::()); - - match l3 { - 0 => { - let e = { - let l4 = *ptr0.add(24).cast::(); - - IncomingResponse::from_handle(l4 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from( - *ptr0.add(24).cast::(), - ); - let v67 = match l5 { - 0 => { - ErrorCode::DnsTimeout - } - 1 => { - let e67 = { - let l6 = i32::from(*ptr0.add(32).cast::()); - let l10 = i32::from(*ptr0.add(44).cast::()); - - DnsErrorPayload{ - rcode: match l6 { - 0 => None, - 1 => { - let e = { - let l7 = *ptr0.add(36).cast::<*mut u8>(); - let l8 = *ptr0.add(40).cast::(); - let len9 = l8; - let bytes9 = _rt::Vec::from_raw_parts(l7.cast(), len9, len9); - - _rt::string_lift(bytes9) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - info_code: match l10 { - 0 => None, - 1 => { - let e = { - let l11 = i32::from(*ptr0.add(46).cast::()); - - l11 as u16 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::DnsError(e67) - } - 2 => { - ErrorCode::DestinationNotFound - } - 3 => { - ErrorCode::DestinationUnavailable - } - 4 => { - ErrorCode::DestinationIpProhibited - } - 5 => { - ErrorCode::DestinationIpUnroutable - } - 6 => { - ErrorCode::ConnectionRefused - } - 7 => { - ErrorCode::ConnectionTerminated - } - 8 => { - ErrorCode::ConnectionTimeout - } - 9 => { - ErrorCode::ConnectionReadTimeout - } - 10 => { - ErrorCode::ConnectionWriteTimeout - } - 11 => { - ErrorCode::ConnectionLimitReached - } - 12 => { - ErrorCode::TlsProtocolError - } - 13 => { - ErrorCode::TlsCertificateError - } - 14 => { - let e67 = { - let l12 = i32::from(*ptr0.add(32).cast::()); - let l14 = i32::from(*ptr0.add(36).cast::()); - - TlsAlertReceivedPayload{ - alert_id: match l12 { - 0 => None, - 1 => { - let e = { - let l13 = i32::from(*ptr0.add(33).cast::()); - - l13 as u8 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - alert_message: match l14 { - 0 => None, - 1 => { - let e = { - let l15 = *ptr0.add(40).cast::<*mut u8>(); - let l16 = *ptr0.add(44).cast::(); - let len17 = l16; - let bytes17 = _rt::Vec::from_raw_parts(l15.cast(), len17, len17); - - _rt::string_lift(bytes17) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::TlsAlertReceived(e67) - } - 15 => { - ErrorCode::HttpRequestDenied - } - 16 => { - ErrorCode::HttpRequestLengthRequired - } - 17 => { - let e67 = { - let l18 = i32::from(*ptr0.add(32).cast::()); - - match l18 { - 0 => None, - 1 => { - let e = { - let l19 = *ptr0.add(40).cast::(); - - l19 as u64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestBodySize(e67) - } - 18 => { - ErrorCode::HttpRequestMethodInvalid - } - 19 => { - ErrorCode::HttpRequestUriInvalid - } - 20 => { - ErrorCode::HttpRequestUriTooLong - } - 21 => { - let e67 = { - let l20 = i32::from(*ptr0.add(32).cast::()); - - match l20 { - 0 => None, - 1 => { - let e = { - let l21 = *ptr0.add(36).cast::(); - - l21 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSectionSize(e67) - } - 22 => { - let e67 = { - let l22 = i32::from(*ptr0.add(32).cast::()); - - match l22 { - 0 => None, - 1 => { - let e = { - let l23 = i32::from(*ptr0.add(36).cast::()); - let l27 = i32::from(*ptr0.add(48).cast::()); - - FieldSizePayload{ - field_name: match l23 { - 0 => None, - 1 => { - let e = { - let l24 = *ptr0.add(40).cast::<*mut u8>(); - let l25 = *ptr0.add(44).cast::(); - let len26 = l25; - let bytes26 = _rt::Vec::from_raw_parts(l24.cast(), len26, len26); - - _rt::string_lift(bytes26) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l27 { - 0 => None, - 1 => { - let e = { - let l28 = *ptr0.add(52).cast::(); - - l28 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSize(e67) - } - 23 => { - let e67 = { - let l29 = i32::from(*ptr0.add(32).cast::()); - - match l29 { - 0 => None, - 1 => { - let e = { - let l30 = *ptr0.add(36).cast::(); - - l30 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestTrailerSectionSize(e67) - } - 24 => { - let e67 = { - let l31 = i32::from(*ptr0.add(32).cast::()); - let l35 = i32::from(*ptr0.add(44).cast::()); - - FieldSizePayload{ - field_name: match l31 { - 0 => None, - 1 => { - let e = { - let l32 = *ptr0.add(36).cast::<*mut u8>(); - let l33 = *ptr0.add(40).cast::(); - let len34 = l33; - let bytes34 = _rt::Vec::from_raw_parts(l32.cast(), len34, len34); - - _rt::string_lift(bytes34) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l35 { - 0 => None, - 1 => { - let e = { - let l36 = *ptr0.add(48).cast::(); - - l36 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpRequestTrailerSize(e67) - } - 25 => { - ErrorCode::HttpResponseIncomplete - } - 26 => { - let e67 = { - let l37 = i32::from(*ptr0.add(32).cast::()); - - match l37 { - 0 => None, - 1 => { - let e = { - let l38 = *ptr0.add(36).cast::(); - - l38 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseHeaderSectionSize(e67) - } - 27 => { - let e67 = { - let l39 = i32::from(*ptr0.add(32).cast::()); - let l43 = i32::from(*ptr0.add(44).cast::()); - - FieldSizePayload{ - field_name: match l39 { - 0 => None, - 1 => { - let e = { - let l40 = *ptr0.add(36).cast::<*mut u8>(); - let l41 = *ptr0.add(40).cast::(); - let len42 = l41; - let bytes42 = _rt::Vec::from_raw_parts(l40.cast(), len42, len42); - - _rt::string_lift(bytes42) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l43 { - 0 => None, - 1 => { - let e = { - let l44 = *ptr0.add(48).cast::(); - - l44 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseHeaderSize(e67) - } - 28 => { - let e67 = { - let l45 = i32::from(*ptr0.add(32).cast::()); - - match l45 { - 0 => None, - 1 => { - let e = { - let l46 = *ptr0.add(40).cast::(); - - l46 as u64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseBodySize(e67) - } - 29 => { - let e67 = { - let l47 = i32::from(*ptr0.add(32).cast::()); - - match l47 { - 0 => None, - 1 => { - let e = { - let l48 = *ptr0.add(36).cast::(); - - l48 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTrailerSectionSize(e67) - } - 30 => { - let e67 = { - let l49 = i32::from(*ptr0.add(32).cast::()); - let l53 = i32::from(*ptr0.add(44).cast::()); - - FieldSizePayload{ - field_name: match l49 { - 0 => None, - 1 => { - let e = { - let l50 = *ptr0.add(36).cast::<*mut u8>(); - let l51 = *ptr0.add(40).cast::(); - let len52 = l51; - let bytes52 = _rt::Vec::from_raw_parts(l50.cast(), len52, len52); - - _rt::string_lift(bytes52) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l53 { - 0 => None, - 1 => { - let e = { - let l54 = *ptr0.add(48).cast::(); - - l54 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseTrailerSize(e67) - } - 31 => { - let e67 = { - let l55 = i32::from(*ptr0.add(32).cast::()); + fn wit_import(_: i32, _: *mut u8); + } - match l55 { - 0 => None, - 1 => { - let e = { - let l56 = *ptr0.add(36).cast::<*mut u8>(); - let l57 = *ptr0.add(40).cast::(); - let len58 = l57; - let bytes58 = _rt::Vec::from_raw_parts(l56.cast(), len58, len58); - - _rt::string_lift(bytes58) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTransferCoding(e67) - } - 32 => { - let e67 = { - let l59 = i32::from(*ptr0.add(32).cast::()); + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8) { + unreachable!() + } + wit_import((self).handle() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(8).cast::()); - match l59 { - 0 => None, - 1 => { - let e = { - let l60 = *ptr0.add(36).cast::<*mut u8>(); - let l61 = *ptr0.add(40).cast::(); - let len62 = l61; - let bytes62 = _rt::Vec::from_raw_parts(l60.cast(), len62, len62); - - _rt::string_lift(bytes62) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseContentCoding(e67) - } - 33 => { - ErrorCode::HttpResponseTimeout - } - 34 => { - ErrorCode::HttpUpgradeFailed - } - 35 => { - ErrorCode::HttpProtocolError - } - 36 => { - ErrorCode::LoopDetected - } - 37 => { - ErrorCode::ConfigurationError - } - n => { - debug_assert_eq!(n, 38, "invalid enum discriminant"); - let e67 = { - let l63 = i32::from(*ptr0.add(32).cast::()); + match l2 { + 0 => { + let e = { + let l3 = i32::from(*ptr0.add(16).cast::()); - match l63 { - 0 => None, - 1 => { - let e = { - let l64 = *ptr0.add(36).cast::<*mut u8>(); - let l65 = *ptr0.add(40).cast::(); - let len66 = l65; - let bytes66 = _rt::Vec::from_raw_parts(l64.cast(), len66, len66); - - _rt::string_lift(bytes66) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::InternalError(e67) - } - }; + match l3 { + 0 => { + let e = { + let l4 = *ptr0.add(24).cast::(); + + IncomingResponse::from_handle(l4 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from( + *ptr0.add(24).cast::(), + ); + let v67 = match l5 { + 0 => { + ErrorCode::DnsTimeout + } + 1 => { + let e67 = { + let l6 = i32::from(*ptr0.add(32).cast::()); + let l10 = i32::from(*ptr0.add(44).cast::()); + + DnsErrorPayload{ + rcode: match l6 { + 0 => None, + 1 => { + let e = { + let l7 = *ptr0.add(36).cast::<*mut u8>(); + let l8 = *ptr0.add(40).cast::(); + let len9 = l8; + let bytes9 = _rt::Vec::from_raw_parts(l7.cast(), len9, len9); + + _rt::string_lift(bytes9) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + info_code: match l10 { + 0 => None, + 1 => { + let e = { + let l11 = i32::from(*ptr0.add(46).cast::()); + + l11 as u16 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::DnsError(e67) + } + 2 => { + ErrorCode::DestinationNotFound + } + 3 => { + ErrorCode::DestinationUnavailable + } + 4 => { + ErrorCode::DestinationIpProhibited + } + 5 => { + ErrorCode::DestinationIpUnroutable + } + 6 => { + ErrorCode::ConnectionRefused + } + 7 => { + ErrorCode::ConnectionTerminated + } + 8 => { + ErrorCode::ConnectionTimeout + } + 9 => { + ErrorCode::ConnectionReadTimeout + } + 10 => { + ErrorCode::ConnectionWriteTimeout + } + 11 => { + ErrorCode::ConnectionLimitReached + } + 12 => { + ErrorCode::TlsProtocolError + } + 13 => { + ErrorCode::TlsCertificateError + } + 14 => { + let e67 = { + let l12 = i32::from(*ptr0.add(32).cast::()); + let l14 = i32::from(*ptr0.add(36).cast::()); + + TlsAlertReceivedPayload{ + alert_id: match l12 { + 0 => None, + 1 => { + let e = { + let l13 = i32::from(*ptr0.add(33).cast::()); + + l13 as u8 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + alert_message: match l14 { + 0 => None, + 1 => { + let e = { + let l15 = *ptr0.add(40).cast::<*mut u8>(); + let l16 = *ptr0.add(44).cast::(); + let len17 = l16; + let bytes17 = _rt::Vec::from_raw_parts(l15.cast(), len17, len17); + + _rt::string_lift(bytes17) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::TlsAlertReceived(e67) + } + 15 => { + ErrorCode::HttpRequestDenied + } + 16 => { + ErrorCode::HttpRequestLengthRequired + } + 17 => { + let e67 = { + let l18 = i32::from(*ptr0.add(32).cast::()); + + match l18 { + 0 => None, + 1 => { + let e = { + let l19 = *ptr0.add(40).cast::(); + + l19 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestBodySize(e67) + } + 18 => { + ErrorCode::HttpRequestMethodInvalid + } + 19 => { + ErrorCode::HttpRequestUriInvalid + } + 20 => { + ErrorCode::HttpRequestUriTooLong + } + 21 => { + let e67 = { + let l20 = i32::from(*ptr0.add(32).cast::()); + + match l20 { + 0 => None, + 1 => { + let e = { + let l21 = *ptr0.add(36).cast::(); + + l21 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSectionSize(e67) + } + 22 => { + let e67 = { + let l22 = i32::from(*ptr0.add(32).cast::()); + + match l22 { + 0 => None, + 1 => { + let e = { + let l23 = i32::from(*ptr0.add(36).cast::()); + let l27 = i32::from(*ptr0.add(48).cast::()); + + FieldSizePayload{ + field_name: match l23 { + 0 => None, + 1 => { + let e = { + let l24 = *ptr0.add(40).cast::<*mut u8>(); + let l25 = *ptr0.add(44).cast::(); + let len26 = l25; + let bytes26 = _rt::Vec::from_raw_parts(l24.cast(), len26, len26); + + _rt::string_lift(bytes26) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l27 { + 0 => None, + 1 => { + let e = { + let l28 = *ptr0.add(52).cast::(); + + l28 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSize(e67) + } + 23 => { + let e67 = { + let l29 = i32::from(*ptr0.add(32).cast::()); + + match l29 { + 0 => None, + 1 => { + let e = { + let l30 = *ptr0.add(36).cast::(); + + l30 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestTrailerSectionSize(e67) + } + 24 => { + let e67 = { + let l31 = i32::from(*ptr0.add(32).cast::()); + let l35 = i32::from(*ptr0.add(44).cast::()); + + FieldSizePayload{ + field_name: match l31 { + 0 => None, + 1 => { + let e = { + let l32 = *ptr0.add(36).cast::<*mut u8>(); + let l33 = *ptr0.add(40).cast::(); + let len34 = l33; + let bytes34 = _rt::Vec::from_raw_parts(l32.cast(), len34, len34); + + _rt::string_lift(bytes34) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l35 { + 0 => None, + 1 => { + let e = { + let l36 = *ptr0.add(48).cast::(); + + l36 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpRequestTrailerSize(e67) + } + 25 => { + ErrorCode::HttpResponseIncomplete + } + 26 => { + let e67 = { + let l37 = i32::from(*ptr0.add(32).cast::()); + + match l37 { + 0 => None, + 1 => { + let e = { + let l38 = *ptr0.add(36).cast::(); + + l38 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseHeaderSectionSize(e67) + } + 27 => { + let e67 = { + let l39 = i32::from(*ptr0.add(32).cast::()); + let l43 = i32::from(*ptr0.add(44).cast::()); + + FieldSizePayload{ + field_name: match l39 { + 0 => None, + 1 => { + let e = { + let l40 = *ptr0.add(36).cast::<*mut u8>(); + let l41 = *ptr0.add(40).cast::(); + let len42 = l41; + let bytes42 = _rt::Vec::from_raw_parts(l40.cast(), len42, len42); + + _rt::string_lift(bytes42) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l43 { + 0 => None, + 1 => { + let e = { + let l44 = *ptr0.add(48).cast::(); + + l44 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseHeaderSize(e67) + } + 28 => { + let e67 = { + let l45 = i32::from(*ptr0.add(32).cast::()); + + match l45 { + 0 => None, + 1 => { + let e = { + let l46 = *ptr0.add(40).cast::(); + + l46 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseBodySize(e67) + } + 29 => { + let e67 = { + let l47 = i32::from(*ptr0.add(32).cast::()); + + match l47 { + 0 => None, + 1 => { + let e = { + let l48 = *ptr0.add(36).cast::(); + + l48 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTrailerSectionSize(e67) + } + 30 => { + let e67 = { + let l49 = i32::from(*ptr0.add(32).cast::()); + let l53 = i32::from(*ptr0.add(44).cast::()); + + FieldSizePayload{ + field_name: match l49 { + 0 => None, + 1 => { + let e = { + let l50 = *ptr0.add(36).cast::<*mut u8>(); + let l51 = *ptr0.add(40).cast::(); + let len52 = l51; + let bytes52 = _rt::Vec::from_raw_parts(l50.cast(), len52, len52); + + _rt::string_lift(bytes52) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l53 { + 0 => None, + 1 => { + let e = { + let l54 = *ptr0.add(48).cast::(); + + l54 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseTrailerSize(e67) + } + 31 => { + let e67 = { + let l55 = i32::from(*ptr0.add(32).cast::()); + + match l55 { + 0 => None, + 1 => { + let e = { + let l56 = *ptr0.add(36).cast::<*mut u8>(); + let l57 = *ptr0.add(40).cast::(); + let len58 = l57; + let bytes58 = _rt::Vec::from_raw_parts(l56.cast(), len58, len58); + + _rt::string_lift(bytes58) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTransferCoding(e67) + } + 32 => { + let e67 = { + let l59 = i32::from(*ptr0.add(32).cast::()); + + match l59 { + 0 => None, + 1 => { + let e = { + let l60 = *ptr0.add(36).cast::<*mut u8>(); + let l61 = *ptr0.add(40).cast::(); + let len62 = l61; + let bytes62 = _rt::Vec::from_raw_parts(l60.cast(), len62, len62); + + _rt::string_lift(bytes62) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseContentCoding(e67) + } + 33 => { + ErrorCode::HttpResponseTimeout + } + 34 => { + ErrorCode::HttpUpgradeFailed + } + 35 => { + ErrorCode::HttpProtocolError + } + 36 => { + ErrorCode::LoopDetected + } + 37 => { + ErrorCode::ConfigurationError + } + n => { + debug_assert_eq!(n, 38, "invalid enum discriminant"); + let e67 = { + let l63 = i32::from(*ptr0.add(32).cast::()); + + match l63 { + 0 => None, + 1 => { + let e = { + let l64 = *ptr0.add(36).cast::<*mut u8>(); + let l65 = *ptr0.add(40).cast::(); + let len66 = l65; + let bytes66 = _rt::Vec::from_raw_parts(l64.cast(), len66, len66); + + _rt::string_lift(bytes66) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::InternalError(e67) + } + }; v67 }; @@ -12410,34 +13908,34 @@ pub mod wasi { let l9 = i32::from(*ptr1.add(28).cast::()); super::super::super::wasi::http::types::DnsErrorPayload{ - rcode: match l5 { - 0 => None, - 1 => { - let e = { - let l6 = *ptr1.add(20).cast::<*mut u8>(); - let l7 = *ptr1.add(24).cast::(); - let len8 = l7; - let bytes8 = _rt::Vec::from_raw_parts(l6.cast(), len8, len8); - - _rt::string_lift(bytes8) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - info_code: match l9 { - 0 => None, - 1 => { - let e = { - let l10 = i32::from(*ptr1.add(30).cast::()); + rcode: match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr1.add(20).cast::<*mut u8>(); + let l7 = *ptr1.add(24).cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts(l6.cast(), len8, len8); - l10 as u16 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } + _rt::string_lift(bytes8) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + info_code: match l9 { + 0 => None, + 1 => { + let e = { + let l10 = i32::from(*ptr1.add(30).cast::()); + + l10 as u16 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } }; V66::DnsError(e66) } @@ -12459,34 +13957,34 @@ pub mod wasi { let l13 = i32::from(*ptr1.add(20).cast::()); super::super::super::wasi::http::types::TlsAlertReceivedPayload{ - alert_id: match l11 { - 0 => None, - 1 => { - let e = { - let l12 = i32::from(*ptr1.add(17).cast::()); + alert_id: match l11 { + 0 => None, + 1 => { + let e = { + let l12 = i32::from(*ptr1.add(17).cast::()); - l12 as u8 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - alert_message: match l13 { - 0 => None, - 1 => { - let e = { - let l14 = *ptr1.add(24).cast::<*mut u8>(); - let l15 = *ptr1.add(28).cast::(); - let len16 = l15; - let bytes16 = _rt::Vec::from_raw_parts(l14.cast(), len16, len16); - - _rt::string_lift(bytes16) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } + l12 as u8 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + alert_message: match l13 { + 0 => None, + 1 => { + let e = { + let l14 = *ptr1.add(24).cast::<*mut u8>(); + let l15 = *ptr1.add(28).cast::(); + let len16 = l15; + let bytes16 = _rt::Vec::from_raw_parts(l14.cast(), len16, len16); + + _rt::string_lift(bytes16) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } }; V66::TlsAlertReceived(e66) } @@ -12547,34 +14045,34 @@ pub mod wasi { i32::from(*ptr1.add(32).cast::()); super::super::super::wasi::http::types::FieldSizePayload{ - field_name: match l22 { - 0 => None, - 1 => { - let e = { - let l23 = *ptr1.add(24).cast::<*mut u8>(); - let l24 = *ptr1.add(28).cast::(); - let len25 = l24; - let bytes25 = _rt::Vec::from_raw_parts(l23.cast(), len25, len25); + field_name: match l22 { + 0 => None, + 1 => { + let e = { + let l23 = *ptr1.add(24).cast::<*mut u8>(); + let l24 = *ptr1.add(28).cast::(); + let len25 = l24; + let bytes25 = _rt::Vec::from_raw_parts(l23.cast(), len25, len25); - _rt::string_lift(bytes25) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l26 { - 0 => None, - 1 => { - let e = { - let l27 = *ptr1.add(36).cast::(); + _rt::string_lift(bytes25) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l26 { + 0 => None, + 1 => { + let e = { + let l27 = *ptr1.add(36).cast::(); - l27 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } + l27 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } }; Some(e) } @@ -12608,34 +14106,34 @@ pub mod wasi { let l34 = i32::from(*ptr1.add(28).cast::()); super::super::super::wasi::http::types::FieldSizePayload{ - field_name: match l30 { - 0 => None, - 1 => { - let e = { - let l31 = *ptr1.add(20).cast::<*mut u8>(); - let l32 = *ptr1.add(24).cast::(); - let len33 = l32; - let bytes33 = _rt::Vec::from_raw_parts(l31.cast(), len33, len33); - - _rt::string_lift(bytes33) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l34 { - 0 => None, - 1 => { - let e = { - let l35 = *ptr1.add(32).cast::(); + field_name: match l30 { + 0 => None, + 1 => { + let e = { + let l31 = *ptr1.add(20).cast::<*mut u8>(); + let l32 = *ptr1.add(24).cast::(); + let len33 = l32; + let bytes33 = _rt::Vec::from_raw_parts(l31.cast(), len33, len33); - l35 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } + _rt::string_lift(bytes33) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l34 { + 0 => None, + 1 => { + let e = { + let l35 = *ptr1.add(32).cast::(); + + l35 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } }; V66::HttpRequestTrailerSize(e66) } @@ -12665,34 +14163,34 @@ pub mod wasi { let l42 = i32::from(*ptr1.add(28).cast::()); super::super::super::wasi::http::types::FieldSizePayload{ - field_name: match l38 { - 0 => None, - 1 => { - let e = { - let l39 = *ptr1.add(20).cast::<*mut u8>(); - let l40 = *ptr1.add(24).cast::(); - let len41 = l40; - let bytes41 = _rt::Vec::from_raw_parts(l39.cast(), len41, len41); - - _rt::string_lift(bytes41) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l42 { - 0 => None, - 1 => { - let e = { - let l43 = *ptr1.add(32).cast::(); + field_name: match l38 { + 0 => None, + 1 => { + let e = { + let l39 = *ptr1.add(20).cast::<*mut u8>(); + let l40 = *ptr1.add(24).cast::(); + let len41 = l40; + let bytes41 = _rt::Vec::from_raw_parts(l39.cast(), len41, len41); - l43 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } + _rt::string_lift(bytes41) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l42 { + 0 => None, + 1 => { + let e = { + let l43 = *ptr1.add(32).cast::(); + + l43 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } }; V66::HttpResponseHeaderSize(e66) } @@ -12740,34 +14238,34 @@ pub mod wasi { let l52 = i32::from(*ptr1.add(28).cast::()); super::super::super::wasi::http::types::FieldSizePayload{ - field_name: match l48 { - 0 => None, - 1 => { - let e = { - let l49 = *ptr1.add(20).cast::<*mut u8>(); - let l50 = *ptr1.add(24).cast::(); - let len51 = l50; - let bytes51 = _rt::Vec::from_raw_parts(l49.cast(), len51, len51); - - _rt::string_lift(bytes51) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l52 { - 0 => None, - 1 => { - let e = { - let l53 = *ptr1.add(32).cast::(); + field_name: match l48 { + 0 => None, + 1 => { + let e = { + let l49 = *ptr1.add(20).cast::<*mut u8>(); + let l50 = *ptr1.add(24).cast::(); + let len51 = l50; + let bytes51 = _rt::Vec::from_raw_parts(l49.cast(), len51, len51); - l53 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } + _rt::string_lift(bytes51) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l52 { + 0 => None, + 1 => { + let e = { + let l53 = *ptr1.add(32).cast::(); + + l53 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } }; V66::HttpResponseTrailerSize(e66) } @@ -15650,45 +17148,45 @@ pub mod wasi { } pub fn message(&self) -> &'static str { match self { - ErrorCode::Unknown => "Unknown error", - ErrorCode::AccessDenied => "Access denied. - - POSIX equivalent: EACCES, EPERM", - ErrorCode::NotSupported => "The operation is not supported. - - POSIX equivalent: EOPNOTSUPP", - ErrorCode::InvalidArgument => "One of the arguments is invalid. - - POSIX equivalent: EINVAL", - ErrorCode::OutOfMemory => "Not enough memory to complete the operation. - - POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY", - ErrorCode::Timeout => "The operation timed out before it could finish completely.", - ErrorCode::ConcurrencyConflict => "This operation is incompatible with another asynchronous operation that is already in progress. - - POSIX equivalent: EALREADY", - ErrorCode::NotInProgress => "Trying to finish an asynchronous operation that: - - has not been started yet, or: - - was already finished by a previous `finish-*` call. - - Note: this is scheduled to be removed when `future`s are natively supported.", - ErrorCode::WouldBlock => "The operation has been aborted because it could not be completed immediately. - - Note: this is scheduled to be removed when `future`s are natively supported.", - ErrorCode::InvalidState => "The operation is not valid in the socket's current state.", - ErrorCode::NewSocketLimit => "A new socket resource could not be created because of a system limit.", - ErrorCode::AddressNotBindable => "A bind operation failed because the provided address is not an address that the `network` can bind to.", - ErrorCode::AddressInUse => "A bind operation failed because the provided address is already in use or because there are no ephemeral ports available.", - ErrorCode::RemoteUnreachable => "The remote address is not reachable", - ErrorCode::ConnectionRefused => "The TCP connection was forcefully rejected", - ErrorCode::ConnectionReset => "The TCP connection was reset.", - ErrorCode::ConnectionAborted => "A TCP connection was aborted.", - ErrorCode::DatagramTooLarge => "The size of a datagram sent to a UDP socket exceeded the maximum - supported size.", - ErrorCode::NameUnresolvable => "Name does not exist or has no suitable associated IP addresses.", - ErrorCode::TemporaryResolverFailure => "A temporary failure in name resolution occurred.", - ErrorCode::PermanentResolverFailure => "A permanent failure in name resolution occurred.", - } + ErrorCode::Unknown => "Unknown error", + ErrorCode::AccessDenied => "Access denied. + + POSIX equivalent: EACCES, EPERM", + ErrorCode::NotSupported => "The operation is not supported. + + POSIX equivalent: EOPNOTSUPP", + ErrorCode::InvalidArgument => "One of the arguments is invalid. + + POSIX equivalent: EINVAL", + ErrorCode::OutOfMemory => "Not enough memory to complete the operation. + + POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY", + ErrorCode::Timeout => "The operation timed out before it could finish completely.", + ErrorCode::ConcurrencyConflict => "This operation is incompatible with another asynchronous operation that is already in progress. + + POSIX equivalent: EALREADY", + ErrorCode::NotInProgress => "Trying to finish an asynchronous operation that: + - has not been started yet, or: + - was already finished by a previous `finish-*` call. + + Note: this is scheduled to be removed when `future`s are natively supported.", + ErrorCode::WouldBlock => "The operation has been aborted because it could not be completed immediately. + + Note: this is scheduled to be removed when `future`s are natively supported.", + ErrorCode::InvalidState => "The operation is not valid in the socket's current state.", + ErrorCode::NewSocketLimit => "A new socket resource could not be created because of a system limit.", + ErrorCode::AddressNotBindable => "A bind operation failed because the provided address is not an address that the `network` can bind to.", + ErrorCode::AddressInUse => "A bind operation failed because the provided address is already in use or because there are no ephemeral ports available.", + ErrorCode::RemoteUnreachable => "The remote address is not reachable", + ErrorCode::ConnectionRefused => "The TCP connection was forcefully rejected", + ErrorCode::ConnectionReset => "The TCP connection was reset.", + ErrorCode::ConnectionAborted => "A TCP connection was aborted.", + ErrorCode::DatagramTooLarge => "The size of a datagram sent to a UDP socket exceeded the maximum + supported size.", + ErrorCode::NameUnresolvable => "Name does not exist or has no suitable associated IP addresses.", + ErrorCode::TemporaryResolverFailure => "A temporary failure in name resolution occurred.", + ErrorCode::PermanentResolverFailure => "A permanent failure in name resolution occurred.", + } } } impl ::core::fmt::Debug for ErrorCode { @@ -16161,8 +17659,6 @@ pub mod wasi { } } mod _rt { - pub use alloc_crate::string::String; - pub use alloc_crate::vec::Vec; use core::fmt; use core::marker; @@ -16258,6 +17754,20 @@ mod _rt { } } } + pub unsafe fn bool_lift(val: u8) -> bool { + if cfg!(debug_assertions) { + match val { + 0 => false, + 1 => true, + _ => panic!("invalid bool discriminant"), + } + } else { + val != 0 + } + } + pub use alloc_crate::alloc; + pub use alloc_crate::string::String; + pub use alloc_crate::vec::Vec; pub fn as_i32(t: T) -> i32 { t.as_i32() @@ -16328,7 +17838,6 @@ mod _rt { self as i32 } } - pub use alloc_crate::alloc; pub fn as_i64(t: T) -> i64 { t.as_i64() @@ -16406,17 +17915,6 @@ mod _rt { core::hint::unreachable_unchecked() } } - pub unsafe fn bool_lift(val: u8) -> bool { - if cfg!(debug_assertions) { - match val { - 0 => false, - 1 => true, - _ => panic!("invalid bool discriminant"), - } - } else { - val != 0 - } - } pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { if size == 0 { return; @@ -16444,75 +17942,83 @@ mod _rt { #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.25.0:golem-rust:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 17401] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xf7\x86\x01\x01A\x02\ -\x01AK\x01B\x19\x01z\x04\0\x0anode-index\x03\0\0\x01p\x01\x01k\x01\x01o\x02y\x03\ -\x01p\x7f\x01j\x01\x03\x01\x03\x01q\x15\x0crecord-value\x01\x02\0\x0dvariant-val\ -ue\x01\x04\0\x0aenum-value\x01y\0\x0bflags-value\x01\x05\0\x0btuple-value\x01\x02\ -\0\x0alist-value\x01\x02\0\x0coption-value\x01\x03\0\x0cresult-value\x01\x06\0\x07\ -prim-u8\x01}\0\x08prim-u16\x01{\0\x08prim-u32\x01y\0\x08prim-u64\x01w\0\x07prim-\ -s8\x01~\0\x08prim-s16\x01|\0\x08prim-s32\x01z\0\x08prim-s64\x01x\0\x0cprim-float\ -32\x01v\0\x0cprim-float64\x01u\0\x09prim-char\x01t\0\x09prim-bool\x01\x7f\0\x0bp\ -rim-string\x01s\0\x04\0\x08wit-node\x03\0\x07\x01p\x08\x01r\x01\x05nodes\x09\x04\ -\0\x09wit-value\x03\0\x0a\x01r\x01\x05values\x04\0\x03uri\x03\0\x0c\x01q\x04\x0e\ -protocol-error\x01s\0\x06denied\x01s\0\x09not-found\x01s\0\x15remote-internal-er\ -ror\x01s\0\x04\0\x09rpc-error\x03\0\x0e\x04\0\x08wasm-rpc\x03\x01\x01i\x10\x01@\x01\ -\x08location\x0d\0\x11\x04\0\x15[constructor]wasm-rpc\x01\x12\x01h\x10\x01p\x0b\x01\ -j\x01\x0b\x01\x0f\x01@\x03\x04self\x13\x0dfunction-names\x0ffunction-params\x14\0\ -\x15\x04\0![method]wasm-rpc.invoke-and-await\x01\x16\x03\x01\x15golem:rpc/types@\ -0.1.0\x05\0\x01B\x0a\x04\0\x08pollable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\ -\x04\0\x16[method]pollable.ready\x01\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[me\ -thod]pollable.block\x01\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04pol\ -l\x01\x06\x03\x01\x12wasi:io/poll@0.2.0\x05\x01\x02\x03\0\x01\x08pollable\x01B\x0f\ -\x02\x03\x02\x01\x02\x04\0\x08pollable\x03\0\0\x01w\x04\0\x07instant\x03\0\x02\x01\ -w\x04\0\x08duration\x03\0\x04\x01@\0\0\x03\x04\0\x03now\x01\x06\x01@\0\0\x05\x04\ -\0\x0aresolution\x01\x07\x01i\x01\x01@\x01\x04when\x03\0\x08\x04\0\x11subscribe-\ -instant\x01\x09\x01@\x01\x04when\x05\0\x08\x04\0\x12subscribe-duration\x01\x0a\x03\ -\x01!wasi:clocks/monotonic-clock@0.2.0\x05\x03\x02\x03\0\0\x03uri\x02\x03\0\x02\x08\ -duration\x01Ba\x02\x03\x02\x01\x04\x04\0\x03uri\x03\0\0\x02\x03\x02\x01\x05\x04\0\ -\x08duration\x03\0\x02\x01w\x04\0\x0boplog-index\x03\0\x04\x01w\x04\0\x11compone\ -nt-version\x03\0\x06\x01r\x02\x09high-bitsw\x08low-bitsw\x04\0\x04uuid\x03\0\x08\ -\x01r\x01\x04uuid\x09\x04\0\x0ccomponent-id\x03\0\x0a\x01r\x02\x0ccomponent-id\x0b\ -\x0bworker-names\x04\0\x09worker-id\x03\0\x0c\x01r\x02\x09worker-id\x0d\x09oplog\ --idx\x05\x04\0\x0apromise-id\x03\0\x0e\x01r\x04\x0cmax-attemptsy\x09min-delay\x03\ -\x09max-delay\x03\x0amultipliery\x04\0\x0cretry-policy\x03\0\x10\x01q\x03\x0fper\ -sist-nothing\0\0\x1bpersist-remote-side-effects\0\0\x05smart\0\0\x04\0\x11persis\ -tence-level\x03\0\x12\x01m\x02\x09automatic\x0esnapshot-based\x04\0\x0bupdate-mo\ -de\x03\0\x14\x01m\x06\x05equal\x09not-equal\x0dgreater-equal\x07greater\x0aless-\ -equal\x04less\x04\0\x11filter-comparator\x03\0\x16\x01m\x04\x05equal\x09not-equa\ -l\x04like\x08not-like\x04\0\x18string-filter-comparator\x03\0\x18\x01m\x07\x07ru\ -nning\x04idle\x09suspended\x0binterrupted\x08retrying\x06failed\x06exited\x04\0\x0d\ -worker-status\x03\0\x1a\x01r\x02\x0acomparator\x19\x05values\x04\0\x12worker-nam\ -e-filter\x03\0\x1c\x01r\x02\x0acomparator\x17\x05value\x1b\x04\0\x14worker-statu\ -s-filter\x03\0\x1e\x01r\x02\x0acomparator\x17\x05valuew\x04\0\x15worker-version-\ -filter\x03\0\x20\x01r\x02\x0acomparator\x17\x05valuew\x04\0\x18worker-created-at\ --filter\x03\0\"\x01r\x03\x04names\x0acomparator\x19\x05values\x04\0\x11worker-en\ -v-filter\x03\0$\x01q\x05\x04name\x01\x1d\0\x06status\x01\x1f\0\x07version\x01!\0\ -\x0acreated-at\x01#\0\x03env\x01%\0\x04\0\x16worker-property-filter\x03\0&\x01p'\ -\x01r\x01\x07filters(\x04\0\x11worker-all-filter\x03\0)\x01p*\x01r\x01\x07filter\ -s+\x04\0\x11worker-any-filter\x03\0,\x01ps\x01o\x02ss\x01p/\x01r\x06\x09worker-i\ -d\x0d\x04args.\x03env0\x06status\x1b\x11component-versionw\x0bretry-countw\x04\0\ -\x0fworker-metadata\x03\01\x04\0\x0bget-workers\x03\x01\x01k-\x01i3\x01@\x03\x0c\ -component-id\x0b\x06filter4\x07precise\x7f\05\x04\0\x18[constructor]get-workers\x01\ -6\x01h3\x01p2\x01k8\x01@\x01\x04self7\09\x04\0\x1c[method]get-workers.get-next\x01\ -:\x01@\0\0\x0f\x04\0\x14golem-create-promise\x01;\x01p}\x01@\x01\x0apromise-id\x0f\ -\0<\x04\0\x13golem-await-promise\x01=\x01@\x02\x0apromise-id\x0f\x04data<\0\x7f\x04\ -\0\x16golem-complete-promise\x01>\x01@\x01\x0apromise-id\x0f\x01\0\x04\0\x14gole\ -m-delete-promise\x01?\x01@\x01\x0dfunction-names\0\x01\x04\0\x0cget-self-uri\x01\ -@\x01@\0\0\x05\x04\0\x0fget-oplog-index\x01A\x01@\x01\x09oplog-idx\x05\x01\0\x04\ -\0\x0fset-oplog-index\x01B\x01@\x01\x08replicas}\x01\0\x04\0\x0coplog-commit\x01\ -C\x04\0\x14mark-begin-operation\x01A\x01@\x01\x05begin\x05\x01\0\x04\0\x12mark-e\ -nd-operation\x01D\x01@\0\0\x11\x04\0\x10get-retry-policy\x01E\x01@\x01\x10new-re\ -try-policy\x11\x01\0\x04\0\x10set-retry-policy\x01F\x01@\0\0\x13\x04\0\x1bget-op\ -log-persistence-level\x01G\x01@\x01\x15new-persistence-level\x13\x01\0\x04\0\x1b\ -set-oplog-persistence-level\x01H\x01@\0\0\x7f\x04\0\x14get-idempotence-mode\x01I\ -\x01@\x01\x0aidempotent\x7f\x01\0\x04\0\x14set-idempotence-mode\x01J\x01@\0\0\x09\ -\x04\0\x18generate-idempotency-key\x01K\x01@\x03\x09worker-id\x0d\x0etarget-vers\ -ion\x07\x04mode\x15\x01\0\x04\0\x0dupdate-worker\x01L\x03\x01\x14golem:api/host@\ -0.2.0\x05\x06\x01B\x04\x04\0\x05error\x03\x01\x01h\0\x01@\x01\x04self\x01\0s\x04\ -\0\x1d[method]error.to-debug-string\x01\x02\x03\x01\x13wasi:io/error@0.2.0\x05\x07\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 17784] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xf6\x89\x01\x01A\x02\ +\x01AK\x01B\x0a\x04\0\x08pollable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\x04\0\ +\x16[method]pollable.ready\x01\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[method]p\ +ollable.block\x01\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04poll\x01\x06\ +\x03\x01\x12wasi:io/poll@0.2.0\x05\0\x02\x03\0\0\x08pollable\x01B*\x02\x03\x02\x01\ +\x01\x04\0\x08pollable\x03\0\0\x01z\x04\0\x0anode-index\x03\0\x02\x01r\x01\x05va\ +lues\x04\0\x03uri\x03\0\x04\x01p\x03\x01k\x03\x01o\x02y\x07\x01p\x7f\x01j\x01\x07\ +\x01\x07\x01o\x02\x05w\x01q\x16\x0crecord-value\x01\x06\0\x0dvariant-value\x01\x08\ +\0\x0aenum-value\x01y\0\x0bflags-value\x01\x09\0\x0btuple-value\x01\x06\0\x0alis\ +t-value\x01\x06\0\x0coption-value\x01\x07\0\x0cresult-value\x01\x0a\0\x07prim-u8\ +\x01}\0\x08prim-u16\x01{\0\x08prim-u32\x01y\0\x08prim-u64\x01w\0\x07prim-s8\x01~\ +\0\x08prim-s16\x01|\0\x08prim-s32\x01z\0\x08prim-s64\x01x\0\x0cprim-float32\x01v\ +\0\x0cprim-float64\x01u\0\x09prim-char\x01t\0\x09prim-bool\x01\x7f\0\x0bprim-str\ +ing\x01s\0\x06handle\x01\x0b\0\x04\0\x08wit-node\x03\0\x0c\x01p\x0d\x01r\x01\x05\ +nodes\x0e\x04\0\x09wit-value\x03\0\x0f\x01q\x04\x0eprotocol-error\x01s\0\x06deni\ +ed\x01s\0\x09not-found\x01s\0\x15remote-internal-error\x01s\0\x04\0\x09rpc-error\ +\x03\0\x11\x04\0\x08wasm-rpc\x03\x01\x04\0\x14future-invoke-result\x03\x01\x01i\x13\ +\x01@\x01\x08location\x05\0\x15\x04\0\x15[constructor]wasm-rpc\x01\x16\x01h\x13\x01\ +p\x10\x01j\x01\x10\x01\x12\x01@\x03\x04self\x17\x0dfunction-names\x0ffunction-pa\ +rams\x18\0\x19\x04\0![method]wasm-rpc.invoke-and-await\x01\x1a\x01j\0\x01\x12\x01\ +@\x03\x04self\x17\x0dfunction-names\x0ffunction-params\x18\0\x1b\x04\0\x17[metho\ +d]wasm-rpc.invoke\x01\x1c\x01i\x14\x01@\x03\x04self\x17\x0dfunction-names\x0ffun\ +ction-params\x18\0\x1d\x04\0'[method]wasm-rpc.async-invoke-and-await\x01\x1e\x01\ +h\x14\x01i\x01\x01@\x01\x04self\x1f\0\x20\x04\0&[method]future-invoke-result.sub\ +scribe\x01!\x01k\x19\x01@\x01\x04self\x1f\0\"\x04\0\x20[method]future-invoke-res\ +ult.get\x01#\x03\x01\x15golem:rpc/types@0.1.0\x05\x02\x01B\x0f\x02\x03\x02\x01\x01\ +\x04\0\x08pollable\x03\0\0\x01w\x04\0\x07instant\x03\0\x02\x01w\x04\0\x08duratio\ +n\x03\0\x04\x01@\0\0\x03\x04\0\x03now\x01\x06\x01@\0\0\x05\x04\0\x0aresolution\x01\ +\x07\x01i\x01\x01@\x01\x04when\x03\0\x08\x04\0\x11subscribe-instant\x01\x09\x01@\ +\x01\x04when\x05\0\x08\x04\0\x12subscribe-duration\x01\x0a\x03\x01!wasi:clocks/m\ +onotonic-clock@0.2.0\x05\x03\x02\x03\0\x01\x03uri\x02\x03\0\x02\x08duration\x01B\ +f\x02\x03\x02\x01\x04\x04\0\x03uri\x03\0\0\x02\x03\x02\x01\x05\x04\0\x08duration\ +\x03\0\x02\x01w\x04\0\x0boplog-index\x03\0\x04\x01w\x04\0\x11component-version\x03\ +\0\x06\x01r\x02\x09high-bitsw\x08low-bitsw\x04\0\x04uuid\x03\0\x08\x01r\x01\x04u\ +uid\x09\x04\0\x0ccomponent-id\x03\0\x0a\x01r\x02\x0ccomponent-id\x0b\x0bworker-n\ +ames\x04\0\x09worker-id\x03\0\x0c\x01r\x02\x09worker-id\x0d\x09oplog-idx\x05\x04\ +\0\x0apromise-id\x03\0\x0e\x01r\x04\x0cmax-attemptsy\x09min-delay\x03\x09max-del\ +ay\x03\x0amultiplieru\x04\0\x0cretry-policy\x03\0\x10\x01q\x03\x0fpersist-nothin\ +g\0\0\x1bpersist-remote-side-effects\0\0\x05smart\0\0\x04\0\x11persistence-level\ +\x03\0\x12\x01m\x02\x09automatic\x0esnapshot-based\x04\0\x0bupdate-mode\x03\0\x14\ +\x01m\x06\x05equal\x09not-equal\x0dgreater-equal\x07greater\x0aless-equal\x04les\ +s\x04\0\x11filter-comparator\x03\0\x16\x01m\x04\x05equal\x09not-equal\x04like\x08\ +not-like\x04\0\x18string-filter-comparator\x03\0\x18\x01m\x07\x07running\x04idle\ +\x09suspended\x0binterrupted\x08retrying\x06failed\x06exited\x04\0\x0dworker-sta\ +tus\x03\0\x1a\x01r\x02\x0acomparator\x19\x05values\x04\0\x12worker-name-filter\x03\ +\0\x1c\x01r\x02\x0acomparator\x17\x05value\x1b\x04\0\x14worker-status-filter\x03\ +\0\x1e\x01r\x02\x0acomparator\x17\x05valuew\x04\0\x15worker-version-filter\x03\0\ +\x20\x01r\x02\x0acomparator\x17\x05valuew\x04\0\x18worker-created-at-filter\x03\0\ +\"\x01r\x03\x04names\x0acomparator\x19\x05values\x04\0\x11worker-env-filter\x03\0\ +$\x01q\x05\x04name\x01\x1d\0\x06status\x01\x1f\0\x07version\x01!\0\x0acreated-at\ +\x01#\0\x03env\x01%\0\x04\0\x16worker-property-filter\x03\0&\x01p'\x01r\x01\x07f\ +ilters(\x04\0\x11worker-all-filter\x03\0)\x01p*\x01r\x01\x07filters+\x04\0\x11wo\ +rker-any-filter\x03\0,\x01ps\x01o\x02ss\x01p/\x01r\x06\x09worker-id\x0d\x04args.\ +\x03env0\x06status\x1b\x11component-versionw\x0bretry-countw\x04\0\x0fworker-met\ +adata\x03\01\x04\0\x0bget-workers\x03\x01\x01k-\x01i3\x01@\x03\x0ccomponent-id\x0b\ +\x06filter4\x07precise\x7f\05\x04\0\x18[constructor]get-workers\x016\x01h3\x01p2\ +\x01k8\x01@\x01\x04self7\09\x04\0\x1c[method]get-workers.get-next\x01:\x01@\0\0\x0f\ +\x04\0\x0ecreate-promise\x01;\x01p}\x01@\x01\x0apromise-id\x0f\0<\x04\0\x0dawait\ +-promise\x01=\x01@\x02\x0apromise-id\x0f\x04data<\0\x7f\x04\0\x10complete-promis\ +e\x01>\x01@\x01\x0apromise-id\x0f\x01\0\x04\0\x0edelete-promise\x01?\x01@\x01\x0d\ +function-names\0\x01\x04\0\x0cget-self-uri\x01@\x01@\0\0\x05\x04\0\x0fget-oplog-\ +index\x01A\x01@\x01\x09oplog-idx\x05\x01\0\x04\0\x0fset-oplog-index\x01B\x01@\x01\ +\x08replicas}\x01\0\x04\0\x0coplog-commit\x01C\x04\0\x14mark-begin-operation\x01\ +A\x01@\x01\x05begin\x05\x01\0\x04\0\x12mark-end-operation\x01D\x01@\0\0\x11\x04\0\ +\x10get-retry-policy\x01E\x01@\x01\x10new-retry-policy\x11\x01\0\x04\0\x10set-re\ +try-policy\x01F\x01@\0\0\x13\x04\0\x1bget-oplog-persistence-level\x01G\x01@\x01\x15\ +new-persistence-level\x13\x01\0\x04\0\x1bset-oplog-persistence-level\x01H\x01@\0\ +\0\x7f\x04\0\x14get-idempotence-mode\x01I\x01@\x01\x0aidempotent\x7f\x01\0\x04\0\ +\x14set-idempotence-mode\x01J\x01@\0\0\x09\x04\0\x18generate-idempotency-key\x01\ +K\x01@\x03\x09worker-id\x0d\x0etarget-version\x07\x04mode\x15\x01\0\x04\0\x0dupd\ +ate-worker\x01L\x01@\0\02\x04\0\x11get-self-metadata\x01M\x01k2\x01@\x01\x09work\ +er-id\x0d\0\xce\0\x04\0\x13get-worker-metadata\x01O\x03\x01\x14golem:api/host@0.\ +2.0\x05\x06\x01B\x04\x04\0\x05error\x03\x01\x01h\0\x01@\x01\x04self\x01\0s\x04\0\ +\x1d[method]error.to-debug-string\x01\x02\x03\x01\x13wasi:io/error@0.2.0\x05\x07\ \x02\x03\0\x04\x05error\x01B(\x02\x03\x02\x01\x08\x04\0\x05error\x03\0\0\x02\x03\ -\x02\x01\x02\x04\0\x08pollable\x03\0\x02\x01i\x01\x01q\x02\x15last-operation-fai\ +\x02\x01\x01\x04\0\x08pollable\x03\0\x02\x01i\x01\x01q\x02\x15last-operation-fai\ led\x01\x04\0\x06closed\0\0\x04\0\x0cstream-error\x03\0\x05\x04\0\x0cinput-strea\ m\x03\x01\x04\0\x0doutput-stream\x03\x01\x01h\x07\x01p}\x01j\x01\x0a\x01\x06\x01\ @\x02\x04self\x09\x03lenw\0\x0b\x04\0\x19[method]input-stream.read\x01\x0c\x04\0\ @@ -16644,7 +18150,7 @@ wasi:filesystem/types@0.2.0\x05\x1b\x02\x03\0\x0a\x0adescriptor\x01B\x07\x02\x03 \x04\x04\0\x0fget-directories\x01\x05\x03\x01\x1ewasi:filesystem/preopens@0.2.0\x05\ \x1d\x01B\xc0\x01\x02\x03\x02\x01\x05\x04\0\x08duration\x03\0\0\x02\x03\x02\x01\x0a\ \x04\0\x0cinput-stream\x03\0\x02\x02\x03\x02\x01\x0b\x04\0\x0doutput-stream\x03\0\ -\x04\x02\x03\x02\x01\x08\x04\0\x08io-error\x03\0\x06\x02\x03\x02\x01\x02\x04\0\x08\ +\x04\x02\x03\x02\x01\x08\x04\0\x08io-error\x03\0\x06\x02\x03\x02\x01\x01\x04\0\x08\ pollable\x03\0\x08\x01q\x0a\x03get\0\0\x04head\0\0\x04post\0\0\x03put\0\0\x06del\ ete\0\0\x07connect\0\0\x07options\0\0\x05trace\0\0\x05patch\0\0\x05other\x01s\0\x04\ \0\x06method\x03\0\x0a\x01q\x03\x04HTTP\0\0\x05HTTPS\0\0\x05other\x01s\0\x04\0\x06\ @@ -16789,7 +18295,7 @@ ipv4-socket-address\x03\0\x0b\x01r\x04\x04port{\x09flow-infoy\x07address\x08\x08 scope-idy\x04\0\x13ipv6-socket-address\x03\0\x0d\x01q\x02\x04ipv4\x01\x0c\0\x04i\ pv6\x01\x0e\0\x04\0\x11ip-socket-address\x03\0\x0f\x03\x01\x1awasi:sockets/netwo\ rk@0.2.0\x05/\x02\x03\0\x13\x07network\x02\x03\0\x13\x0aerror-code\x02\x03\0\x13\ -\x0aip-address\x01B\x16\x02\x03\x02\x01\x02\x04\0\x08pollable\x03\0\0\x02\x03\x02\ +\x0aip-address\x01B\x16\x02\x03\x02\x01\x01\x04\0\x08pollable\x03\0\0\x02\x03\x02\ \x010\x04\0\x07network\x03\0\x02\x02\x03\x02\x011\x04\0\x0aerror-code\x03\0\x04\x02\ \x03\x02\x012\x04\0\x0aip-address\x03\0\x06\x04\0\x16resolve-address-stream\x03\x01\ \x01h\x08\x01k\x07\x01j\x01\x0a\x01\x05\x01@\x01\x04self\x09\0\x0b\x04\03[method\ diff --git a/golem-rust/wit/deps.lock b/golem-rust/wit/deps.lock new file mode 100644 index 0000000..bc9002e --- /dev/null +++ b/golem-rust/wit/deps.lock @@ -0,0 +1,53 @@ +[all] +url = "https://github.com/golemcloud/golem-wit/archive/main.tar.gz" +sha256 = "6ac4f1553003474229bb40a885b48d1eaa4bea2f9d679a115da9afede30b5ad4" +sha512 = "ced8c18a35dc04123386465d98d2aeba54c486e4e22a30e7efac0548974e176528fcba36c64942d67fa35d9135806ff0fcde259eb4af051c4a29fcb397e9af1c" +deps = ["blobstore", "cli", "clocks", "filesystem", "golem", "http", "io", "keyvalue", "logging", "random", "sockets", "wasm-rpc"] + +[blobstore] +sha256 = "eb50ec776eac937b2ef90b41a281d0dd7c94f0b076466d917bd0f2ed5b01d39d" +sha512 = "b40613b47a8ba236a7b3ff85cb7e3c5b8f665a6c359fc539ca01f0b2170538a47c80eb991df8f4d5ca162f4dc6e0ca4311e23ad5ce88b85b30570dedf78fcffe" + +[cli] +sha256 = "285865a31d777181b075f39e92bcfe59c89cd6bacce660be1b9a627646956258" +sha512 = "da2622210a9e3eea82b99f1a5b8a44ce5443d009cb943f7bca0bf9cf4360829b289913d7ee727c011f0f72994ea7dc8e661ebcc0a6b34b587297d80cd9b3f7e8" + +[clocks] +sha256 = "468b4d12892fe926b8eb5d398dbf579d566c93231fa44f415440572c695b7613" +sha512 = "e6b53a07221f1413953c9797c68f08b815fdaebf66419bbc1ea3e8b7dece73731062693634731f311a03957b268cf9cc509c518bd15e513c318aa04a8459b93a" + +[filesystem] +sha256 = "498c465cfd04587db40f970fff2185daa597d074c20b68a8bcbae558f261499b" +sha512 = "ead452f9b7bfb88593a502ec00d76d4228003d51c40fd0408aebc32d35c94673551b00230d730873361567cc209ec218c41fb4e95bad194268592c49e7964347" + +[golem] +sha256 = "181dfcbb2421c6f52303d49aac4b06d8db67eb683e7460acacf29961153247f4" +sha512 = "64c51048f90c4bc83b43c99af570376bcaa4b623c66b97fd418be9fef77d17530e37d7c7f59f2e706b7b5dcfb6728eb11e27e3805a96391c59a264818f513d32" + +[http] +sha256 = "8f44402bde16c48e28c47dc53eab0b26af5b3b3482a1852cf77673e0880ba1c1" +sha512 = "760695f9a25c25bf75a25b731cb21c3bda9e288e450edda823324ecbc73d5d798bbb5de2edad999566980836f037463ee9e57d61789d04b3f3e381475b1a9a0f" + +[io] +sha256 = "5a3b0b9774ad733d4fa144a694018b03158c21e6168234e81ed02d49a78ef9cb" +sha512 = "f88e836b2264b7a0ec8e51b79420331c42b4973ccc283c556802103e0b6a8daa5ecdf00bd984851fe52db07e703d75c1970c5fba1614b6c990d97734cad22d67" + +[keyvalue] +sha256 = "efceed91e17be50f52681ef73043f54298e2f11b48a5befdcbc92a7aea941bed" +sha512 = "b019a3333c6dadbab8c067085a5110566cfb7c3f3d9a65d482ccdac85a62eb0bdfed0ca1bbf7dafabf622ca0c6cf39b865cc234412bcbb2ff1290386cda031fa" + +[logging] +sha256 = "7fb7216c713fd329ec91bb596127a1b95eec26290290b6de0c1ef294fba858c2" +sha512 = "ceb68410bb46176051b0eee54e1a60831ca2fe820892c5f5f739e76efd4fe6ee6dc5e307947e7118b68a2a757ed3a3b471d16eb0900bb9040de47fef4bf1b56f" + +[random] +sha256 = "7371d03c037d924caba2587fb2e7c5773a0d3c5fcecbf7971e0e0ba57973c53d" +sha512 = "964c4e8925a53078e4d94ba907b54f89a0b7e154f46823a505391471466c17f53c8692682e5c85771712acd88b348686173fc07c53a3cfe3d301b8cd8ddd0de4" + +[sockets] +sha256 = "b0869b7cbbaea1410308cd379207f5841db5e30f1e1c1d9fe0582b560b668f24" +sha512 = "198a7bcf4d405b7761e1b5a0a94cdd1e144adb0c6cfbe2b64e380d377de5ac3171a4cf3f840b81ff2ef54be990c95c121f48910796228c0f54b0c3c6e973e317" + +[wasm-rpc] +sha256 = "64225943bf3b42acc7ce9001260d3f16b43ee9f58cdeef373918a95e1e649a43" +sha512 = "e4de3538fbfbf5bf5b03afb05201c07a32efc78388f648d4420ea1f0b962e0b5c43c19c6bffe29b7f51de36e4bcc75ce2b8a227a3d44b581e53a1148c69b49ab" diff --git a/golem-rust/wit/deps.toml b/golem-rust/wit/deps.toml new file mode 100644 index 0000000..1b78bbb --- /dev/null +++ b/golem-rust/wit/deps.toml @@ -0,0 +1 @@ +all = "https://github.com/golemcloud/golem-wit/archive/main.tar.gz" diff --git a/golem-rust/wit/deps/all/main.wit b/golem-rust/wit/deps/all/main.wit new file mode 100644 index 0000000..0a1f74f --- /dev/null +++ b/golem-rust/wit/deps/all/main.wit @@ -0,0 +1 @@ +package unused:main; diff --git a/golem-rust/wit/deps/golem/golem-host.wit b/golem-rust/wit/deps/golem/golem-host.wit index fc0b99f..10787a7 100644 --- a/golem-rust/wit/deps/golem/golem-host.wit +++ b/golem-rust/wit/deps/golem/golem-host.wit @@ -3,249 +3,255 @@ package golem:api@0.2.0; /// The Golem host API provides low level access to Golem specific features such as promises and control over /// the durability and transactional guarantees the executor provides. interface host { - use golem:rpc/types@0.1.0.{uri}; - use wasi:clocks/monotonic-clock@0.2.0.{duration}; - - /// An index into the persistent log storing all performed operations of a worker - type oplog-index = u64; - - /// A promise ID is a value that can be passed to an external Golem API to complete that promise - /// from an arbitrary external source, while Golem workers can await for this completion. - record promise-id { - worker-id: worker-id, - oplog-idx: oplog-index, - } - - /// Represents a Golem worker - record worker-id { - component-id: component-id, - worker-name: string - } - - - /// Represents a Golem component - record component-id { - uuid: uuid, - } - - /// Represents a Golem component's version - type component-version = u64; - - /// UUID - record uuid { - high-bits: u64, - low-bits: u64 - } - - /// Configures how the executor retries failures - record retry-policy { - /// The maximum number of retries before the worker becomes permanently failed - max-attempts: u32, - /// The minimum delay between retries (applied to the first retry) - min-delay: duration, - /// The maximum delay between retries - max-delay: duration, - /// Multiplier applied to the delay on each retry to implement exponential backoff - multiplier: u32 - } - - /// Configurable persistence level for workers - variant persistence-level { - persist-nothing, - persist-remote-side-effects, - smart - } - - /// Describes how to update a worker to a different component version - enum update-mode { - /// Automatic update tries to recover the worker using the new component version - /// and may fail if there is a divergence. - automatic, - - /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface - /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to - /// load it into the new version. - snapshot-based - } - - enum filter-comparator { - equal, - not-equal, - greater-equal, - greater, - less-equal, - less - } - - enum string-filter-comparator { - equal, - not-equal, - like, - not-like - } - - enum worker-status { - /// The worker is running an invoked function - running, - /// The worker is ready to run an invoked function - idle, - /// An invocation is active but waiting for something (sleeping, waiting for a promise) - suspended, - /// The last invocation was interrupted but will be resumed - interrupted, - /// The last invocation failed and a retry was scheduled - retrying, - /// The last invocation failed and the worker can no longer be used - failed, - /// The worker exited after a successful invocation and can no longer be invoked - exited, - } - - record worker-name-filter { - comparator: string-filter-comparator, - value: string - } - - record worker-status-filter { - comparator: filter-comparator, - value: worker-status - } - - record worker-version-filter { - comparator: filter-comparator, - value: u64 - } - - record worker-created-at-filter { - comparator: filter-comparator, - value: u64 - } - - record worker-env-filter { - name: string, - comparator: string-filter-comparator, - value: string - } - - variant worker-property-filter { - name(worker-name-filter), - status(worker-status-filter), - version(worker-version-filter), - created-at(worker-created-at-filter), - env(worker-env-filter) - } - - record worker-all-filter { - filters: list - } - - record worker-any-filter { - filters: list - } - - record worker-metadata { - worker-id: worker-id, - args: list, - env: list>, - status: worker-status, - component-version: u64, - retry-count: u64 - } - - resource get-workers { -constructor(component-id: component-id, filter: option, precise: bool); - - get-next: func() -> option>; - } - - /// Create a new promise - golem-create-promise: func() -> promise-id; - - /// Suspends execution until the given promise gets completed, and returns the payload passed to - /// the promise completion. - golem-await-promise: func(promise-id: promise-id) -> list; - - /// Completes the given promise with the given payload. Returns true if the promise was completed, false - /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. - golem-complete-promise: func(promise-id: promise-id, data: list) -> bool; - - /// Deletes the given promise - golem-delete-promise: func(promise-id: promise-id) -> (); - - /// Returns a Golem worker URI that can be used to invoke a given function on the current worker - get-self-uri: func(function-name: string) -> uri; - - /// Returns the current position in the persistent op log - get-oplog-index: func() -> oplog-index; - - /// Makes the current worker travel back in time and continue execution from the given position in the persistent - /// op log. - set-oplog-index: func(oplog-idx: oplog-index) -> (); - - /// Blocks the execution until the oplog has been written to at least the specified number of replicas, - /// or the maximum number of replicas if the requested number is higher. - oplog-commit: func(replicas: u8) -> (); - - /// Marks the beginning of an atomic operation. - /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` - /// the whole region will be reexecuted on retry. - /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. - mark-begin-operation: func() -> oplog-index; - - /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls - /// with the same parameter will do nothing. - mark-end-operation: func(begin: oplog-index) -> (); - - /// Gets the current retry policy associated with the worker - get-retry-policy: func() -> retry-policy; - - /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the - /// new retry policy. - set-retry-policy: func(new-retry-policy: retry-policy) -> (); - - /// Gets the worker's current persistence level. - get-oplog-persistence-level: func() -> persistence-level; - - /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable - /// execution is not required. - set-oplog-persistence-level: func(new-persistence-level: persistence-level) -> (); - - /// Gets the current idempotence mode. See `set-idempotence-mode` for details. - get-idempotence-mode: func() -> bool; - - /// Sets the current idempotence mode. The default is true. - /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. - /// In case of false the executor provides at-most-once semantics, failing the worker in case it is - /// not known if the side effect was already executed. - set-idempotence-mode: func(idempotent: bool) -> (); - - /// Generates an idempotency key. This operation will never be replayed — - /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) - /// to introduce idempotence. - generate-idempotency-key: func() -> uuid; - - /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, - /// not waiting for the worker to get updated. - update-worker: func(worker-id: worker-id, target-version: component-version, mode: update-mode) -> (); + use golem:rpc/types@0.1.0.{uri}; + use wasi:clocks/monotonic-clock@0.2.0.{duration}; + + /// An index into the persistent log storing all performed operations of a worker + type oplog-index = u64; + + /// A promise ID is a value that can be passed to an external Golem API to complete that promise + /// from an arbitrary external source, while Golem workers can await for this completion. + record promise-id { + worker-id: worker-id, + oplog-idx: oplog-index, + } + + /// Represents a Golem worker + record worker-id { + component-id: component-id, + worker-name: string + } + + + /// Represents a Golem component + record component-id { + uuid: uuid, + } + + /// Represents a Golem component's version + type component-version = u64; + + /// UUID + record uuid { + high-bits: u64, + low-bits: u64 + } + + /// Configures how the executor retries failures + record retry-policy { + /// The maximum number of retries before the worker becomes permanently failed + max-attempts: u32, + /// The minimum delay between retries (applied to the first retry) + min-delay: duration, + /// The maximum delay between retries + max-delay: duration, + /// Multiplier applied to the delay on each retry to implement exponential backoff + multiplier: f64 + } + + /// Configurable persistence level for workers + variant persistence-level { + persist-nothing, + persist-remote-side-effects, + smart + } + + /// Describes how to update a worker to a different component version + enum update-mode { + /// Automatic update tries to recover the worker using the new component version + /// and may fail if there is a divergence. + automatic, + + /// Manual, snapshot-based update uses a user-defined implementation of the `save-snapshot` interface + /// to store the worker's state, and a user-defined implementation of the `load-snapshot` interface to + /// load it into the new version. + snapshot-based + } + + enum filter-comparator { + equal, + not-equal, + greater-equal, + greater, + less-equal, + less + } + + enum string-filter-comparator { + equal, + not-equal, + like, + not-like + } + + enum worker-status { + /// The worker is running an invoked function + running, + /// The worker is ready to run an invoked function + idle, + /// An invocation is active but waiting for something (sleeping, waiting for a promise) + suspended, + /// The last invocation was interrupted but will be resumed + interrupted, + /// The last invocation failed and a retry was scheduled + retrying, + /// The last invocation failed and the worker can no longer be used + failed, + /// The worker exited after a successful invocation and can no longer be invoked + exited, + } + + record worker-name-filter { + comparator: string-filter-comparator, + value: string + } + + record worker-status-filter { + comparator: filter-comparator, + value: worker-status + } + + record worker-version-filter { + comparator: filter-comparator, + value: u64 + } + + record worker-created-at-filter { + comparator: filter-comparator, + value: u64 + } + + record worker-env-filter { + name: string, + comparator: string-filter-comparator, + value: string + } + + variant worker-property-filter { + name(worker-name-filter), + status(worker-status-filter), + version(worker-version-filter), + created-at(worker-created-at-filter), + env(worker-env-filter) + } + + record worker-all-filter { + filters: list + } + + record worker-any-filter { + filters: list + } + + record worker-metadata { + worker-id: worker-id, + args: list, + env: list>, + status: worker-status, + component-version: u64, + retry-count: u64 + } + + resource get-workers { + constructor(component-id: component-id, filter: option, precise: bool); + + get-next: func() -> option>; + } + + /// Create a new promise + create-promise: func() -> promise-id; + + /// Suspends execution until the given promise gets completed, and returns the payload passed to + /// the promise completion. + await-promise: func(promise-id: promise-id) -> list; + + /// Completes the given promise with the given payload. Returns true if the promise was completed, false + /// if the promise was already completed. The payload is passed to the worker that is awaiting the promise. + complete-promise: func(promise-id: promise-id, data: list) -> bool; + + /// Deletes the given promise + delete-promise: func(promise-id: promise-id) -> (); + + /// Returns a Golem worker URI that can be used to invoke a given function on the current worker + get-self-uri: func(function-name: string) -> uri; + + /// Returns the current position in the persistent op log + get-oplog-index: func() -> oplog-index; + + /// Makes the current worker travel back in time and continue execution from the given position in the persistent + /// op log. + set-oplog-index: func(oplog-idx: oplog-index) -> (); + + /// Blocks the execution until the oplog has been written to at least the specified number of replicas, + /// or the maximum number of replicas if the requested number is higher. + oplog-commit: func(replicas: u8) -> (); + + /// Marks the beginning of an atomic operation. + /// In case of a failure within the region selected by `mark-begin-operation` and `mark-end-operation` + /// the whole region will be reexecuted on retry. + /// The end of the region is when `mark-end-operation` is called with the returned oplog-index. + mark-begin-operation: func() -> oplog-index; + + /// Commits this atomic operation. After `mark-end-operation` is called for a given index, further calls + /// with the same parameter will do nothing. + mark-end-operation: func(begin: oplog-index) -> (); + + /// Gets the current retry policy associated with the worker + get-retry-policy: func() -> retry-policy; + + /// Overrides the current retry policy associated with the worker. Following this call, `get-retry-policy` will return the + /// new retry policy. + set-retry-policy: func(new-retry-policy: retry-policy) -> (); + + /// Gets the worker's current persistence level. + get-oplog-persistence-level: func() -> persistence-level; + + /// Sets the worker's current persistence level. This can increase the performance of execution in cases where durable + /// execution is not required. + set-oplog-persistence-level: func(new-persistence-level: persistence-level) -> (); + + /// Gets the current idempotence mode. See `set-idempotence-mode` for details. + get-idempotence-mode: func() -> bool; + + /// Sets the current idempotence mode. The default is true. + /// True means side-effects are treated idempotent and Golem guarantees at-least-once semantics. + /// In case of false the executor provides at-most-once semantics, failing the worker in case it is + /// not known if the side effect was already executed. + set-idempotence-mode: func(idempotent: bool) -> (); + + /// Generates an idempotency key. This operation will never be replayed — + /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) + /// to introduce idempotence. + generate-idempotency-key: func() -> uuid; + + /// Initiates an update attempt for the given worker. The function returns immediately once the request has been processed, + /// not waiting for the worker to get updated. + update-worker: func(worker-id: worker-id, target-version: component-version, mode: update-mode) -> (); + + /// Get current worker metadata + get-self-metadata: func() -> worker-metadata; + + /// Get worker metadata + get-worker-metadata: func(worker-id: worker-id) -> option; } /// Interface providing user-defined snapshotting capability. This can be used to perform manual update of workers /// when the new component incompatible with the old one. interface save-snapshot { - /// Saves the component's state into a user-defined snapshot - save: func() -> list; + /// Saves the component's state into a user-defined snapshot + save: func() -> list; } /// Interface providing user-defined snapshotting capability. This can be used to perform manual update of workers /// when the new component incompatible with the old one. interface load-snapshot { - /// Tries to load a user-defined snapshot, setting up the worker's state based on it. - /// The function can return with a failure to indicate that the update is not possible. - load: func(bytes: list) -> result<_, string>; + /// Tries to load a user-defined snapshot, setting up the worker's state based on it. + /// The function can return with a failure to indicate that the update is not possible. + load: func(bytes: list) -> result<_, string>; } world golem-host { - import host; - import save-snapshot; - import load-snapshot; + import host; + import save-snapshot; + import load-snapshot; } diff --git a/golem-rust/wit/deps/wasm-rpc/wasm-rpc.wit b/golem-rust/wit/deps/wasm-rpc/wasm-rpc.wit index f7deff5..69e1c8d 100644 --- a/golem-rust/wit/deps/wasm-rpc/wasm-rpc.wit +++ b/golem-rust/wit/deps/wasm-rpc/wasm-rpc.wit @@ -1,6 +1,8 @@ package golem:rpc@0.1.0; interface types { + use wasi:io/poll@0.2.0.{pollable}; + type node-index = s32; record wit-value { @@ -29,6 +31,7 @@ interface types { prim-char(char), prim-bool(bool), prim-string(string), + handle(tuple) } record uri { @@ -46,6 +49,14 @@ interface types { constructor(location: uri); invoke-and-await: func(function-name: string, function-params: list) -> result; + invoke: func(function-name: string, function-params: list) -> result<_, rpc-error>; + + async-invoke-and-await: func(function-name: string, function-params: list) -> future-invoke-result; + } + + resource future-invoke-result { + subscribe: func() -> pollable; + get: func() -> option>; } } From b0f59df0c1f5cf3324478d2c1bb0d1a0dadc67fe Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Fri, 26 Jul 2024 14:42:26 +0200 Subject: [PATCH 2/6] generate_idempotency_key returns uuid::Uuid --- golem-rust/src/lib.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/golem-rust/src/lib.rs b/golem-rust/src/lib.rs index 6f8647a..d2d57db 100644 --- a/golem-rust/src/lib.rs +++ b/golem-rust/src/lib.rs @@ -85,6 +85,15 @@ pub fn with_idempotence_mode(mode: bool, f: impl FnOnce() -> R) -> R { /// Generates an idempotency key. This operation will never be replayed — /// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) /// to introduce idempotence. +#[cfg(feature = "uuid")] +pub fn generate_idempotency_key() -> ::uuid::Uuid { + Into::into(bindings::golem::api::host::generate_idempotency_key()) +} + +/// Generates an idempotency key. This operation will never be replayed — +/// i.e. not only is this key generated, but it is persisted and committed, such that the key can be used in third-party systems (e.g. payment processing) +/// to introduce idempotence. +#[cfg(not(feature = "uuid"))] pub fn generate_idempotency_key() -> Uuid { bindings::golem::api::host::generate_idempotency_key() } From 383b8a4ef3990799ae9e736f479a6b409093de29 Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Fri, 26 Jul 2024 14:48:31 +0200 Subject: [PATCH 3/6] More convenient RetryPolicy wrapper --- golem-rust/src/lib.rs | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/golem-rust/src/lib.rs b/golem-rust/src/lib.rs index d2d57db..0211725 100644 --- a/golem-rust/src/lib.rs +++ b/golem-rust/src/lib.rs @@ -26,10 +26,39 @@ use bindings::golem::api::host::*; pub use bindings::golem::api::host::oplog_commit; pub use bindings::golem::api::host::PersistenceLevel; -pub use bindings::golem::api::host::RetryPolicy; pub use transaction::*; +#[derive(Clone, Debug, PartialEq)] +pub struct RetryPolicy { + pub max_attempts: u32, + pub min_delay: std::time::Duration, + pub max_delay: std::time::Duration, + pub multiplier: f64, +} + +impl From for RetryPolicy { + fn from(value: bindings::golem::api::host::RetryPolicy) -> Self { + Self { + max_attempts: value.max_attempts, + min_delay: std::time::Duration::from_nanos(value.min_delay), + max_delay: std::time::Duration::from_nanos(value.max_delay), + multiplier: value.multiplier, + } + } +} + +impl Into for RetryPolicy { + fn into(self) -> bindings::golem::api::host::RetryPolicy { + bindings::golem::api::host::RetryPolicy { + max_attempts: self.max_attempts, + min_delay: self.min_delay.as_nanos() as u64, + max_delay: self.max_delay.as_nanos() as u64, + multiplier: self.multiplier, + } + } +} + pub struct PersistenceLevelGuard { original_level: PersistenceLevel, } @@ -104,7 +133,7 @@ pub struct RetryPolicyGuard { impl Drop for RetryPolicyGuard { fn drop(&mut self) { - set_retry_policy(self.original); + set_retry_policy(Into::into(self.original.clone())); } } @@ -113,8 +142,8 @@ impl Drop for RetryPolicyGuard { /// When the returned guard is dropped, the original retry policy is restored. #[must_use] pub fn use_retry_policy(policy: RetryPolicy) -> RetryPolicyGuard { - let original = get_retry_policy(); - set_retry_policy(policy); + let original = Into::into(get_retry_policy()); + set_retry_policy(Into::into(policy)); RetryPolicyGuard { original } } From 6aba395bb6ad39b2a24fff76f7ca60b7ea05bc02 Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Fri, 26 Jul 2024 14:50:13 +0200 Subject: [PATCH 4/6] Format --- golem-rust/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/golem-rust/src/lib.rs b/golem-rust/src/lib.rs index 0211725..06761c7 100644 --- a/golem-rust/src/lib.rs +++ b/golem-rust/src/lib.rs @@ -48,13 +48,13 @@ impl From for RetryPolicy { } } -impl Into for RetryPolicy { - fn into(self) -> bindings::golem::api::host::RetryPolicy { +impl From for bindings::golem::api::host::RetryPolicy { + fn from(val: RetryPolicy) -> Self { bindings::golem::api::host::RetryPolicy { - max_attempts: self.max_attempts, - min_delay: self.min_delay.as_nanos() as u64, - max_delay: self.max_delay.as_nanos() as u64, - multiplier: self.multiplier, + max_attempts: val.max_attempts, + min_delay: val.min_delay.as_nanos() as u64, + max_delay: val.max_delay.as_nanos() as u64, + multiplier: val.multiplier, } } } From a4b2c347a73bb1576d92e782f3662ed2ea0a33d6 Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Fri, 26 Jul 2024 15:05:30 +0200 Subject: [PATCH 5/6] Conversions for ComponentId, WorkerId and PromiseId --- Cargo.lock | 4 +- golem-rust/Cargo.toml | 2 +- golem-rust/src/uuid.rs | 90 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fb11083..3ff13af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -93,9 +93,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "uuid" -version = "1.8.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" dependencies = [ "getrandom", ] diff --git a/golem-rust/Cargo.toml b/golem-rust/Cargo.toml index 9506882..9e121b0 100644 --- a/golem-rust/Cargo.toml +++ b/golem-rust/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["cdylib", "rlib"] [dependencies] golem-rust-macro = { path = "../golem-rust-macro", version = "0.0.0", optional = true } -uuid = { version = "1.8.0", features = ["v4"], optional = true } +uuid = { version = "1.10.0", features = ["v4"], optional = true } wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [features] diff --git a/golem-rust/src/uuid.rs b/golem-rust/src/uuid.rs index a98226a..c9fc289 100644 --- a/golem-rust/src/uuid.rs +++ b/golem-rust/src/uuid.rs @@ -12,6 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +use crate::bindings::golem::api::host::ComponentId; +use std::fmt; +use std::fmt::{Display, Formatter}; +use std::str::FromStr; use uuid::Uuid; impl From for Uuid { @@ -29,3 +33,89 @@ impl From for crate::bindings::golem::api::host::Uuid { } } } + +impl From for crate::bindings::golem::api::host::ComponentId { + fn from(value: Uuid) -> Self { + Self { uuid: value.into() } + } +} + +impl From for Uuid { + fn from(value: crate::bindings::golem::api::host::ComponentId) -> Self { + value.uuid.into() + } +} + +impl FromStr for crate::bindings::golem::api::host::ComponentId { + type Err = uuid::Error; + + fn from_str(s: &str) -> Result { + Ok(Uuid::parse_str(s)?.into()) + } +} + +impl Display for crate::bindings::golem::api::host::ComponentId { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "{:?}", &self.uuid) + } +} + +impl Display for crate::bindings::golem::api::host::WorkerId { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "{}/{}", self.component_id, self.worker_name) + } +} + +impl FromStr for crate::bindings::golem::api::host::WorkerId { + type Err = String; + + fn from_str(s: &str) -> Result { + let parts: Vec<&str> = s.split('/').collect(); + if parts.len() == 2 { + let component_id = ComponentId::from_str(parts[0]) + .map_err(|_| format!("invalid component id: {s} - expected uuid"))?; + let worker_name = parts[1].to_string(); + Ok(Self { + component_id, + worker_name, + }) + } else { + Err(format!( + "invalid worker id: {s} - expected format: /" + )) + } + } +} + +impl Display for crate::bindings::golem::api::host::PromiseId { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + write!(f, "{}/{}", self.worker_id, self.oplog_idx) + } +} + +impl FromStr for crate::bindings::golem::api::host::PromiseId { + type Err = String; + + fn from_str(s: &str) -> Result { + let parts: Vec<&str> = s.split('/').collect(); + if parts.len() == 2 { + let worker_id = crate::bindings::golem::api::host::WorkerId::from_str(parts[0]) + .map_err(|_| { + format!( + "invalid worker id: {s} - expected format: /" + ) + })?; + let oplog_idx = parts[1] + .parse() + .map_err(|_| format!("invalid oplog index: {s} - expected integer"))?; + Ok(Self { + worker_id, + oplog_idx, + }) + } else { + Err(format!( + "invalid promise id: {s} - expected format: /" + )) + } + } +} From f11cb54a09386df3090828faa926e46cd23a7c52 Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Fri, 26 Jul 2024 15:26:08 +0200 Subject: [PATCH 6/6] JSON support for promises --- Cargo.lock | 45 ++++++++++++++++++++++++++++++++++++++++++ golem-rust/Cargo.toml | 5 ++++- golem-rust/src/json.rs | 34 +++++++++++++++++++++++++++++++ golem-rust/src/lib.rs | 6 ++++++ 4 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 golem-rust/src/json.rs diff --git a/Cargo.lock b/Cargo.lock index 3ff13af..1f76691 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,6 +30,8 @@ name = "golem-rust" version = "0.0.0" dependencies = [ "golem-rust-macro", + "serde", + "serde_json", "uuid", "wit-bindgen-rt", ] @@ -50,6 +52,12 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + [[package]] name = "libc" version = "0.2.153" @@ -74,6 +82,43 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "serde" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.204" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.120" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +dependencies = [ + "itoa", + "ryu", + "serde", +] + [[package]] name = "syn" version = "2.0.58" diff --git a/golem-rust/Cargo.toml b/golem-rust/Cargo.toml index 9e121b0..cd57b87 100644 --- a/golem-rust/Cargo.toml +++ b/golem-rust/Cargo.toml @@ -13,11 +13,14 @@ crate-type = ["cdylib", "rlib"] [dependencies] golem-rust-macro = { path = "../golem-rust-macro", version = "0.0.0", optional = true } +serde = { version = "1.0.204", optional = true } +serde_json = { version = "1.0.120", optional = true } uuid = { version = "1.10.0", features = ["v4"], optional = true } wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } [features] -default = ["macro", "uuid"] +default = ["json", "macro", "uuid"] +json = ["dep:serde", "dep:serde_json"] macro = ["dep:golem-rust-macro"] uuid = ["dep:uuid"] diff --git a/golem-rust/src/json.rs b/golem-rust/src/json.rs new file mode 100644 index 0000000..7aacd57 --- /dev/null +++ b/golem-rust/src/json.rs @@ -0,0 +1,34 @@ +// Copyright 2024 Golem Cloud +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +use crate::bindings::golem::api::host::PromiseId; +use serde::de::DeserializeOwned; +use serde::Serialize; + +pub fn await_promise_json( + promise_id: &PromiseId, +) -> Result { + let bytes = crate::bindings::golem::api::host::await_promise(promise_id); + serde_json::from_slice(&bytes) +} + +pub fn complete_promise_json( + promise_id: &PromiseId, + value: T, +) -> Result { + let bytes = serde_json::to_vec(&value)?; + Ok(crate::bindings::golem::api::host::complete_promise( + promise_id, &bytes, + )) +} diff --git a/golem-rust/src/lib.rs b/golem-rust/src/lib.rs index 06761c7..024ad6e 100644 --- a/golem-rust/src/lib.rs +++ b/golem-rust/src/lib.rs @@ -17,6 +17,12 @@ #[rustfmt::skip] pub mod bindings; +#[cfg(feature = "json")] +mod json; + +#[cfg(feature = "json")] +pub use json::*; + #[cfg(feature = "uuid")] mod uuid;