From ae1b9c364b3021e114136c1fd8c5080c2f55655c Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Tue, 1 Jul 2025 12:03:43 +0200 Subject: [PATCH 01/45] wip --- .../hermes/http_request/host.rs | 12 + .../hermes/http_request/mod.rs | 41 + .../hermes/http_request/tokio_runtime_task.rs | 58 + .../bin/src/runtime_extensions/hermes/mod.rs | 2 + wasm/integration-test/http_request/Earthfile | 3 + wasm/wasi/Earthfile | 1 + wasm/wasi/hermes_bindings.rs | 16897 ++++++++++++++++ .../wasi/wit/deps/hermes-http-request/api.wit | 13 + .../wit/deps/hermes-http-request/world.wit | 5 + wasm/wasi/wit/hermes.wit | 1 + 10 files changed, 17033 insertions(+) create mode 100644 hermes/bin/src/runtime_extensions/hermes/http_request/host.rs create mode 100644 hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs create mode 100644 hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs create mode 100644 wasm/integration-test/http_request/Earthfile create mode 100644 wasm/wasi/hermes_bindings.rs create mode 100644 wasm/wasi/wit/deps/hermes-http-request/api.wit create mode 100644 wasm/wasi/wit/deps/hermes-http-request/world.wit diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs new file mode 100644 index 0000000000..6fc28065ad --- /dev/null +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs @@ -0,0 +1,12 @@ +//! Cardano Blockchain host implementation for WASM runtime. + +use crate::{ + runtime_context::HermesRuntimeContext, + runtime_extensions::bindings::hermes::http_request::api::{Host, Payload}, +}; + +impl Host for HermesRuntimeContext { + fn send(&mut self, p: Payload) -> wasmtime::Result { + todo!() + } +} diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs new file mode 100644 index 0000000000..0ae8e7b9d2 --- /dev/null +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs @@ -0,0 +1,41 @@ +//! Http Request extension implementation. + +#![allow(unused)] +#![allow(dead_code)] + +mod tokio_runtime_task; +mod host; + +struct State { + tokio_rt_handle: tokio_runtime_task::Handle, +} + +/// Http Request extension internal state. +static STATE: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { + let tokio_rt_handle = tokio_runtime_task::spawn(); + + State { tokio_rt_handle } +}); + +pub(crate) fn new_context(_ctx: &crate::runtime_context::HermesRuntimeContext) {} + +type Payload = u32; + +type Error = u32; + +/// Send an Http Request +pub(super) fn send(payload: Payload) -> Result { + STATE.tokio_rt_handle.send(payload) +} + +#[cfg(test)] +mod test { + use crate::runtime_extensions::hermes::http_request::send; + + #[test] + fn sending_works() { + let result = send(24).unwrap(); + + assert_eq!(result, true); + } +} diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs new file mode 100644 index 0000000000..5bcfd778bb --- /dev/null +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -0,0 +1,58 @@ +use tracing::{error, trace}; + +enum Command { + Send { payload: super::Payload }, +} + +type CommandSender = tokio::sync::mpsc::Sender; + +type CommandReceiver = tokio::sync::mpsc::Receiver; + +pub struct Handle { + cmd_tx: CommandSender, +} + +impl Handle { + pub(super) fn send(&self, payload: super::Payload) -> Result { + self.cmd_tx + .blocking_send(Command::Send { payload }) + .map_err(|_| 0u32)?; + + // TODO: Proper return type + Ok(true) + } +} + +pub fn spawn() -> Handle { + let (cmd_tx, cmd_rx) = tokio::sync::mpsc::channel(1); + std::thread::spawn(move || { + executor(cmd_rx); + }); + + Handle { cmd_tx } +} + +fn executor(mut cmd_rx: CommandReceiver) { + let res = tokio::runtime::Builder::new_current_thread() + .enable_io() + .enable_time() + .build(); + + let rt = match res { + Ok(rt) => rt, + Err(err) => { + error!(error = ?err, "Failed to start Http Request Runtime Extension background thread"); + return; + }, + }; + + trace!("Created Tokio runtime for Http Request Runtime Extension"); + + rt.block_on(async move { + while let Some(cmd) = cmd_rx.recv().await { + match cmd { + Command::Send { payload: _ } => todo!(), + } + } + }); +} diff --git a/hermes/bin/src/runtime_extensions/hermes/mod.rs b/hermes/bin/src/runtime_extensions/hermes/mod.rs index fea99b6f34..9fc88a2857 100644 --- a/hermes/bin/src/runtime_extensions/hermes/mod.rs +++ b/hermes/bin/src/runtime_extensions/hermes/mod.rs @@ -9,6 +9,7 @@ pub(crate) mod cron; pub(crate) mod crypto; pub(crate) mod hash; pub(crate) mod http_gateway; +pub(crate) mod http_request; pub(crate) mod init; pub mod integration_test; pub(crate) mod ipfs; @@ -34,4 +35,5 @@ pub(crate) fn new_context(ctx: &HermesRuntimeContext) { logging::new_context(ctx); sqlite::new_context(ctx); http_gateway::new_context(ctx); + http_request::new_context(ctx); } diff --git a/wasm/integration-test/http_request/Earthfile b/wasm/integration-test/http_request/Earthfile new file mode 100644 index 0000000000..4efd3b078e --- /dev/null +++ b/wasm/integration-test/http_request/Earthfile @@ -0,0 +1,3 @@ +# Placeholder +# +# To be created after the wasm-related bump are done. \ No newline at end of file diff --git a/wasm/wasi/Earthfile b/wasm/wasi/Earthfile index 0ea8b8005a..12e6ec53b2 100644 --- a/wasm/wasi/Earthfile +++ b/wasm/wasi/Earthfile @@ -80,6 +80,7 @@ build-rust-bindings: RUN wit-bindgen rust --generate-all -w hermes:wasi/hermes ../wasi/wit SAVE ARTIFACT hermes.rs + SAVE ARTIFACT hermes.rs AS LOCAL hermes_bindings.rs # build-go-bindings - Generate tinygo bindings build-go-bindings: diff --git a/wasm/wasi/hermes_bindings.rs b/wasm/wasi/hermes_bindings.rs new file mode 100644 index 0000000000..f081b11004 --- /dev/null +++ b/wasm/wasi/hermes_bindings.rs @@ -0,0 +1,16897 @@ +// Generated by `wit-bindgen` 0.29.0. DO NOT EDIT! +// Options used: +#[allow(dead_code)] +pub mod hermes { + #[allow(dead_code)] + pub mod binary { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// Binary String (bstr) is a list of bytes. + /// This type is used to indicate the data is an arbitrary array of bytes. + pub type Bstr = _rt::Vec::; + /// 256 bit value + pub type B256 = (u64,u64,u64,u64,); + /// 512 bit value + pub type B512 = (u64,u64,u64,u64,u64,u64,u64,u64,); + + } + + } + #[allow(dead_code)] + pub mod cardano { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Bstr = super::super::super::hermes::binary::api::Bstr; + pub type Cbor = super::super::super::hermes::cbor::api::Cbor; + /// Cardano Blocks are CBOR Data + pub type CardanoBlock = Cbor; + /// Cardano Transactions are CBOR Data + pub type CardanoTxn = Cbor; + /// The ID of the blockchain to interact with. + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum CardanoBlockchainId { + Mainnet, + /// Cardano Mainnet + Preprod, + /// Cardano Preprod Network + Preview, + /// Cardano Preview Network + LocalTestBlockchain, + } + impl ::core::fmt::Debug for CardanoBlockchainId { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + CardanoBlockchainId::Mainnet => { + f.debug_tuple("CardanoBlockchainId::Mainnet").finish() + } + CardanoBlockchainId::Preprod => { + f.debug_tuple("CardanoBlockchainId::Preprod").finish() + } + CardanoBlockchainId::Preview => { + f.debug_tuple("CardanoBlockchainId::Preview").finish() + } + CardanoBlockchainId::LocalTestBlockchain => { + f.debug_tuple("CardanoBlockchainId::LocalTestBlockchain").finish() + } + } + } + } + + impl CardanoBlockchainId{ + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> CardanoBlockchainId{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => CardanoBlockchainId::Mainnet, + 1 => CardanoBlockchainId::Preprod, + 2 => CardanoBlockchainId::Preview, + 3 => CardanoBlockchainId::LocalTestBlockchain, + + _ => panic!("invalid enum discriminant"), + } + } + } + + wit_bindgen::rt::bitflags::bitflags! { + /// Source information about where the block came from, and if we are at tip or not. + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] + pub struct BlockSrc: u8 { + const TIP = 1 << 0; + const NODE = 1 << 1; + const MITHRIL = 1 << 2; + } + } + /// The Slot number to interact with + #[derive(Clone)] + pub enum Slot { + Genesis, + /// The very start of the blockchain. + Point((u64,Bstr,)), + /// A particular slot number. + Tip, + /// The TIP of the blockchain. + Continue, + } + impl ::core::fmt::Debug for Slot { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Slot::Genesis => { + f.debug_tuple("Slot::Genesis").finish() + } + Slot::Point(e) => { + f.debug_tuple("Slot::Point").field(e).finish() + } + Slot::Tip => { + f.debug_tuple("Slot::Tip").finish() + } + Slot::Continue => { + f.debug_tuple("Slot::Continue").finish() + } + } + } + } + /// Errors that can happen fetching/subscribing to blocks + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum FetchError { + BlockchainNotAvailable, + /// The blockchain requested is not available. + InvalidSlot, + } + impl FetchError{ + pub fn name(&self) -> &'static str { + match self { + FetchError::BlockchainNotAvailable => "blockchain-not-available", + FetchError::InvalidSlot => "invalid-slot", + } + } + pub fn message(&self) -> &'static str { + match self { + FetchError::BlockchainNotAvailable => "", + FetchError::InvalidSlot => "The blockchain requested is not available.", + } + } + } + impl ::core::fmt::Debug for FetchError{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("FetchError") + .field("code", &(*self as i32)) + .field("name", &self.name()) + .field("message", &self.message()) + .finish() + } + } + impl ::core::fmt::Display for FetchError{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{} (error {})", self.name(), *self as i32) + } + } + + impl std::error::Error for FetchError {} + + impl FetchError{ + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> FetchError{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => FetchError::BlockchainNotAvailable, + 1 => FetchError::InvalidSlot, + + _ => panic!("invalid enum discriminant"), + } + } + } + + /// Errors that can occur when posting transactions. + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum TxnError { + BlockchainNotAvailable, + /// The blockchain requested is not available. + MalformedTransaction, + /// The transaction is not well formed, and can not be posted. + PostTxnNotAllowed, + } + impl TxnError{ + pub fn name(&self) -> &'static str { + match self { + TxnError::BlockchainNotAvailable => "blockchain-not-available", + TxnError::MalformedTransaction => "malformed-transaction", + TxnError::PostTxnNotAllowed => "post-txn-not-allowed", + } + } + pub fn message(&self) -> &'static str { + match self { + TxnError::BlockchainNotAvailable => "", + TxnError::MalformedTransaction => "The blockchain requested is not available.", + TxnError::PostTxnNotAllowed => "The transaction is not well formed, and can not be posted.", + } + } + } + impl ::core::fmt::Debug for TxnError{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("TxnError") + .field("code", &(*self as i32)) + .field("name", &self.name()) + .field("message", &self.message()) + .finish() + } + } + impl ::core::fmt::Display for TxnError{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{} (error {})", self.name(), *self as i32) + } + } + + impl std::error::Error for TxnError {} + + impl TxnError{ + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> TxnError{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => TxnError::BlockchainNotAvailable, + 1 => TxnError::MalformedTransaction, + 2 => TxnError::PostTxnNotAllowed, + + _ => panic!("invalid enum discriminant"), + } + } + } + + wit_bindgen::rt::bitflags::bitflags! { + /// Options used to unsubscribe from the blockchain data flow. + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] + pub struct UnsubscribeOptions: u8 { + const BLOCK = 1 << 0; + /// Stop receiving block data + const TRANSACTION = 1 << 1; + /// Stop receiving txn data + const ROLLBACK = 1 << 2; + /// Stop receiving rollback data + const STOP = 1 << 3; + } + } + #[allow(unused_unsafe, clippy::all)] + /// Subscribe to the Blockchain block data. + /// + /// **Parameters** + /// + /// - `net` : The blockchain network to fetch block from, and subscribe to. + /// - `whence`: Where to start fetching blocks from. + /// + /// **Returns** + /// + /// - `ok(u64)` : The slot we are synching from now. + /// - `error(fetch-error)` : If an error occured. + /// + /// **Notes** + /// + /// If the blockchain is not yet syncing, it will start, from the requested slot. + /// If the blockchain is not yet syncing, and `whence` == `continue` then the blockchain will + /// not be synced from, the calling module will only be subscribed for block events. + /// + /// If the blockchain is already syncing, the sync will stop and restart, unless `whence` == `continue`. + /// When `whence` == `continue` the blockchain will keep syncing from where it is at, and this module + /// will be subscribed to block updates. + /// + /// `whence` == `stop` will prevent the blockchain syncing, and the caller will be unsubscribed. + pub fn subscribe_blocks(net: CardanoBlockchainId,whence: &Slot,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let (result2_0,result2_1,result2_2,result2_3,) = match whence { + Slot::Genesis=> { + (0i32, 0i64, ::core::ptr::null_mut(), 0usize) + } + Slot::Point(e) => { + let (t0_0, t0_1, ) = e; + let vec1 = t0_1; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + (1i32, _rt::as_i64(t0_0), ptr1.cast_mut(), len1) + }, + Slot::Tip=> { + (2i32, 0i64, ::core::ptr::null_mut(), 0usize) + } + Slot::Continue=> { + (3i32, 0i64, ::core::ptr::null_mut(), 0usize) + } + }; + let ptr3 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:cardano/api")] + extern "C" { + #[link_name = "subscribe-blocks"] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(net.clone() as i32, result2_0, result2_1, result2_2, result2_3, ptr3); + let l4 = i32::from(*ptr3.add(0).cast::()); + match l4 { + 0 => { + let e = { + let l5 = *ptr3.add(8).cast::(); + + l5 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from(*ptr3.add(8).cast::()); + + FetchError::_lift(l6 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Unsubscribe from the blockchain events listed. + /// + /// **Parameters** + /// + /// - `opts` : The events to unsubscribe from (and optionally stop the blockchain follower). + /// + /// **Notes** + /// + /// This only unsubscribes from the events. + /// The option `stop` MUST be set to actually stop fetching data from the blockchain once started. + /// + /// `stop` can be set without unsubscribing, and this will interrupt the flow of blockchain data. + /// After `stop`, `subscribe-blocks(?, continue)` would cause blockchain sync to continue from + /// the last block received. This would result in the last block being sent as an event twice, + /// once before the `stop` and once after the `continue`. + pub fn unsubscribe(net: CardanoBlockchainId,opts: UnsubscribeOptions,){ + unsafe { + let flags0 = opts; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:cardano/api")] + extern "C" { + #[link_name = "unsubscribe"] + fn wit_import(_: i32, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, ){ unreachable!() } + wit_import(net.clone() as i32, (flags0.bits() >> 0) as i32); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Subscribe to transaction data events, does not alter the blockchain sync in anyway. + /// + /// **Parameters** + /// + /// - `net` : The blockchain network to subscribe to txn events from. + pub fn subscribe_txn(net: CardanoBlockchainId,){ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:cardano/api")] + extern "C" { + #[link_name = "subscribe-txn"] + fn wit_import(_: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ){ unreachable!() } + wit_import(net.clone() as i32); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Subscribe to blockchain rollback events, does not alter the blockchain sync in anyway. + /// + /// **Parameters** + /// + /// - `net` : The blockchain network to subscribe to txn events from. + /// + /// **Notes** + /// + /// After a rollback event, the blockchain sync will AUTOMATICALLY start sending block + /// data from the rollback point. No action is required to actually follow the rollback, unless the + /// default behavior is not desired. + pub fn subscribe_rollback(net: CardanoBlockchainId,){ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:cardano/api")] + extern "C" { + #[link_name = "subscribe-rollback"] + fn wit_import(_: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ){ unreachable!() } + wit_import(net.clone() as i32); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Fetch a block from the requested blockchain at the requested slot. + /// + /// **Parameters** + /// + /// - `net` : The blockchain network to get a block from. + /// - `whence` : Which block to get. + /// + /// **Returns** + /// + /// - `cardano-block` : The block requested. + /// - `fetch-error` : An error if the block can not be fetched. + /// + /// **Notes** + /// + /// Fetching a block does not require the blockchain to be subscribed, or for blocks to be + /// being followed and generating events. + /// It also will not alter the automatic fetching of blocks in any way, and happens in parallel + /// to automated block fetch. + pub fn fetch_block(net: CardanoBlockchainId,whence: &Slot,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let (result2_0,result2_1,result2_2,result2_3,) = match whence { + Slot::Genesis=> { + (0i32, 0i64, ::core::ptr::null_mut(), 0usize) + } + Slot::Point(e) => { + let (t0_0, t0_1, ) = e; + let vec1 = t0_1; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + (1i32, _rt::as_i64(t0_0), ptr1.cast_mut(), len1) + }, + Slot::Tip=> { + (2i32, 0i64, ::core::ptr::null_mut(), 0usize) + } + Slot::Continue=> { + (3i32, 0i64, ::core::ptr::null_mut(), 0usize) + } + }; + let ptr3 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:cardano/api")] + extern "C" { + #[link_name = "fetch-block"] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(net.clone() as i32, result2_0, result2_1, result2_2, result2_3, ptr3); + let l4 = i32::from(*ptr3.add(0).cast::()); + match l4 { + 0 => { + let e = { + let l5 = *ptr3.add(4).cast::<*mut u8>(); + let l6 = *ptr3.add(8).cast::(); + let len7 = l6; + + _rt::Vec::from_raw_parts(l5.cast(), len7, len7) + }; + Ok(e) + } + 1 => { + let e = { + let l8 = i32::from(*ptr3.add(4).cast::()); + + FetchError::_lift(l8 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Get transactions from a block. + /// + /// This can be used to easily extract all transactions from a complete block. + /// + /// **Parameters** + /// + /// - `block` : The blockchain data to extract transactions from. + /// + /// **Returns** + /// + /// - a list of all transactions in the block, in the order they appear in the block. + /// + /// **Notes** + /// + /// This function exists to support `fetch-block`. + /// Transactions from subscribed block events, should be processed as transaction events. + pub fn get_txns(block: &CardanoBlock,) -> _rt::Vec::{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = block; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:cardano/api")] + extern "C" { + #[link_name = "get-txns"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let base7 = l2; + let len7 = l3; + let mut result7 = _rt::Vec::with_capacity(len7); + for i in 0..len7 { + let base = base7.add(i * 8); + let e7 = { + let l4 = *base.add(0).cast::<*mut u8>(); + let l5 = *base.add(4).cast::(); + let len6 = l5; + + _rt::Vec::from_raw_parts(l4.cast(), len6, len6) + }; + result7.push(e7); + } + _rt::cabi_dealloc(base7, len7 * 8, 4); + result7 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Post a transactions to the blockchain. + /// + /// This can be used to post a pre-formed transaction to the required blockchain. + /// + /// **Parameters** + /// + /// - `net` : The blockchain to post the transaction to. + /// - `txn` : The transaction data, ready to submit. + /// + /// **Returns** + /// + /// - An error if the transaction can not be posted. + /// + /// **Notes** + /// + /// This is proposed functionality, and is not yet active. + /// All calls to this function will return `post-txn-not-allowed` error. + pub fn post_txn(net: CardanoBlockchainId,txn: &CardanoTxn,) -> Result<(),TxnError>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = txn; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:cardano/api")] + extern "C" { + #[link_name = "post-txn"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(net.clone() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + + TxnError::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + + } + + } + #[allow(dead_code)] + pub mod cbor { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + pub type Bstr = super::super::super::hermes::binary::api::Bstr; + /// CBOR is a binary cbor data type. + /// This type is used to indicate the binary array MUST be CBOR data. + pub type Cbor = Bstr; + + } + + } + #[allow(dead_code)] + pub mod cron { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Instant = super::super::super::wasi::clocks::monotonic_clock::Instant; + /// A Tag used to mark a delivered cron event. + pub type CronEventTag = _rt::String; + /// A cron schedule in crontab format. + pub type CronSched = _rt::String; + /// A tagged crontab entry + /// It is valid for multiple crontab entries at the same time to have different tags. + /// It is valid for crontab entries at different times to have the same tag. + /// BUT there can only ever be 1 crontab entry at a specified time with a specified tag. + /// ie, `when` + `tag` is uniquely identifying of every crontab entry. + /// See: [crontab.5 man page](https://www.man7.org/linux/man-pages/man5/crontab.5.html) for details on cron schedule format. + #[derive(Clone)] + pub struct CronTagged { + /// The crontab entry in standard cron format. + /// The Time is ALWAYS relative to UTC and does not account for local time. + /// If Localtime adjustment is required it must be handled by the module. + pub when: CronSched, + /// The tag associated with the crontab entry. + pub tag: CronEventTag, + } + impl ::core::fmt::Debug for CronTagged { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("CronTagged").field("when", &self.when).field("tag", &self.tag).finish() + } + } + /// A discreet time entry used to help convert numeric times into crontab entries. + #[derive(Clone, Copy)] + pub enum CronComponent { + /// Maps to `*` in a cron schedule (ie, match all) + All, + /// Match an absolute time/date + At(u8), + /// Match an inclusive list of time/date values. + Range((u8,u8,)), + } + impl ::core::fmt::Debug for CronComponent { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + CronComponent::All => { + f.debug_tuple("CronComponent::All").finish() + } + CronComponent::At(e) => { + f.debug_tuple("CronComponent::At").field(e).finish() + } + CronComponent::Range(e) => { + f.debug_tuple("CronComponent::Range").field(e).finish() + } + } + } + } + /// A list of cron time components + pub type CronTime = _rt::Vec::; + #[allow(unused_unsafe, clippy::all)] + /// # Schedule Recurrent CRON event + /// + /// Cron events will be delivered to the `on-cron` event handler. + /// + /// ## Parameters + /// + /// - `entry`: The crontab entry to add. + /// - `when`: When the event triggers. Standard crontab format. + /// - `tag`: A tag which will accompany the triggered event. + /// - `retrigger`: + /// - `true`: The event will re-trigger every time the crontab entry matches until cancelled. + /// - `false`: The event will automatically cancel after it is generated once. + /// + /// ## Returns + /// + /// - `true`: Crontab added successfully. (Or the crontab event already exists) + /// - `false`: Crontab failed to be added. + /// + /// ## Note: + /// + /// If the crontab entry already exists, the retrigger flag can be changed by calling + /// this function. This could be useful where a retriggering crontab event is desired + /// to be stopped, but ONLY after it has triggered once more. + pub fn add(entry: &CronTagged,retrigger: bool,) -> bool{ + unsafe { + let CronTagged{ when:when0, tag:tag0, } = entry; + let vec1 = when0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let vec2 = tag0; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:cron/api")] + extern "C" { + #[link_name = "add"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: i32, ) -> i32{ unreachable!() } + let ret = wit_import(ptr1.cast_mut(), len1, ptr2.cast_mut(), len2, match &retrigger { true => 1, false => 0 }); + _rt::bool_lift(ret as u8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// # Schedule A Single cron event after a fixed delay. + /// + /// Allows for easy timed wait events to be delivered without + /// requiring datetime calculations or formatting cron entries. + /// + /// ## Parameters + /// + /// - `duration`: How many nanoseconds to delay. The delay will be AT LEAST this long. + /// - `tag`: A tag which will accompany the triggered event. + /// + /// ## Returns + /// + /// - `true`: Crontab added successfully. + /// - `false`: Crontab failed to be added. + /// + /// ## Note: + /// + /// This is a convenience function which will automatically calculate the crontab + /// entry needed to trigger the event after the requested `duration`. + /// It is added as a non-retriggering event. + /// Listing the crontabs after this call will list the delay in addition to all other + /// crontab entries. + pub fn delay(duration: Instant,tag: &CronEventTag,) -> bool{ + unsafe { + let vec0 = tag; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:cron/api")] + extern "C" { + #[link_name = "delay"] + fn wit_import(_: i64, _: *mut u8, _: usize, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: *mut u8, _: usize, ) -> i32{ unreachable!() } + let ret = wit_import(_rt::as_i64(duration), ptr0.cast_mut(), len0); + _rt::bool_lift(ret as u8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// # List currently active cron schedule. + /// + /// Allows for management of scheduled cron events. + /// + /// ## Parameters + /// + /// - `tag`: Optional, the tag to limit the list to. If `none` then all crons listed. + /// + /// ## Returns + /// + /// - A list of tuples containing the scheduled crontabs and their tags, along with the current retrigger flag. + /// The list is sorted from most crontab that will trigger soonest to latest. + /// Crontabs are only listed once, in the case where a crontab may be scheduled + /// may times before a later one. + /// - `0` - `cron-tagged` - The Tagged crontab event. + /// - `1` - `bool` - The state of the retrigger flag. + pub fn ls(tag: Option<&CronEventTag>,) -> _rt::Vec::<(CronTagged,bool,)>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let (result1_0,result1_1,result1_2,) = match tag { + Some(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (1i32, ptr0.cast_mut(), len0) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:cron/api")] + extern "C" { + #[link_name = "ls"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(result1_0, result1_1, result1_2, ptr2); + let l3 = *ptr2.add(0).cast::<*mut u8>(); + let l4 = *ptr2.add(4).cast::(); + let base12 = l3; + let len12 = l4; + let mut result12 = _rt::Vec::with_capacity(len12); + for i in 0..len12 { + let base = base12.add(i * 20); + let e12 = { + let l5 = *base.add(0).cast::<*mut u8>(); + let l6 = *base.add(4).cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts(l5.cast(), len7, len7); + let l8 = *base.add(8).cast::<*mut u8>(); + let l9 = *base.add(12).cast::(); + let len10 = l9; + let bytes10 = _rt::Vec::from_raw_parts(l8.cast(), len10, len10); + let l11 = i32::from(*base.add(16).cast::()); + + (CronTagged{ + when: _rt::string_lift(bytes7), + tag: _rt::string_lift(bytes10), + }, _rt::bool_lift(l11 as u8)) + }; + result12.push(e12); + } + _rt::cabi_dealloc(base12, len12 * 20, 4); + result12 + } + } + #[allow(unused_unsafe, clippy::all)] + /// # Remove the requested crontab. + /// + /// Allows for management of scheduled cron events. + /// + /// ## Parameters + /// + /// - `when`: The crontab entry to add. Standard crontab format. + /// - `tag`: A tag which will accompany the triggered event. + /// + /// ## Returns + /// + /// - `true`: The requested crontab was deleted and will not trigger. + /// - `false`: The requested crontab does not exist. + pub fn rm(entry: &CronTagged,) -> bool{ + unsafe { + let CronTagged{ when:when0, tag:tag0, } = entry; + let vec1 = when0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let vec2 = tag0; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:cron/api")] + extern "C" { + #[link_name = "rm"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, ) -> i32{ unreachable!() } + let ret = wit_import(ptr1.cast_mut(), len1, ptr2.cast_mut(), len2); + _rt::bool_lift(ret as u8) + } + } + #[allow(unused_unsafe, clippy::all)] + /// # Make a crontab entry from individual time values. + /// + /// Crates the properly formatted cron entry + /// from numeric cron time components. + /// Convenience function to make building cron strings simpler when they are + /// calculated from data. + /// + /// ## Parameters + /// + /// - `dow` - DayOfWeek (0-7, 0 or 7 = Sunday) + /// - `month` - Month of the year (1-12, 1 = January) + /// - `day` - Day in the month (1-31) + /// - `hour` - Hour in the day (0-23) + /// - `minute` - Minute in the hour (0-59) + /// + /// ## Returns + /// + /// - A matching `cron-sched` ready for use in the cron functions above. + /// + /// ## Note: + /// No checking is done to determine if the requested date is valid. + /// If a particular component is out of its allowable range it will be silently + /// clamped within the allowable range of each parameter. + /// Redundant entries will be removed. + /// - For example specifying a `month` as `3` and `2-4` will + /// remove the individual month and only produce the range. + pub fn mkcron(dow: &CronTime,month: &CronTime,day: &CronTime,hour: &CronTime,minute: &CronTime,) -> CronSched{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec1 = dow; + let len1 = vec1.len(); + let layout1 = _rt::alloc::Layout::from_size_align_unchecked(vec1.len() * 3, 1); + let result1 = if layout1.size() != 0 { + let ptr = _rt::alloc::alloc(layout1).cast::(); + if ptr.is_null() + { + _rt::alloc::handle_alloc_error(layout1); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec1.into_iter().enumerate() { + let base = result1.add(i * 3); + { + match e { + CronComponent::All=> { + { + *base.add(0).cast::() = (0i32) as u8; + } + } + CronComponent::At(e) => { + *base.add(0).cast::() = (1i32) as u8; + *base.add(1).cast::() = (_rt::as_i32(e)) as u8; + }, + CronComponent::Range(e) => { + *base.add(0).cast::() = (2i32) as u8; + let (t0_0, t0_1, ) = e; + *base.add(1).cast::() = (_rt::as_i32(t0_0)) as u8; + *base.add(2).cast::() = (_rt::as_i32(t0_1)) as u8; + }, + } + } + } + let vec3 = month; + let len3 = vec3.len(); + let layout3 = _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 3, 1); + let result3 = if layout3.size() != 0 { + let ptr = _rt::alloc::alloc(layout3).cast::(); + if ptr.is_null() + { + _rt::alloc::handle_alloc_error(layout3); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec3.into_iter().enumerate() { + let base = result3.add(i * 3); + { + match e { + CronComponent::All=> { + { + *base.add(0).cast::() = (0i32) as u8; + } + } + CronComponent::At(e) => { + *base.add(0).cast::() = (1i32) as u8; + *base.add(1).cast::() = (_rt::as_i32(e)) as u8; + }, + CronComponent::Range(e) => { + *base.add(0).cast::() = (2i32) as u8; + let (t2_0, t2_1, ) = e; + *base.add(1).cast::() = (_rt::as_i32(t2_0)) as u8; + *base.add(2).cast::() = (_rt::as_i32(t2_1)) as u8; + }, + } + } + } + let vec5 = day; + let len5 = vec5.len(); + let layout5 = _rt::alloc::Layout::from_size_align_unchecked(vec5.len() * 3, 1); + let result5 = if layout5.size() != 0 { + let ptr = _rt::alloc::alloc(layout5).cast::(); + if ptr.is_null() + { + _rt::alloc::handle_alloc_error(layout5); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec5.into_iter().enumerate() { + let base = result5.add(i * 3); + { + match e { + CronComponent::All=> { + { + *base.add(0).cast::() = (0i32) as u8; + } + } + CronComponent::At(e) => { + *base.add(0).cast::() = (1i32) as u8; + *base.add(1).cast::() = (_rt::as_i32(e)) as u8; + }, + CronComponent::Range(e) => { + *base.add(0).cast::() = (2i32) as u8; + let (t4_0, t4_1, ) = e; + *base.add(1).cast::() = (_rt::as_i32(t4_0)) as u8; + *base.add(2).cast::() = (_rt::as_i32(t4_1)) as u8; + }, + } + } + } + let vec7 = hour; + let len7 = vec7.len(); + let layout7 = _rt::alloc::Layout::from_size_align_unchecked(vec7.len() * 3, 1); + let result7 = if layout7.size() != 0 { + let ptr = _rt::alloc::alloc(layout7).cast::(); + if ptr.is_null() + { + _rt::alloc::handle_alloc_error(layout7); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec7.into_iter().enumerate() { + let base = result7.add(i * 3); + { + match e { + CronComponent::All=> { + { + *base.add(0).cast::() = (0i32) as u8; + } + } + CronComponent::At(e) => { + *base.add(0).cast::() = (1i32) as u8; + *base.add(1).cast::() = (_rt::as_i32(e)) as u8; + }, + CronComponent::Range(e) => { + *base.add(0).cast::() = (2i32) as u8; + let (t6_0, t6_1, ) = e; + *base.add(1).cast::() = (_rt::as_i32(t6_0)) as u8; + *base.add(2).cast::() = (_rt::as_i32(t6_1)) as u8; + }, + } + } + } + let vec9 = minute; + let len9 = vec9.len(); + let layout9 = _rt::alloc::Layout::from_size_align_unchecked(vec9.len() * 3, 1); + let result9 = if layout9.size() != 0 { + let ptr = _rt::alloc::alloc(layout9).cast::(); + if ptr.is_null() + { + _rt::alloc::handle_alloc_error(layout9); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec9.into_iter().enumerate() { + let base = result9.add(i * 3); + { + match e { + CronComponent::All=> { + { + *base.add(0).cast::() = (0i32) as u8; + } + } + CronComponent::At(e) => { + *base.add(0).cast::() = (1i32) as u8; + *base.add(1).cast::() = (_rt::as_i32(e)) as u8; + }, + CronComponent::Range(e) => { + *base.add(0).cast::() = (2i32) as u8; + let (t8_0, t8_1, ) = e; + *base.add(1).cast::() = (_rt::as_i32(t8_0)) as u8; + *base.add(2).cast::() = (_rt::as_i32(t8_1)) as u8; + }, + } + } + } + let ptr10 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:cron/api")] + extern "C" { + #[link_name = "mkcron"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(result1, len1, result3, len3, result5, len5, result7, len7, result9, len9, ptr10); + let l11 = *ptr10.add(0).cast::<*mut u8>(); + let l12 = *ptr10.add(4).cast::(); + let len13 = l12; + let bytes13 = _rt::Vec::from_raw_parts(l11.cast(), len13, len13); + if layout1.size() != 0 { + _rt::alloc::dealloc(result1.cast(), layout1); + } + if layout3.size() != 0 { + _rt::alloc::dealloc(result3.cast(), layout3); + } + if layout5.size() != 0 { + _rt::alloc::dealloc(result5.cast(), layout5); + } + if layout7.size() != 0 { + _rt::alloc::dealloc(result7.cast(), layout7); + } + if layout9.size() != 0 { + _rt::alloc::dealloc(result9.cast(), layout9); + } + _rt::string_lift(bytes13) + } + } + + } + + } + #[allow(dead_code)] + pub mod crypto { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Bstr = super::super::super::hermes::binary::api::Bstr; + pub type B256 = super::super::super::hermes::binary::api::B256; + pub type B512 = super::super::super::hermes::binary::api::B512; + /// Errors that can occurs. + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum Errno { + PrefixTooLong, + /// The prefix is longer than the maximum allowed length, max is 3. + InvalidMnemonicLength, + /// The mnemonic length is not a multiple of 3 or not in the range of 12 - 24. + WordNotFound, + /// A word in the mnemonic is not found in the word list. + InvalidMnemonic, + /// The mnemonic is invalid. + InvalidDerivationalPath, + /// The derivational path is invalid. + GenerateEntropyFailed, + /// Failed to generate entropy. + UnsupportedLanguage, + } + impl Errno{ + pub fn name(&self) -> &'static str { + match self { + Errno::PrefixTooLong => "prefix-too-long", + Errno::InvalidMnemonicLength => "invalid-mnemonic-length", + Errno::WordNotFound => "word-not-found", + Errno::InvalidMnemonic => "invalid-mnemonic", + Errno::InvalidDerivationalPath => "invalid-derivational-path", + Errno::GenerateEntropyFailed => "generate-entropy-failed", + Errno::UnsupportedLanguage => "unsupported-language", + } + } + pub fn message(&self) -> &'static str { + match self { + Errno::PrefixTooLong => "", + Errno::InvalidMnemonicLength => "The prefix is longer than the maximum allowed length, max is 3.", + Errno::WordNotFound => "The mnemonic length is not a multiple of 3 or not in the range of 12 - 24.", + Errno::InvalidMnemonic => "A word in the mnemonic is not found in the word list.", + Errno::InvalidDerivationalPath => "The mnemonic is invalid.", + Errno::GenerateEntropyFailed => "The derivational path is invalid.", + Errno::UnsupportedLanguage => "Failed to generate entropy.", + } + } + } + impl ::core::fmt::Debug for Errno{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Errno") + .field("code", &(*self as i32)) + .field("name", &self.name()) + .field("message", &self.message()) + .finish() + } + } + impl ::core::fmt::Display for Errno{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{} (error {})", self.name(), *self as i32) + } + } + + impl std::error::Error for Errno {} + + impl Errno{ + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> Errno{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => Errno::PrefixTooLong, + 1 => Errno::InvalidMnemonicLength, + 2 => Errno::WordNotFound, + 3 => Errno::InvalidMnemonic, + 4 => Errno::InvalidDerivationalPath, + 5 => Errno::GenerateEntropyFailed, + 6 => Errno::UnsupportedLanguage, + + _ => panic!("invalid enum discriminant"), + } + } + } + + /// bip32-ed25519 Public Key + pub type Bip32Ed25519PublicKey = B256; + /// bip32-ed25519 Signature + pub type Bip32Ed25519Signature = B512; + /// Mnemonic + pub type MnemonicPhrase = _rt::Vec::<_rt::String>; + /// Passphrase + pub type Passphrase = _rt::Vec::<_rt::String>; + /// Derivation path + pub type Path = _rt::String; + pub type Prefix = _rt::Vec::<_rt::String>; + + #[derive(Debug)] + #[repr(transparent)] + pub struct Bip32Ed25519{ + handle: _rt::Resource, + } + + impl Bip32Ed25519{ + #[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 Bip32Ed25519{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "hermes:crypto/api")] + extern "C" { + #[link_name = "[resource-drop]bip32-ed25519"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[allow(unused_unsafe, clippy::all)] + /// # Generate BIP39 Mnemonic Function + /// + /// Generate a new BIP39 mnemonic phrase with the given + /// size, prefix and language. + /// + /// ## Parameters + /// + /// `size` : The size of the mnemonic. Must be a multiple of 3 and in the range of 12 - 24. + /// `prefix` : The prefix for the mnemonic. Must be a list of 1 - 3 words. + /// `language` : Optional. The language to use for the mnemonic. + /// If not provided, the default language is used. + /// + /// ## Returns + /// + /// - Either a list of mnemonic words. + /// - Or an error if the mnemonic could not be generated: + /// - `prefix-too-long` : The prefix is longer than the maximum allowed length, max is 3. + /// - `invalid-mnemonic-length` : The mnemonic length is not a multiple of 3 or not in the range of 12 - 24. + /// - `word-not-found` : A word in the mnemonic is not found in the word list. + /// - `generate-entropy-failed` : Failed to generate entropy. + pub fn generate_mnemonic(size: u8,prefix: &Prefix,language: Option<&str>,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec1 = prefix; + let len1 = vec1.len(); + let layout1 = _rt::alloc::Layout::from_size_align_unchecked(vec1.len() * 8, 4); + let result1 = if layout1.size() != 0 { + let ptr = _rt::alloc::alloc(layout1).cast::(); + if ptr.is_null() + { + _rt::alloc::handle_alloc_error(layout1); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec1.into_iter().enumerate() { + let base = result1.add(i * 8); + { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + *base.add(4).cast::() = len0; + *base.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + } + let (result3_0,result3_1,result3_2,) = match language { + Some(e) => { + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + (1i32, ptr2.cast_mut(), len2) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let ptr4 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:crypto/api")] + extern "C" { + #[link_name = "generate-mnemonic"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(_rt::as_i32(&size), result1, len1, result3_0, result3_1, result3_2, ptr4); + let l5 = i32::from(*ptr4.add(0).cast::()); + if layout1.size() != 0 { + _rt::alloc::dealloc(result1.cast(), layout1); + } + match l5 { + 0 => { + let e = { + let l6 = *ptr4.add(4).cast::<*mut u8>(); + let l7 = *ptr4.add(8).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); + + result11 + }; + Ok(e) + } + 1 => { + let e = { + let l12 = i32::from(*ptr4.add(4).cast::()); + + Errno::_lift(l12 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + impl Bip32Ed25519 { + #[allow(unused_unsafe, clippy::all)] + /// Create a new BIP32-Ed25519 Crypto resource + /// + /// **Parameters** + /// + /// - `mnemonic-phrase` : BIP39 mnemonic. + /// - `passphrase` : Optional BIP39 passphrase. + pub fn new(mnemonic: &MnemonicPhrase,passphrase: Option<&Passphrase>,) -> Self{ + unsafe { + let mut cleanup_list = _rt::Vec::new(); + let vec1 = mnemonic; + let len1 = vec1.len(); + let layout1 = _rt::alloc::Layout::from_size_align_unchecked(vec1.len() * 8, 4); + let result1 = if layout1.size() != 0 { + let ptr = _rt::alloc::alloc(layout1).cast::(); + if ptr.is_null() + { + _rt::alloc::handle_alloc_error(layout1); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec1.into_iter().enumerate() { + let base = result1.add(i * 8); + { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + *base.add(4).cast::() = len0; + *base.add(0).cast::<*mut u8>() = ptr0.cast_mut(); + } + } + let (result4_0,result4_1,result4_2,) = match passphrase { + Some(e) => { + let vec3 = e; + let len3 = vec3.len(); + let layout3 = _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 4); + let result3 = if layout3.size() != 0 { + let ptr = _rt::alloc::alloc(layout3).cast::(); + if ptr.is_null() + { + _rt::alloc::handle_alloc_error(layout3); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec3.into_iter().enumerate() { + let base = result3.add(i * 8); + { + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(4).cast::() = len2; + *base.add(0).cast::<*mut u8>() = ptr2.cast_mut(); + } + } + cleanup_list.extend_from_slice(&[(result3, layout3),]); + + (1i32, result3, len3) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:crypto/api")] + extern "C" { + #[link_name = "[constructor]bip32-ed25519"] + fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } + let ret = wit_import(result1, len1, result4_0, result4_1, result4_2); + if layout1.size() != 0 { + _rt::alloc::dealloc(result1.cast(), layout1); + } + for (ptr, layout) in cleanup_list { + + if layout.size() != 0 { + + _rt::alloc::dealloc(ptr.cast(), layout); + + } + + } + Bip32Ed25519::from_handle(ret as u32) + } + } + } + impl Bip32Ed25519 { + #[allow(unused_unsafe, clippy::all)] + /// Get the public key for this private key. + pub fn public_key(&self,) -> Bip32Ed25519PublicKey{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 32]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 32]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:crypto/api")] + extern "C" { + #[link_name = "[method]bip32-ed25519.public-key"] + 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 = *ptr0.add(0).cast::(); + let l2 = *ptr0.add(8).cast::(); + let l3 = *ptr0.add(16).cast::(); + let l4 = *ptr0.add(24).cast::(); + (l1 as u64, l2 as u64, l3 as u64, l4 as u64) + } + } + } + impl Bip32Ed25519 { + #[allow(unused_unsafe, clippy::all)] + /// Sign data with the Private key, and return it. + /// + /// **Parameters** + /// + /// - `data` : The data to sign. + pub fn sign_data(&self,data: &Bstr,) -> Bip32Ed25519Signature{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 64]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 64]); + let vec0 = data; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:crypto/api")] + extern "C" { + #[link_name = "[method]bip32-ed25519.sign-data"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = *ptr1.add(0).cast::(); + let l3 = *ptr1.add(8).cast::(); + let l4 = *ptr1.add(16).cast::(); + let l5 = *ptr1.add(24).cast::(); + let l6 = *ptr1.add(32).cast::(); + let l7 = *ptr1.add(40).cast::(); + let l8 = *ptr1.add(48).cast::(); + let l9 = *ptr1.add(56).cast::(); + (l2 as u64, l3 as u64, l4 as u64, l5 as u64, l6 as u64, l7 as u64, l8 as u64, l9 as u64) + } + } + } + impl Bip32Ed25519 { + #[allow(unused_unsafe, clippy::all)] + /// Check a signature on a set of data. + /// + /// **Parameters** + /// + /// - `data` : The data to check. + /// - `sig` : The signature to check. + /// + /// **Returns** + /// + /// - `true` : Signature checked OK. + /// - `false` : Signature check failed. + pub fn check_sig(&self,data: &Bstr,sig: Bip32Ed25519Signature,) -> bool{ + unsafe { + let vec0 = data; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let (t1_0, t1_1, t1_2, t1_3, t1_4, t1_5, t1_6, t1_7, ) = sig; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:crypto/api")] + extern "C" { + #[link_name = "[method]bip32-ed25519.check-sig"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32, ptr0.cast_mut(), len0, _rt::as_i64(t1_0), _rt::as_i64(t1_1), _rt::as_i64(t1_2), _rt::as_i64(t1_3), _rt::as_i64(t1_4), _rt::as_i64(t1_5), _rt::as_i64(t1_6), _rt::as_i64(t1_7)); + _rt::bool_lift(ret as u8) + } + } + } + impl Bip32Ed25519 { + #[allow(unused_unsafe, clippy::all)] + /// Derive a new private key from the current private key. + /// + /// **Parameters** + /// + /// - `path` : Derivation path. + /// + /// Note: uses BIP32 HD key derivation. + pub fn derive(&self,path: &Path,) -> Bip32Ed25519{ + unsafe { + let vec0 = path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:crypto/api")] + extern "C" { + #[link_name = "[method]bip32-ed25519.derive"] + fn wit_import(_: i32, _: *mut u8, _: usize, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32, ptr0.cast_mut(), len0); + Bip32Ed25519::from_handle(ret as u32) + } + } + } + + } + + } + #[allow(dead_code)] + pub mod hash { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Bstr = super::super::super::hermes::binary::api::Bstr; + /// Errors that can occur during hashing. + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum Errno { + KeyTooBig, + /// The key exceeds the supported size of the hash function. + HashTooBig, + /// The hash size requested is larger than supported by the hash function. + SaltTooBig, + /// The salt exceeds the supported size of the hash function. + PersonalTooBig, + /// The personal exceeds the supported size of the hash function. + InvalidDigestByteLength, + } + impl Errno{ + pub fn name(&self) -> &'static str { + match self { + Errno::KeyTooBig => "key-too-big", + Errno::HashTooBig => "hash-too-big", + Errno::SaltTooBig => "salt-too-big", + Errno::PersonalTooBig => "personal-too-big", + Errno::InvalidDigestByteLength => "invalid-digest-byte-length", + } + } + pub fn message(&self) -> &'static str { + match self { + Errno::KeyTooBig => "", + Errno::HashTooBig => "The key exceeds the supported size of the hash function.", + Errno::SaltTooBig => "The hash size requested is larger than supported by the hash function.", + Errno::PersonalTooBig => "The salt exceeds the supported size of the hash function.", + Errno::InvalidDigestByteLength => "The personal exceeds the supported size of the hash function.", + } + } + } + impl ::core::fmt::Debug for Errno{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Errno") + .field("code", &(*self as i32)) + .field("name", &self.name()) + .field("message", &self.message()) + .finish() + } + } + impl ::core::fmt::Display for Errno{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{} (error {})", self.name(), *self as i32) + } + } + + impl std::error::Error for Errno {} + + impl Errno{ + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> Errno{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => Errno::KeyTooBig, + 1 => Errno::HashTooBig, + 2 => Errno::SaltTooBig, + 3 => Errno::PersonalTooBig, + 4 => Errno::InvalidDigestByteLength, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[allow(unused_unsafe, clippy::all)] + /// # BLAKE2s Hash Function + /// + /// Hash a binary buffer with BLAKE2s. + /// + /// ## Parameters + /// + /// - `buf`: The binary data buffer to hash. + /// - `outlen`: Optional. The size of the digest. + /// If the outlen is not defined, it defaults to 32. + /// + /// ## Returns + /// + /// - Either a buffer the size requested, with the hash. + /// - Or an error: + /// - `hash_too_big` if `outlen` is specified and is > 32 bytes. + /// - `invalid_digest_byte_length` if `outlen` is specified and is = 0. + pub fn blake2s(buf: &Bstr,outlen: Option,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = buf; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let (result1_0,result1_1,) = match outlen { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + };let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:hash/api")] + extern "C" { + #[link_name = "blake2s"] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, result1_0, result1_1, ptr2); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = { + let l4 = *ptr2.add(4).cast::<*mut u8>(); + let l5 = *ptr2.add(8).cast::(); + let len6 = l5; + + _rt::Vec::from_raw_parts(l4.cast(), len6, len6) + }; + Ok(e) + } + 1 => { + let e = { + let l7 = i32::from(*ptr2.add(4).cast::()); + + Errno::_lift(l7 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// # BLAKE2sMac Hash Function + /// + /// Hash a binary buffer with BLAKE2s with MAC (Message Authentication Code) mode. + /// + /// ## Parameters + /// + /// - `buf`: The binary data buffer to hash. + /// - `outlen`: Optional. The size of the digest. + /// If the outlen is not defined, it defaults to 32. + /// - `key`: The key to use with the hash. + /// With MAC mode, key is needed to be defined + /// Should not be > 32 bytes. + /// - `salt`: Optional. Salt uses to increase the randomness and + /// uniqueness of the hash output + /// Should not be > 8 bytes. + /// If not defined, salt is not used. + /// - `personal`: Optional. Personal allows to + /// add customization to the hash function behavior. + /// Should not be > 8 bytes. + /// If not defined, personal is not used. + /// + /// ## Returns + /// + /// - Either a buffer the size requested, with the hash. + /// - Or an error: + /// - `key_too_big` if `key` is > 32 bytes. + /// - `hash_too_big` if `outlen` is specified and is > 32 bytes. + /// - `salt_too_big` if `salt` is specified and is > 8 bytes. + /// - `personal_too_big` if `personal` is specified and is > 8 bytes. + /// + /// ## Note: + /// + /// `key` length is checked before `outlen` so if both sizes are invalid, only + /// `key_too_big` will be returned. + /// If `salt` length exceeds 8 bytes, `salt_too_big` will be returned. + /// if `personal` length exceeds 8 bytes, `personal_too_big` will be returned. + pub fn blake2smac(buf: &Bstr,outlen: Option,key: &Bstr,salt: Option<&Bstr>,personal: Option<&Bstr>,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = buf; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let (result1_0,result1_1,) = match outlen { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + };let vec2 = key; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let (result4_0,result4_1,result4_2,) = match salt { + Some(e) => { + let vec3 = e; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + + (1i32, ptr3.cast_mut(), len3) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let (result6_0,result6_1,result6_2,) = match personal { + Some(e) => { + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + + (1i32, ptr5.cast_mut(), len5) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let ptr7 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:hash/api")] + extern "C" { + #[link_name = "blake2smac"] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, result1_0, result1_1, ptr2.cast_mut(), len2, result4_0, result4_1, result4_2, result6_0, result6_1, result6_2, ptr7); + let l8 = i32::from(*ptr7.add(0).cast::()); + match l8 { + 0 => { + let e = { + let l9 = *ptr7.add(4).cast::<*mut u8>(); + let l10 = *ptr7.add(8).cast::(); + let len11 = l10; + + _rt::Vec::from_raw_parts(l9.cast(), len11, len11) + }; + Ok(e) + } + 1 => { + let e = { + let l12 = i32::from(*ptr7.add(4).cast::()); + + Errno::_lift(l12 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// # BLAKE2b Hash Function + /// + /// Hash a binary buffer with BLAKE2b. + /// + /// ## Parameters + /// + /// - `buf`: The binary data buffer to hash. + /// - `outlen`: Optional. The size of the digest. + /// If the outlen is not defined, it defaults to 64. + /// + /// ## Returns + /// + /// - Either a buffer the size requested, with the hash. + /// - Or an error: + /// - `hash_too_big` if `outlen` is specified and is > 64 bytes. + /// - `invalid_digest_byte_length` if `outlen` is specified and is = 0. + pub fn blake2b(buf: &Bstr,outlen: Option,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = buf; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let (result1_0,result1_1,) = match outlen { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + };let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:hash/api")] + extern "C" { + #[link_name = "blake2b"] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, result1_0, result1_1, ptr2); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = { + let l4 = *ptr2.add(4).cast::<*mut u8>(); + let l5 = *ptr2.add(8).cast::(); + let len6 = l5; + + _rt::Vec::from_raw_parts(l4.cast(), len6, len6) + }; + Ok(e) + } + 1 => { + let e = { + let l7 = i32::from(*ptr2.add(4).cast::()); + + Errno::_lift(l7 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// # BLAKE2bMac Hash Function + /// + /// Hash a binary buffer with BLAKE2b with MAC (Message Authentication Code) mode. + /// + /// ## Parameters + /// + /// - `buf`: The binary data buffer to hash. + /// - `outlen`: Optional. The size of the digest. + /// If the outlen is not defined, it defaults to 64. + /// - `key`: The key to use with the hash. + /// With MAC mode, key is needed to be defined + /// Should not be > 64 bytes. + /// - `salt`: Optional. Salt uses to increase the randomness and + /// uniqueness of the hash output + /// Should not be > 16 bytes. + /// If not defined, salt is not used. + /// - `personal`: Optional. Personal allows to + /// add customization to the hash function behavior. + /// Should not be > 16 bytes. + /// If not defined, personal is not used. + /// + /// ## Returns + /// + /// - Either a buffer the size requested, with the hash. + /// - Or an error: + /// - `key_too_big` if `key` is specified and is > 64 bytes. + /// - `hash_too_big` if `outlen` is specified and is > 64 bytes. + /// - `salt_too_big` if `salt` is specified and is > 16 bytes. + /// - `personal_too_big` if `personal` is specified and is > 16 bytes. + /// + /// ## Note: + /// + /// `key` length is checked before `outlen` so if both sizes are invalid, only + /// `key_too_big` will be returned. + /// If `salt` length exceeds 16 bytes, `salt_too_big` will be returned. + /// if `personal` length exceeds 16 bytes, `personal_too_big` will be returned. + pub fn blake2bmac(buf: &Bstr,outlen: Option,key: &Bstr,salt: Option<&Bstr>,personal: Option<&Bstr>,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = buf; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let (result1_0,result1_1,) = match outlen { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + };let vec2 = key; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let (result4_0,result4_1,result4_2,) = match salt { + Some(e) => { + let vec3 = e; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + + (1i32, ptr3.cast_mut(), len3) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let (result6_0,result6_1,result6_2,) = match personal { + Some(e) => { + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + + (1i32, ptr5.cast_mut(), len5) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let ptr7 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:hash/api")] + extern "C" { + #[link_name = "blake2bmac"] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, result1_0, result1_1, ptr2.cast_mut(), len2, result4_0, result4_1, result4_2, result6_0, result6_1, result6_2, ptr7); + let l8 = i32::from(*ptr7.add(0).cast::()); + match l8 { + 0 => { + let e = { + let l9 = *ptr7.add(4).cast::<*mut u8>(); + let l10 = *ptr7.add(8).cast::(); + let len11 = l10; + + _rt::Vec::from_raw_parts(l9.cast(), len11, len11) + }; + Ok(e) + } + 1 => { + let e = { + let l12 = i32::from(*ptr7.add(4).cast::()); + + Errno::_lift(l12 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// # BLAKE3 Hash Function + /// + /// Hash a binary buffer with BLAKE3. + /// + /// ## Parameters + /// + /// - `buf`: The binary data buffer to hash. + /// - `outlen`: Optional. The size of the digest. + /// If the outlen is not defined, it defaults to 32. + /// - `key`: Optional. The key to use with the hash. + /// If not defined, the hash is not keyed. + /// Should not be > 32 bytes. + /// + /// ## Returns + /// + /// - Either a buffer the size requested, with the hash. + /// - Or an error: + /// - `key_too_big` if `key` is specified and is > 32 bytes. + /// - `hash_too_big` if `outlen` is specified and is > 32 bytes. + /// + /// ## Note: + /// + /// `key` length is checked before `outlen` so if both sizes are invalid, only + /// `key_too_big` will be returned. + pub fn blake3(buf: &Bstr,outlen: Option,key: Option<&Bstr>,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = buf; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let (result1_0,result1_1,) = match outlen { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + };let (result3_0,result3_1,result3_2,) = match key { + Some(e) => { + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + (1i32, ptr2.cast_mut(), len2) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let ptr4 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:hash/api")] + extern "C" { + #[link_name = "blake3"] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, result1_0, result1_1, result3_0, result3_1, result3_2, ptr4); + let l5 = i32::from(*ptr4.add(0).cast::()); + match l5 { + 0 => { + let e = { + let l6 = *ptr4.add(4).cast::<*mut u8>(); + let l7 = *ptr4.add(8).cast::(); + let len8 = l7; + + _rt::Vec::from_raw_parts(l6.cast(), len8, len8) + }; + Ok(e) + } + 1 => { + let e = { + let l9 = i32::from(*ptr4.add(4).cast::()); + + Errno::_lift(l9 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + + } + + } + #[allow(dead_code)] + pub mod http_request { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Payload = u32; + #[allow(unused_unsafe, clippy::all)] + pub fn send(p: Payload,) -> bool{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:http-request/api")] + extern "C" { + #[link_name = "send"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import(_rt::as_i32(p)); + _rt::bool_lift(ret as u8) + } + } + + } + + } + #[allow(dead_code)] + pub mod ipfs { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// A DHT key. + pub type DhtKey = _rt::Vec::; + /// A DHT value. + pub type DhtValue = _rt::Vec::; + /// The binary contents of an IPFS file. + pub type IpfsFile = _rt::Vec::; + /// A path to an IPFS file. + pub type IpfsPath = _rt::String; + /// PubSub Message Data + pub type MessageData = _rt::Vec::; + /// PubSub Message ID + pub type MessageId = _rt::Vec::; + /// The ID of a peer. + pub type PeerId = _rt::String; + /// A PubSub topic. + pub type PubsubTopic = _rt::String; + /// This is content that can be validated. + #[derive(Clone)] + pub enum IpfsContent { + /// DHT value + Dht((DhtKey,DhtValue,)), + Pubsub((PubsubTopic,MessageData,)), + } + impl ::core::fmt::Debug for IpfsContent { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + IpfsContent::Dht(e) => { + f.debug_tuple("IpfsContent::Dht").field(e).finish() + } + IpfsContent::Pubsub(e) => { + f.debug_tuple("IpfsContent::Pubsub").field(e).finish() + } + } + } + } + /// A PubSub message from a topic subscription. + #[derive(Clone)] + pub struct PubsubMessage { + /// The topic that the message was received on. + pub topic: PubsubTopic, + /// The contents of the message. + pub message: MessageData, + /// Optional Peer ID that published the message. + pub publisher: Option, + } + impl ::core::fmt::Debug for PubsubMessage { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("PubsubMessage").field("topic", &self.topic).field("message", &self.message).field("publisher", &self.publisher).finish() + } + } + /// Errors that occur in IPFS networking. + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum Errno { + /// Unable to get DHT value. + DhtGetError, + /// Unable to put DHT value. + DhtPutError, + /// Unable to publish file to IPFS. + FileAddError, + /// Unable to get file from IPFS. + FileGetError, + /// Unable to pin file. + FilePinError, + /// Invalid CID. + InvalidCid, + /// Invalid DHT key. + InvalidDhtKey, + /// Invalid DHT value. + InvalidDhtValue, + /// Unable to parse a valid IPFS path. + InvalidIpfsPath, + /// Invalid Peer ID. + InvalidPeerId, + /// Invalid PubSub message. + InvalidPubsubMessage, + /// Unable to evict peer. + PeerEvictionError, + /// Unable to publish to IPFS topic. + PubsubPublishError, + /// Unable to subscribe to IPFS topic. + PubsubSubscribeError, + /// IPFS service is unavailable. + ServiceUnavailable, + } + impl Errno{ + pub fn name(&self) -> &'static str { + match self { + Errno::DhtGetError => "dht-get-error", + Errno::DhtPutError => "dht-put-error", + Errno::FileAddError => "file-add-error", + Errno::FileGetError => "file-get-error", + Errno::FilePinError => "file-pin-error", + Errno::InvalidCid => "invalid-cid", + Errno::InvalidDhtKey => "invalid-dht-key", + Errno::InvalidDhtValue => "invalid-dht-value", + Errno::InvalidIpfsPath => "invalid-ipfs-path", + Errno::InvalidPeerId => "invalid-peer-id", + Errno::InvalidPubsubMessage => "invalid-pubsub-message", + Errno::PeerEvictionError => "peer-eviction-error", + Errno::PubsubPublishError => "pubsub-publish-error", + Errno::PubsubSubscribeError => "pubsub-subscribe-error", + Errno::ServiceUnavailable => "service-unavailable", + } + } + pub fn message(&self) -> &'static str { + match self { + Errno::DhtGetError => "Unable to get DHT value.", + Errno::DhtPutError => "Unable to put DHT value.", + Errno::FileAddError => "Unable to publish file to IPFS.", + Errno::FileGetError => "Unable to get file from IPFS.", + Errno::FilePinError => "Unable to pin file.", + Errno::InvalidCid => "Invalid CID.", + Errno::InvalidDhtKey => "Invalid DHT key.", + Errno::InvalidDhtValue => "Invalid DHT value.", + Errno::InvalidIpfsPath => "Unable to parse a valid IPFS path.", + Errno::InvalidPeerId => "Invalid Peer ID.", + Errno::InvalidPubsubMessage => "Invalid PubSub message.", + Errno::PeerEvictionError => "Unable to evict peer.", + Errno::PubsubPublishError => "Unable to publish to IPFS topic.", + Errno::PubsubSubscribeError => "Unable to subscribe to IPFS topic.", + Errno::ServiceUnavailable => "IPFS service is unavailable.", + } + } + } + impl ::core::fmt::Debug for Errno{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Errno") + .field("code", &(*self as i32)) + .field("name", &self.name()) + .field("message", &self.message()) + .finish() + } + } + impl ::core::fmt::Display for Errno{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{} (error {})", self.name(), *self as i32) + } + } + + impl std::error::Error for Errno {} + + impl Errno{ + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> Errno{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => Errno::DhtGetError, + 1 => Errno::DhtPutError, + 2 => Errno::FileAddError, + 3 => Errno::FileGetError, + 4 => Errno::FilePinError, + 5 => Errno::InvalidCid, + 6 => Errno::InvalidDhtKey, + 7 => Errno::InvalidDhtValue, + 8 => Errno::InvalidIpfsPath, + 9 => Errno::InvalidPeerId, + 10 => Errno::InvalidPubsubMessage, + 11 => Errno::PeerEvictionError, + 12 => Errno::PubsubPublishError, + 13 => Errno::PubsubSubscribeError, + 14 => Errno::ServiceUnavailable, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[allow(unused_unsafe, clippy::all)] + /// Puts a DHT key-value into IPFS. + pub fn dht_put(key: &DhtKey,value: &DhtValue,) -> Result{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec1 = value; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:ipfs/api")] + extern "C" { + #[link_name = "dht-put"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, ptr1.cast_mut(), len1, ptr2); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = { + let l4 = i32::from(*ptr2.add(1).cast::()); + + _rt::bool_lift(l4 as u8) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr2.add(1).cast::()); + + Errno::_lift(l5 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Gets a DHT key-value from IPFS. + pub fn dht_get(key: &DhtKey,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:ipfs/api")] + extern "C" { + #[link_name = "dht-get"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(4).cast::<*mut u8>(); + let l4 = *ptr1.add(8).cast::(); + let len5 = l4; + + _rt::Vec::from_raw_parts(l3.cast(), len5, len5) + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from(*ptr1.add(4).cast::()); + + Errno::_lift(l6 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Validates IPFS content from DHT or PubSub. + pub fn ipfs_content_validate(content: &IpfsContent,) -> Result{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let (result6_0,result6_1,result6_2,result6_3,result6_4,) = match content { + IpfsContent::Dht(e) => { + let (t0_0, t0_1, ) = e; + let vec1 = t0_0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let vec2 = t0_1; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + (0i32, ptr1.cast_mut(), len1, ptr2.cast_mut(), len2) + }, + IpfsContent::Pubsub(e) => { + let (t3_0, t3_1, ) = e; + let vec4 = t3_0; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + let vec5 = t3_1; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + + (1i32, ptr4.cast_mut(), len4, ptr5.cast_mut(), len5) + }, + }; + let ptr7 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:ipfs/api")] + extern "C" { + #[link_name = "ipfs-content-validate"] + 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(result6_0, result6_1, result6_2, result6_3, result6_4, ptr7); + let l8 = i32::from(*ptr7.add(0).cast::()); + match l8 { + 0 => { + let e = { + let l9 = i32::from(*ptr7.add(1).cast::()); + + _rt::bool_lift(l9 as u8) + }; + Ok(e) + } + 1 => { + let e = { + let l10 = i32::from(*ptr7.add(1).cast::()); + + Errno::_lift(l10 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Uploads a file to IPFS. + pub fn file_add(contents: &IpfsFile,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = contents; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:ipfs/api")] + extern "C" { + #[link_name = "file-add"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(4).cast::<*mut u8>(); + let l4 = *ptr1.add(8).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from(*ptr1.add(4).cast::()); + + Errno::_lift(l6 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Retrieves a file from IPFS. + pub fn file_get(path: &IpfsPath,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:ipfs/api")] + extern "C" { + #[link_name = "file-get"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(4).cast::<*mut u8>(); + let l4 = *ptr1.add(8).cast::(); + let len5 = l4; + + _rt::Vec::from_raw_parts(l3.cast(), len5, len5) + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from(*ptr1.add(4).cast::()); + + Errno::_lift(l6 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Pins an IPFS file by path. + pub fn file_pin(path: &IpfsPath,) -> Result{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:ipfs/api")] + extern "C" { + #[link_name = "file-pin"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + + _rt::bool_lift(l3 as u8) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr1.add(1).cast::()); + + Errno::_lift(l4 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Un-pins an IPFS file by path. + pub fn file_unpin(path: &IpfsPath,) -> Result{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:ipfs/api")] + extern "C" { + #[link_name = "file-unpin"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + + _rt::bool_lift(l3 as u8) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr1.add(1).cast::()); + + Errno::_lift(l4 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Evict peer from network. + pub fn peer_evict(peer: &PeerId,) -> Result{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = peer; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:ipfs/api")] + extern "C" { + #[link_name = "peer-evict"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + + _rt::bool_lift(l3 as u8) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr1.add(1).cast::()); + + Errno::_lift(l4 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Publish a message to a topic. + pub fn pubsub_publish(topic: &PubsubTopic,message: &MessageData,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = topic; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec1 = message; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:ipfs/api")] + extern "C" { + #[link_name = "pubsub-publish"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, ptr1.cast_mut(), len1, ptr2); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = { + let l4 = *ptr2.add(4).cast::<*mut u8>(); + let l5 = *ptr2.add(8).cast::(); + let len6 = l5; + + _rt::Vec::from_raw_parts(l4.cast(), len6, len6) + }; + Ok(e) + } + 1 => { + let e = { + let l7 = i32::from(*ptr2.add(4).cast::()); + + Errno::_lift(l7 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Subscribes to a PubSub topic. + pub fn pubsub_subscribe(topic: &PubsubTopic,) -> Result{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = topic; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:ipfs/api")] + extern "C" { + #[link_name = "pubsub-subscribe"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + + _rt::bool_lift(l3 as u8) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr1.add(1).cast::()); + + Errno::_lift(l4 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + + } + + } + #[allow(dead_code)] + pub mod json { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// JSON is just a string. + /// This type is used to indicate the string MUST be properly formatted JSON. + pub type Json = _rt::String; + + } + + } + #[allow(dead_code)] + pub mod kv_store { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Bstr = super::super::super::hermes::binary::api::Bstr; + pub type Cbor = super::super::super::hermes::cbor::api::Cbor; + pub type Json = super::super::super::hermes::json::api::Json; + /// A time and date in seconds plus nanoseconds. + #[derive(Clone)] + pub enum KvValues { + KvString(_rt::String), + /// A String + KvS64(i64), + /// Just use the largest signed integer type supported + KvU64(u64), + /// Just use the largest integer type supported + KvF64(f64), + /// Just use the largest float type supported + KvBstr(Bstr), + /// A byte string + KvCbor(Cbor), + /// CBOR data + KvJson(Json), + } + impl ::core::fmt::Debug for KvValues { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + KvValues::KvString(e) => { + f.debug_tuple("KvValues::KvString").field(e).finish() + } + KvValues::KvS64(e) => { + f.debug_tuple("KvValues::KvS64").field(e).finish() + } + KvValues::KvU64(e) => { + f.debug_tuple("KvValues::KvU64").field(e).finish() + } + KvValues::KvF64(e) => { + f.debug_tuple("KvValues::KvF64").field(e).finish() + } + KvValues::KvBstr(e) => { + f.debug_tuple("KvValues::KvBstr").field(e).finish() + } + KvValues::KvCbor(e) => { + f.debug_tuple("KvValues::KvCbor").field(e).finish() + } + KvValues::KvJson(e) => { + f.debug_tuple("KvValues::KvJson").field(e).finish() + } + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Set a value in the local key-value store + /// Setting None will cause the Key to be deleted from the KV store. + pub fn kv_set(key: &str,value: Option<&KvValues>,){ + unsafe { + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let (result6_0,result6_1,result6_2,result6_3,) = match value { + Some(e) => { + let (result5_0,result5_1,result5_2,) = match e { + KvValues::KvString(e) => { + let vec1 = e; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + (0i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr1.cast_mut()); + t + }, len1) + }, + KvValues::KvS64(e) => (1i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), + KvValues::KvU64(e) => (2i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), + KvValues::KvF64(e) => (3i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), + KvValues::KvBstr(e) => { + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + (4i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr2.cast_mut()); + t + }, len2) + }, + KvValues::KvCbor(e) => { + let vec3 = e; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + + (5i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr3.cast_mut()); + t + }, len3) + }, + KvValues::KvJson(e) => { + let vec4 = e; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + (6i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr4.cast_mut()); + t + }, len4) + }, + }; + + (1i32, result5_0, result5_1, result5_2) + }, + None => { + (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) + }, + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:kv-store/api")] + extern "C" { + #[link_name = "kv-set"] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, result6_0, result6_1, result6_2, result6_3); + } + } + #[allow(unused_unsafe, clippy::all)] + /// Get a value from the local key-value store + /// Returns the default if not set. + pub fn kv_get_default(key: &str,default: Option<&KvValues>,) -> Option{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let (result6_0,result6_1,result6_2,result6_3,) = match default { + Some(e) => { + let (result5_0,result5_1,result5_2,) = match e { + KvValues::KvString(e) => { + let vec1 = e; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + (0i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr1.cast_mut()); + t + }, len1) + }, + KvValues::KvS64(e) => (1i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), + KvValues::KvU64(e) => (2i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), + KvValues::KvF64(e) => (3i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), + KvValues::KvBstr(e) => { + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + (4i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr2.cast_mut()); + t + }, len2) + }, + KvValues::KvCbor(e) => { + let vec3 = e; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + + (5i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr3.cast_mut()); + t + }, len3) + }, + KvValues::KvJson(e) => { + let vec4 = e; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + (6i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr4.cast_mut()); + t + }, len4) + }, + }; + + (1i32, result5_0, result5_1, result5_2) + }, + None => { + (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) + }, + };let ptr7 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:kv-store/api")] + extern "C" { + #[link_name = "kv-get-default"] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, result6_0, result6_1, result6_2, result6_3, ptr7); + let l8 = i32::from(*ptr7.add(0).cast::()); + match l8 { + 0 => None, + 1 => { + let e = { + let l9 = i32::from(*ptr7.add(8).cast::()); + let v25 = match l9 { + 0 => { + let e25 = { + let l10 = *ptr7.add(16).cast::<*mut u8>(); + let l11 = *ptr7.add(20).cast::(); + let len12 = l11; + let bytes12 = _rt::Vec::from_raw_parts(l10.cast(), len12, len12); + + _rt::string_lift(bytes12) + }; + KvValues::KvString(e25) + } + 1 => { + let e25 = { + let l13 = *ptr7.add(16).cast::(); + + l13 + }; + KvValues::KvS64(e25) + } + 2 => { + let e25 = { + let l14 = *ptr7.add(16).cast::(); + + l14 as u64 + }; + KvValues::KvU64(e25) + } + 3 => { + let e25 = { + let l15 = *ptr7.add(16).cast::(); + + l15 + }; + KvValues::KvF64(e25) + } + 4 => { + let e25 = { + let l16 = *ptr7.add(16).cast::<*mut u8>(); + let l17 = *ptr7.add(20).cast::(); + let len18 = l17; + + _rt::Vec::from_raw_parts(l16.cast(), len18, len18) + }; + KvValues::KvBstr(e25) + } + 5 => { + let e25 = { + let l19 = *ptr7.add(16).cast::<*mut u8>(); + let l20 = *ptr7.add(20).cast::(); + let len21 = l20; + + _rt::Vec::from_raw_parts(l19.cast(), len21, len21) + }; + KvValues::KvCbor(e25) + } + n => { + debug_assert_eq!(n, 6, "invalid enum discriminant"); + let e25 = { + let l22 = *ptr7.add(16).cast::<*mut u8>(); + let l23 = *ptr7.add(20).cast::(); + let len24 = l23; + let bytes24 = _rt::Vec::from_raw_parts(l22.cast(), len24, len24); + + _rt::string_lift(bytes24) + }; + KvValues::KvJson(e25) + } + }; + + v25 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Get a value from the local key-value store + /// Returns None if the Key does not exist in the KV Store. + /// This is a convenience function, and is equivalent to `kv-get-default(key, none)` + pub fn kv_get(key: &str,) -> Option{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:kv-store/api")] + extern "C" { + #[link_name = "kv-get"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(8).cast::()); + let v19 = match l3 { + 0 => { + let e19 = { + let l4 = *ptr1.add(16).cast::<*mut u8>(); + let l5 = *ptr1.add(20).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + KvValues::KvString(e19) + } + 1 => { + let e19 = { + let l7 = *ptr1.add(16).cast::(); + + l7 + }; + KvValues::KvS64(e19) + } + 2 => { + let e19 = { + let l8 = *ptr1.add(16).cast::(); + + l8 as u64 + }; + KvValues::KvU64(e19) + } + 3 => { + let e19 = { + let l9 = *ptr1.add(16).cast::(); + + l9 + }; + KvValues::KvF64(e19) + } + 4 => { + let e19 = { + let l10 = *ptr1.add(16).cast::<*mut u8>(); + let l11 = *ptr1.add(20).cast::(); + let len12 = l11; + + _rt::Vec::from_raw_parts(l10.cast(), len12, len12) + }; + KvValues::KvBstr(e19) + } + 5 => { + let e19 = { + let l13 = *ptr1.add(16).cast::<*mut u8>(); + let l14 = *ptr1.add(20).cast::(); + let len15 = l14; + + _rt::Vec::from_raw_parts(l13.cast(), len15, len15) + }; + KvValues::KvCbor(e19) + } + n => { + debug_assert_eq!(n, 6, "invalid enum discriminant"); + let e19 = { + let l16 = *ptr1.add(16).cast::<*mut u8>(); + let l17 = *ptr1.add(20).cast::(); + let len18 = l17; + let bytes18 = _rt::Vec::from_raw_parts(l16.cast(), len18, len18); + + _rt::string_lift(bytes18) + }; + KvValues::KvJson(e19) + } + }; + + v19 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Get a value, and then set it (Atomic) + /// Setting None will cause the Key to be deleted from the KV store. + pub fn kv_get_set(key: &str,value: Option<&KvValues>,) -> Option{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let (result6_0,result6_1,result6_2,result6_3,) = match value { + Some(e) => { + let (result5_0,result5_1,result5_2,) = match e { + KvValues::KvString(e) => { + let vec1 = e; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + (0i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr1.cast_mut()); + t + }, len1) + }, + KvValues::KvS64(e) => (1i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), + KvValues::KvU64(e) => (2i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), + KvValues::KvF64(e) => (3i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), + KvValues::KvBstr(e) => { + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + (4i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr2.cast_mut()); + t + }, len2) + }, + KvValues::KvCbor(e) => { + let vec3 = e; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + + (5i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr3.cast_mut()); + t + }, len3) + }, + KvValues::KvJson(e) => { + let vec4 = e; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + (6i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr4.cast_mut()); + t + }, len4) + }, + }; + + (1i32, result5_0, result5_1, result5_2) + }, + None => { + (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) + }, + };let ptr7 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:kv-store/api")] + extern "C" { + #[link_name = "kv-get-set"] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, result6_0, result6_1, result6_2, result6_3, ptr7); + let l8 = i32::from(*ptr7.add(0).cast::()); + match l8 { + 0 => None, + 1 => { + let e = { + let l9 = i32::from(*ptr7.add(8).cast::()); + let v25 = match l9 { + 0 => { + let e25 = { + let l10 = *ptr7.add(16).cast::<*mut u8>(); + let l11 = *ptr7.add(20).cast::(); + let len12 = l11; + let bytes12 = _rt::Vec::from_raw_parts(l10.cast(), len12, len12); + + _rt::string_lift(bytes12) + }; + KvValues::KvString(e25) + } + 1 => { + let e25 = { + let l13 = *ptr7.add(16).cast::(); + + l13 + }; + KvValues::KvS64(e25) + } + 2 => { + let e25 = { + let l14 = *ptr7.add(16).cast::(); + + l14 as u64 + }; + KvValues::KvU64(e25) + } + 3 => { + let e25 = { + let l15 = *ptr7.add(16).cast::(); + + l15 + }; + KvValues::KvF64(e25) + } + 4 => { + let e25 = { + let l16 = *ptr7.add(16).cast::<*mut u8>(); + let l17 = *ptr7.add(20).cast::(); + let len18 = l17; + + _rt::Vec::from_raw_parts(l16.cast(), len18, len18) + }; + KvValues::KvBstr(e25) + } + 5 => { + let e25 = { + let l19 = *ptr7.add(16).cast::<*mut u8>(); + let l20 = *ptr7.add(20).cast::(); + let len21 = l20; + + _rt::Vec::from_raw_parts(l19.cast(), len21, len21) + }; + KvValues::KvCbor(e25) + } + n => { + debug_assert_eq!(n, 6, "invalid enum discriminant"); + let e25 = { + let l22 = *ptr7.add(16).cast::<*mut u8>(); + let l23 = *ptr7.add(20).cast::(); + let len24 = l23; + let bytes24 = _rt::Vec::from_raw_parts(l22.cast(), len24, len24); + + _rt::string_lift(bytes24) + }; + KvValues::KvJson(e25) + } + }; + + v25 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Get a value, and then add to it (Atomic) + /// Adding to a string will concatenate the string. + /// String concatenation will only occur up to the maximum possible size of a string value.\ + /// Concatenation beyond the maximum size will result in truncation. + /// Adding to a numeric will have the expected behavior (rounded to nearest if necessary). + /// The original type does not change, so: `f64 + u64 = f64`. `s64 + f64 = s64` + /// If the value overflows or under-flows it will saturate at the limit. + /// This behavior allows us to decrement values by using the signed version, so `u64(10) + s64(-5) = u64(5))` + /// If a string is added to a numeric, nothing happens. + /// If a numeric is added to a string, it is converted to a string first, and then concatenated + /// Note: There will be no spaces added. So "My string" + u32(77) = "My string77" + pub fn kv_add(key: &str,value: Option<&KvValues>,) -> Option{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let (result6_0,result6_1,result6_2,result6_3,) = match value { + Some(e) => { + let (result5_0,result5_1,result5_2,) = match e { + KvValues::KvString(e) => { + let vec1 = e; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + (0i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr1.cast_mut()); + t + }, len1) + }, + KvValues::KvS64(e) => (1i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), + KvValues::KvU64(e) => (2i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), + KvValues::KvF64(e) => (3i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), + KvValues::KvBstr(e) => { + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + (4i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr2.cast_mut()); + t + }, len2) + }, + KvValues::KvCbor(e) => { + let vec3 = e; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + + (5i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr3.cast_mut()); + t + }, len3) + }, + KvValues::KvJson(e) => { + let vec4 = e; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + (6i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr4.cast_mut()); + t + }, len4) + }, + }; + + (1i32, result5_0, result5_1, result5_2) + }, + None => { + (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) + }, + };let ptr7 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:kv-store/api")] + extern "C" { + #[link_name = "kv-add"] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, result6_0, result6_1, result6_2, result6_3, ptr7); + let l8 = i32::from(*ptr7.add(0).cast::()); + match l8 { + 0 => None, + 1 => { + let e = { + let l9 = i32::from(*ptr7.add(8).cast::()); + let v25 = match l9 { + 0 => { + let e25 = { + let l10 = *ptr7.add(16).cast::<*mut u8>(); + let l11 = *ptr7.add(20).cast::(); + let len12 = l11; + let bytes12 = _rt::Vec::from_raw_parts(l10.cast(), len12, len12); + + _rt::string_lift(bytes12) + }; + KvValues::KvString(e25) + } + 1 => { + let e25 = { + let l13 = *ptr7.add(16).cast::(); + + l13 + }; + KvValues::KvS64(e25) + } + 2 => { + let e25 = { + let l14 = *ptr7.add(16).cast::(); + + l14 as u64 + }; + KvValues::KvU64(e25) + } + 3 => { + let e25 = { + let l15 = *ptr7.add(16).cast::(); + + l15 + }; + KvValues::KvF64(e25) + } + 4 => { + let e25 = { + let l16 = *ptr7.add(16).cast::<*mut u8>(); + let l17 = *ptr7.add(20).cast::(); + let len18 = l17; + + _rt::Vec::from_raw_parts(l16.cast(), len18, len18) + }; + KvValues::KvBstr(e25) + } + 5 => { + let e25 = { + let l19 = *ptr7.add(16).cast::<*mut u8>(); + let l20 = *ptr7.add(20).cast::(); + let len21 = l20; + + _rt::Vec::from_raw_parts(l19.cast(), len21, len21) + }; + KvValues::KvCbor(e25) + } + n => { + debug_assert_eq!(n, 6, "invalid enum discriminant"); + let e25 = { + let l22 = *ptr7.add(16).cast::<*mut u8>(); + let l23 = *ptr7.add(20).cast::(); + let len24 = l23; + let bytes24 = _rt::Vec::from_raw_parts(l22.cast(), len24, len24); + + _rt::string_lift(bytes24) + }; + KvValues::KvJson(e25) + } + }; + + v25 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Check if the Key equals a test value (exact match) and if it does, store the new value. + /// In all cases, the current value is returned. + /// If the types are NOT the same, the comparison will fail, even if the values are equivalent. + /// For example: `u64(7) != s64(7)`, `f64(-1) != s64(-1)`. + pub fn kv_cas(key: &str,test: Option<&KvValues>,value: Option<&KvValues>,) -> Option{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let (result6_0,result6_1,result6_2,result6_3,) = match test { + Some(e) => { + let (result5_0,result5_1,result5_2,) = match e { + KvValues::KvString(e) => { + let vec1 = e; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + (0i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr1.cast_mut()); + t + }, len1) + }, + KvValues::KvS64(e) => (1i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), + KvValues::KvU64(e) => (2i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), + KvValues::KvF64(e) => (3i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), + KvValues::KvBstr(e) => { + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + (4i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr2.cast_mut()); + t + }, len2) + }, + KvValues::KvCbor(e) => { + let vec3 = e; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + + (5i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr3.cast_mut()); + t + }, len3) + }, + KvValues::KvJson(e) => { + let vec4 = e; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + + (6i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr4.cast_mut()); + t + }, len4) + }, + }; + + (1i32, result5_0, result5_1, result5_2) + }, + None => { + (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) + }, + };let (result12_0,result12_1,result12_2,result12_3,) = match value { + Some(e) => { + let (result11_0,result11_1,result11_2,) = match e { + KvValues::KvString(e) => { + let vec7 = e; + let ptr7 = vec7.as_ptr().cast::(); + let len7 = vec7.len(); + + (0i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr7.cast_mut()); + t + }, len7) + }, + KvValues::KvS64(e) => (1i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), + KvValues::KvU64(e) => (2i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), + KvValues::KvF64(e) => (3i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), + KvValues::KvBstr(e) => { + let vec8 = e; + let ptr8 = vec8.as_ptr().cast::(); + let len8 = vec8.len(); + + (4i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr8.cast_mut()); + t + }, len8) + }, + KvValues::KvCbor(e) => { + let vec9 = e; + let ptr9 = vec9.as_ptr().cast::(); + let len9 = vec9.len(); + + (5i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr9.cast_mut()); + t + }, len9) + }, + KvValues::KvJson(e) => { + let vec10 = e; + let ptr10 = vec10.as_ptr().cast::(); + let len10 = vec10.len(); + + (6i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr10.cast_mut()); + t + }, len10) + }, + }; + + (1i32, result11_0, result11_1, result11_2) + }, + None => { + (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) + }, + };let ptr13 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:kv-store/api")] + extern "C" { + #[link_name = "kv-cas"] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, result6_0, result6_1, result6_2, result6_3, result12_0, result12_1, result12_2, result12_3, ptr13); + let l14 = i32::from(*ptr13.add(0).cast::()); + match l14 { + 0 => None, + 1 => { + let e = { + let l15 = i32::from(*ptr13.add(8).cast::()); + let v31 = match l15 { + 0 => { + let e31 = { + let l16 = *ptr13.add(16).cast::<*mut u8>(); + let l17 = *ptr13.add(20).cast::(); + let len18 = l17; + let bytes18 = _rt::Vec::from_raw_parts(l16.cast(), len18, len18); + + _rt::string_lift(bytes18) + }; + KvValues::KvString(e31) + } + 1 => { + let e31 = { + let l19 = *ptr13.add(16).cast::(); + + l19 + }; + KvValues::KvS64(e31) + } + 2 => { + let e31 = { + let l20 = *ptr13.add(16).cast::(); + + l20 as u64 + }; + KvValues::KvU64(e31) + } + 3 => { + let e31 = { + let l21 = *ptr13.add(16).cast::(); + + l21 + }; + KvValues::KvF64(e31) + } + 4 => { + let e31 = { + let l22 = *ptr13.add(16).cast::<*mut u8>(); + let l23 = *ptr13.add(20).cast::(); + let len24 = l23; + + _rt::Vec::from_raw_parts(l22.cast(), len24, len24) + }; + KvValues::KvBstr(e31) + } + 5 => { + let e31 = { + let l25 = *ptr13.add(16).cast::<*mut u8>(); + let l26 = *ptr13.add(20).cast::(); + let len27 = l26; + + _rt::Vec::from_raw_parts(l25.cast(), len27, len27) + }; + KvValues::KvCbor(e31) + } + n => { + debug_assert_eq!(n, 6, "invalid enum discriminant"); + let e31 = { + let l28 = *ptr13.add(16).cast::<*mut u8>(); + let l29 = *ptr13.add(20).cast::(); + let len30 = l29; + let bytes30 = _rt::Vec::from_raw_parts(l28.cast(), len30, len30); + + _rt::string_lift(bytes30) + }; + KvValues::KvJson(e31) + } + }; + + v31 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Subscribe to any updates made to a particular Key. + /// After this call, this module will receive Key Update events when a key is written. + /// It returns the current value of the Key and None if it is not set. + pub fn kv_subscribe(key: &str,) -> Option{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:kv-store/api")] + extern "C" { + #[link_name = "kv-subscribe"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(8).cast::()); + let v19 = match l3 { + 0 => { + let e19 = { + let l4 = *ptr1.add(16).cast::<*mut u8>(); + let l5 = *ptr1.add(20).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + KvValues::KvString(e19) + } + 1 => { + let e19 = { + let l7 = *ptr1.add(16).cast::(); + + l7 + }; + KvValues::KvS64(e19) + } + 2 => { + let e19 = { + let l8 = *ptr1.add(16).cast::(); + + l8 as u64 + }; + KvValues::KvU64(e19) + } + 3 => { + let e19 = { + let l9 = *ptr1.add(16).cast::(); + + l9 + }; + KvValues::KvF64(e19) + } + 4 => { + let e19 = { + let l10 = *ptr1.add(16).cast::<*mut u8>(); + let l11 = *ptr1.add(20).cast::(); + let len12 = l11; + + _rt::Vec::from_raw_parts(l10.cast(), len12, len12) + }; + KvValues::KvBstr(e19) + } + 5 => { + let e19 = { + let l13 = *ptr1.add(16).cast::<*mut u8>(); + let l14 = *ptr1.add(20).cast::(); + let len15 = l14; + + _rt::Vec::from_raw_parts(l13.cast(), len15, len15) + }; + KvValues::KvCbor(e19) + } + n => { + debug_assert_eq!(n, 6, "invalid enum discriminant"); + let e19 = { + let l16 = *ptr1.add(16).cast::<*mut u8>(); + let l17 = *ptr1.add(20).cast::(); + let len18 = l17; + let bytes18 = _rt::Vec::from_raw_parts(l16.cast(), len18, len18); + + _rt::string_lift(bytes18) + }; + KvValues::KvJson(e19) + } + }; + + v19 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Unsubscribe to any updates made to a particular Key. + /// After this call, this module will no longer receive Key Update events when a key is written. + /// It returns the current value of the Key and None if it is not set. + pub fn kv_unsubscribe(key: &str,) -> Option{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let vec0 = key; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:kv-store/api")] + extern "C" { + #[link_name = "kv-unsubscribe"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(8).cast::()); + let v19 = match l3 { + 0 => { + let e19 = { + let l4 = *ptr1.add(16).cast::<*mut u8>(); + let l5 = *ptr1.add(20).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + KvValues::KvString(e19) + } + 1 => { + let e19 = { + let l7 = *ptr1.add(16).cast::(); + + l7 + }; + KvValues::KvS64(e19) + } + 2 => { + let e19 = { + let l8 = *ptr1.add(16).cast::(); + + l8 as u64 + }; + KvValues::KvU64(e19) + } + 3 => { + let e19 = { + let l9 = *ptr1.add(16).cast::(); + + l9 + }; + KvValues::KvF64(e19) + } + 4 => { + let e19 = { + let l10 = *ptr1.add(16).cast::<*mut u8>(); + let l11 = *ptr1.add(20).cast::(); + let len12 = l11; + + _rt::Vec::from_raw_parts(l10.cast(), len12, len12) + }; + KvValues::KvBstr(e19) + } + 5 => { + let e19 = { + let l13 = *ptr1.add(16).cast::<*mut u8>(); + let l14 = *ptr1.add(20).cast::(); + let len15 = l14; + + _rt::Vec::from_raw_parts(l13.cast(), len15, len15) + }; + KvValues::KvCbor(e19) + } + n => { + debug_assert_eq!(n, 6, "invalid enum discriminant"); + let e19 = { + let l16 = *ptr1.add(16).cast::<*mut u8>(); + let l17 = *ptr1.add(20).cast::(); + let len18 = l17; + let bytes18 = _rt::Vec::from_raw_parts(l16.cast(), len18, len18); + + _rt::string_lift(bytes18) + }; + KvValues::KvJson(e19) + } + }; + + v19 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + + } + + } + #[allow(dead_code)] + pub mod localtime { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Datetime = super::super::super::wasi::clocks::wall_clock::Datetime; + /// The timezone we are localized for. + pub type Timezone = _rt::String; + /// Time in localtime format. + #[derive(Clone)] + pub struct Localtime { + pub year: u64, + /// Year + pub month: u8, + /// Month (0-11) + pub dow: u8, + /// Day of week (0-6) + pub day: u8, + /// Day (1-31) + pub hh: u8, + /// Hour (0-23) + pub mm: u8, + /// Minute (0-59) + pub ss: u8, + /// Second (0-59) + pub ns: u32, + /// Nanoseconds + pub tz: Timezone, + } + impl ::core::fmt::Debug for Localtime { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Localtime").field("year", &self.year).field("month", &self.month).field("dow", &self.dow).field("day", &self.day).field("hh", &self.hh).field("mm", &self.mm).field("ss", &self.ss).field("ns", &self.ns).field("tz", &self.tz).finish() + } + } + /// Errors that can occur converting times + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum Errno { + InvalidLocaltime, + UnknownTimezone, + YearOutOfRange, + } + impl Errno{ + pub fn name(&self) -> &'static str { + match self { + Errno::InvalidLocaltime => "invalid-localtime", + Errno::UnknownTimezone => "unknown-timezone", + Errno::YearOutOfRange => "year-out-of-range", + } + } + pub fn message(&self) -> &'static str { + match self { + Errno::InvalidLocaltime => "", + Errno::UnknownTimezone => "", + Errno::YearOutOfRange => "", + } + } + } + impl ::core::fmt::Debug for Errno{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Errno") + .field("code", &(*self as i32)) + .field("name", &self.name()) + .field("message", &self.message()) + .finish() + } + } + impl ::core::fmt::Display for Errno{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{} (error {})", self.name(), *self as i32) + } + } + + impl std::error::Error for Errno {} + + impl Errno{ + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> Errno{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => Errno::InvalidLocaltime, + 1 => Errno::UnknownTimezone, + 2 => Errno::YearOutOfRange, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[allow(unused_unsafe, clippy::all)] + /// Get localtime from a datetime or now. + /// + /// **Parameters** + /// + /// `when` : The datetime we want to convert (Optional, if not set it will convert `now`). + /// `tz` : The timezone to use. (Optional, if not set uses the local machines configured local timezone.) + /// + /// **Returns** + /// + /// `localtime` : the converted time. + /// `errno` : An error indicating why conversion failed. + pub fn get_localtime(when: Option,tz: Option<&Timezone>,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 40]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); + let (result1_0,result1_1,result1_2,) = match when { + Some(e) => { + let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds0, nanoseconds:nanoseconds0, } = e; + + (1i32, _rt::as_i64(seconds0), _rt::as_i32(nanoseconds0)) + }, + None => { + (0i32, 0i64, 0i32) + }, + };let (result3_0,result3_1,result3_2,) = match tz { + Some(e) => { + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + (1i32, ptr2.cast_mut(), len2) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let ptr4 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:localtime/api")] + extern "C" { + #[link_name = "get-localtime"] + fn wit_import(_: i32, _: i64, _: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(result1_0, result1_1, result1_2, result3_0, result3_1, result3_2, ptr4); + let l5 = i32::from(*ptr4.add(0).cast::()); + match l5 { + 0 => { + let e = { + let l6 = *ptr4.add(8).cast::(); + let l7 = i32::from(*ptr4.add(16).cast::()); + let l8 = i32::from(*ptr4.add(17).cast::()); + let l9 = i32::from(*ptr4.add(18).cast::()); + let l10 = i32::from(*ptr4.add(19).cast::()); + let l11 = i32::from(*ptr4.add(20).cast::()); + let l12 = i32::from(*ptr4.add(21).cast::()); + let l13 = *ptr4.add(24).cast::(); + let l14 = *ptr4.add(28).cast::<*mut u8>(); + let l15 = *ptr4.add(32).cast::(); + let len16 = l15; + let bytes16 = _rt::Vec::from_raw_parts(l14.cast(), len16, len16); + + Localtime{ + year: l6 as u64, + month: l7 as u8, + dow: l8 as u8, + day: l9 as u8, + hh: l10 as u8, + mm: l11 as u8, + ss: l12 as u8, + ns: l13 as u32, + tz: _rt::string_lift(bytes16), + } + }; + Ok(e) + } + 1 => { + let e = { + let l17 = i32::from(*ptr4.add(8).cast::()); + + Errno::_lift(l17 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Get a new localtime from a localtime, by recalculating time for a new timezone. + /// + /// **Parameters** + /// + /// `time` : The localtime to convert. + /// `tz` : The timezone to use. (Optional, if not set uses the local machines configured local timezone.) + /// + /// **Returns** + /// + /// `localtime` : the converted time. + /// `errno` : An error indicating why conversion failed. + pub fn alt_localtime(time: &Localtime,tz: Option<&Timezone>,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 40]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); + let Localtime{ year:year0, month:month0, dow:dow0, day:day0, hh:hh0, mm:mm0, ss:ss0, ns:ns0, tz:tz0, } = time; + let vec1 = tz0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let (result3_0,result3_1,result3_2,) = match tz { + Some(e) => { + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + + (1i32, ptr2.cast_mut(), len2) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let ptr4 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:localtime/api")] + extern "C" { + #[link_name = "alt-localtime"] + fn wit_import(_: i64, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(_rt::as_i64(year0), _rt::as_i32(month0), _rt::as_i32(dow0), _rt::as_i32(day0), _rt::as_i32(hh0), _rt::as_i32(mm0), _rt::as_i32(ss0), _rt::as_i32(ns0), ptr1.cast_mut(), len1, result3_0, result3_1, result3_2, ptr4); + let l5 = i32::from(*ptr4.add(0).cast::()); + match l5 { + 0 => { + let e = { + let l6 = *ptr4.add(8).cast::(); + let l7 = i32::from(*ptr4.add(16).cast::()); + let l8 = i32::from(*ptr4.add(17).cast::()); + let l9 = i32::from(*ptr4.add(18).cast::()); + let l10 = i32::from(*ptr4.add(19).cast::()); + let l11 = i32::from(*ptr4.add(20).cast::()); + let l12 = i32::from(*ptr4.add(21).cast::()); + let l13 = *ptr4.add(24).cast::(); + let l14 = *ptr4.add(28).cast::<*mut u8>(); + let l15 = *ptr4.add(32).cast::(); + let len16 = l15; + let bytes16 = _rt::Vec::from_raw_parts(l14.cast(), len16, len16); + + Localtime{ + year: l6 as u64, + month: l7 as u8, + dow: l8 as u8, + day: l9 as u8, + hh: l10 as u8, + mm: l11 as u8, + ss: l12 as u8, + ns: l13 as u32, + tz: _rt::string_lift(bytes16), + } + }; + Ok(e) + } + 1 => { + let e = { + let l17 = i32::from(*ptr4.add(8).cast::()); + + Errno::_lift(l17 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Get a datetime from a localtime. + /// + /// **Parameters** + /// + /// `time` : The localtime to convert. + /// + /// **Returns** + /// + /// `datetime` : the converted time. + /// `errno` : An error indicating why conversion failed. + pub fn get_datetime(time: &Localtime,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let Localtime{ year:year0, month:month0, dow:dow0, day:day0, hh:hh0, mm:mm0, ss:ss0, ns:ns0, tz:tz0, } = time; + let vec1 = tz0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:localtime/api")] + extern "C" { + #[link_name = "get-datetime"] + fn wit_import(_: i64, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(_rt::as_i64(year0), _rt::as_i32(month0), _rt::as_i32(dow0), _rt::as_i32(day0), _rt::as_i32(hh0), _rt::as_i32(mm0), _rt::as_i32(ss0), _rt::as_i32(ns0), ptr1.cast_mut(), len1, ptr2); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = { + let l4 = *ptr2.add(8).cast::(); + let l5 = *ptr2.add(16).cast::(); + + super::super::super::wasi::clocks::wall_clock::Datetime{ + seconds: l4 as u64, + nanoseconds: l5 as u32, + } + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from(*ptr2.add(8).cast::()); + + Errno::_lift(l6 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + + } + + } + #[allow(dead_code)] + pub mod logging { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Json = super::super::super::hermes::json::api::Json; + /// The supported logging levels + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum Level { + /// Debug Log Level + Debug, + /// Tracing Log level + Trace, + /// General Informational Log Level + Info, + /// Warning about something that might be a problem. + Warn, + /// A very serious error + Error, + } + impl ::core::fmt::Debug for Level { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Level::Debug => { + f.debug_tuple("Level::Debug").finish() + } + Level::Trace => { + f.debug_tuple("Level::Trace").finish() + } + Level::Info => { + f.debug_tuple("Level::Info").finish() + } + Level::Warn => { + f.debug_tuple("Level::Warn").finish() + } + Level::Error => { + f.debug_tuple("Level::Error").finish() + } + } + } + } + + impl Level{ + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> Level{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => Level::Debug, + 1 => Level::Trace, + 2 => Level::Info, + 3 => Level::Warn, + 4 => Level::Error, + + _ => panic!("invalid enum discriminant"), + } + } + } + + #[allow(unused_unsafe, clippy::all)] + /// Generate a Log + /// + /// The Hermes API will add extra information to the log, such as the instance of the webasm + /// module being logged. + /// The Webasm module does not need to concern itself with this kind of information, and should + /// log as if it is the only instance. + /// It also should not log any webasm shared context, except where it is relevant to the log message itself. + /// The log level will be forced to INFO level. + /// + /// **Parameters** + /// + /// - `level` : The log level this message is for. + /// - `file` : The name of the src file being logged from. (Optional) + /// - `function` : The function within the file being logged from. (Optional) + /// - `line` : The line of code the log was generated from. (Optional) + /// - `col` : The column of code the log was generated from. (Optional) + /// - `ctx` : The logging context. (Should have no newlines or formatting). + /// - `msg` : A Single line message to be logged. (Should have no newlines or formatting). + /// - `data` : A Free form json payload that will be logged with the msg. This must be valid JSON. + /// + /// *Notes* + /// + /// The `data` parameter may contain a record of the format: + /// ```json + /// { + /// "bt" : [ , ] + /// } + /// ``` + /// The logger will interpret this as a backtrace where each entry in the array is one line of the backtrace. + /// The format of the backtrace lines is up to the webasm module generating the log. + /// The individual backtrace entries may contain line breaks if the backtrace entry is + /// multiline. + /// * Multiline backtrace entries should be de-dented, relative to the first line. + /// * This is to allow the display to properly format multiline entries. + /// This format is designed to keep the broadest flexibility for multiple languages capabilities. + /// The backtrace must be sorted with most recent lines of the backtrace occurring first in the array. + /// Backtrace must be contained in a single `log` call. Multiple log calls will be considered independent logs. + pub fn log(level: Level,file: Option<&str>,function: Option<&str>,line: Option,col: Option,ctx: Option<&str>,msg: &str,data: Option<&Json>,){ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 76]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 76]); + let ptr0 = ret_area.0.as_mut_ptr().cast::();*ptr0.add(0).cast::() = (level.clone() as i32) as u8; + match file { + Some(e) => { + *ptr0.add(4).cast::() = (1i32) as u8; + let vec1 = e; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + *ptr0.add(12).cast::() = len1; + *ptr0.add(8).cast::<*mut u8>() = ptr1.cast_mut(); + }, + None => { + { + *ptr0.add(4).cast::() = (0i32) as u8; + } + }, + };match function { + Some(e) => { + *ptr0.add(16).cast::() = (1i32) as u8; + let vec2 = e; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *ptr0.add(24).cast::() = len2; + *ptr0.add(20).cast::<*mut u8>() = ptr2.cast_mut(); + }, + None => { + { + *ptr0.add(16).cast::() = (0i32) as u8; + } + }, + };match line { + Some(e) => { + *ptr0.add(28).cast::() = (1i32) as u8; + *ptr0.add(32).cast::() = _rt::as_i32(e); + }, + None => { + { + *ptr0.add(28).cast::() = (0i32) as u8; + } + }, + };match col { + Some(e) => { + *ptr0.add(36).cast::() = (1i32) as u8; + *ptr0.add(40).cast::() = _rt::as_i32(e); + }, + None => { + { + *ptr0.add(36).cast::() = (0i32) as u8; + } + }, + };match ctx { + Some(e) => { + *ptr0.add(44).cast::() = (1i32) as u8; + let vec3 = e; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + *ptr0.add(52).cast::() = len3; + *ptr0.add(48).cast::<*mut u8>() = ptr3.cast_mut(); + }, + None => { + { + *ptr0.add(44).cast::() = (0i32) as u8; + } + }, + };let vec4 = msg; + let ptr4 = vec4.as_ptr().cast::(); + let len4 = vec4.len(); + *ptr0.add(60).cast::() = len4; + *ptr0.add(56).cast::<*mut u8>() = ptr4.cast_mut(); + match data { + Some(e) => { + *ptr0.add(64).cast::() = (1i32) as u8; + let vec5 = e; + let ptr5 = vec5.as_ptr().cast::(); + let len5 = vec5.len(); + *ptr0.add(72).cast::() = len5; + *ptr0.add(68).cast::<*mut u8>() = ptr5.cast_mut(); + }, + None => { + { + *ptr0.add(64).cast::() = (0i32) as u8; + } + }, + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:logging/api")] + extern "C" { + #[link_name = "log"] + fn wit_import(_: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, ){ unreachable!() } + wit_import(ptr0); + } + } + + } + + } + #[allow(dead_code)] + pub mod sqlite { + #[allow(dead_code, clippy::all)] + pub mod api { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// Represents an error with a code and a message. + #[derive(Clone)] + pub struct ErrorInfo { + /// The numeric result code of the error. + pub code: i32, + /// The error message associated with the error code. + pub message: _rt::String, + } + impl ::core::fmt::Debug for ErrorInfo { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ErrorInfo").field("code", &self.code).field("message", &self.message).finish() + } + } + /// Errors that indicate that something has gone wrong. + #[derive(Clone, Copy)] + pub enum Errno { + /// An error caused from internal SQLite engine. + Sqlite(i32), + /// An error caused during the conversion of a CString. + ConvertingCString, + /// The in-memory configuration provided is invalid. + InvalidInMemoryConfig, + /// The persistent configuration provided is invalid. + InvalidPersistentConfig, + /// The database name is missing in the persistent configuration. + MissingDatabaseNameForPersistentConfig, + /// Failed to open the database. + FailedOpeningDatabase, + /// Failed to set the database size limit. + FailedSettingDatabaseSize, + /// Unknown column type is retrieved. + UnknownColumnType, + /// `PRAGMA` commands are not allowed to execute inside Hermes. + ForbiddenPragmaCommand, + /// Unhandled null pointer is returned while interacting with the database. + ReturnedNullPointer, + /// The numeric value is truncated or improperly converted during the execution. + ConvertingNumeric, + } + impl ::core::fmt::Debug for Errno { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Errno::Sqlite(e) => { + f.debug_tuple("Errno::Sqlite").field(e).finish() + } + Errno::ConvertingCString => { + f.debug_tuple("Errno::ConvertingCString").finish() + } + Errno::InvalidInMemoryConfig => { + f.debug_tuple("Errno::InvalidInMemoryConfig").finish() + } + Errno::InvalidPersistentConfig => { + f.debug_tuple("Errno::InvalidPersistentConfig").finish() + } + Errno::MissingDatabaseNameForPersistentConfig => { + f.debug_tuple("Errno::MissingDatabaseNameForPersistentConfig").finish() + } + Errno::FailedOpeningDatabase => { + f.debug_tuple("Errno::FailedOpeningDatabase").finish() + } + Errno::FailedSettingDatabaseSize => { + f.debug_tuple("Errno::FailedSettingDatabaseSize").finish() + } + Errno::UnknownColumnType => { + f.debug_tuple("Errno::UnknownColumnType").finish() + } + Errno::ForbiddenPragmaCommand => { + f.debug_tuple("Errno::ForbiddenPragmaCommand").finish() + } + Errno::ReturnedNullPointer => { + f.debug_tuple("Errno::ReturnedNullPointer").finish() + } + Errno::ConvertingNumeric => { + f.debug_tuple("Errno::ConvertingNumeric").finish() + } + } + } + } + impl ::core::fmt::Display for Errno { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } + + impl std::error::Error for Errno {} + /// The value of a column in a specific data format. + #[derive(Clone)] + pub enum Value { + /// A blob or a UTF-8 text in bytes. + Blob(_rt::Vec::), + /// Real number. + Double(f64), + /// 32-bit integer. + Int32(i32), + /// 64-bit integer. + Int64(i64), + /// Null value. + Null, + /// UTF-8 text. + Text(_rt::String), + } + impl ::core::fmt::Debug for Value { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Value::Blob(e) => { + f.debug_tuple("Value::Blob").field(e).finish() + } + Value::Double(e) => { + f.debug_tuple("Value::Double").field(e).finish() + } + Value::Int32(e) => { + f.debug_tuple("Value::Int32").field(e).finish() + } + Value::Int64(e) => { + f.debug_tuple("Value::Int64").field(e).finish() + } + Value::Null => { + f.debug_tuple("Value::Null").finish() + } + Value::Text(e) => { + f.debug_tuple("Value::Text").field(e).finish() + } + } + } + } + /// The database connection object. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Sqlite{ + handle: _rt::Resource, + } + + impl Sqlite{ + #[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 Sqlite{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "hermes:sqlite/api")] + extern "C" { + #[link_name = "[resource-drop]sqlite"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// The prepared statement object. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Statement{ + handle: _rt::Resource, + } + + impl Statement{ + #[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 Statement{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "hermes:sqlite/api")] + extern "C" { + #[link_name = "[resource-drop]statement"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Sqlite { + #[allow(unused_unsafe, clippy::all)] + /// Closes a database connection, destructor for `sqlite3`. + /// + /// Ideally, applications should finalize all prepared statements associated with the `sqlite3` object prior to attempting to close the object. + /// If the database connection is associated with unfinalized prepared statements, + /// then the function will leave the database connection open and return the `busy` error code. + /// + /// If an `sqlite3` object is destroyed while a transaction is open, the transaction is automatically rolled back. + pub fn close(&self,) -> Result<(),Errno>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:sqlite/api")] + extern "C" { + #[link_name = "[method]sqlite.close"] + 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 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + l3 + }; + Errno::Sqlite(e4) + } + 1 => { + Errno::ConvertingCString + } + 2 => { + Errno::InvalidInMemoryConfig + } + 3 => { + Errno::InvalidPersistentConfig + } + 4 => { + Errno::MissingDatabaseNameForPersistentConfig + } + 5 => { + Errno::FailedOpeningDatabase + } + 6 => { + Errno::FailedSettingDatabaseSize + } + 7 => { + Errno::UnknownColumnType + } + 8 => { + Errno::ForbiddenPragmaCommand + } + 9 => { + Errno::ReturnedNullPointer + } + n => { + debug_assert_eq!(n, 10, "invalid enum discriminant"); + Errno::ConvertingNumeric + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Sqlite { + #[allow(unused_unsafe, clippy::all)] + /// Retrieves the numeric result code for the most recent failed SQLite operation on a database connection. + /// + /// # Returns + /// + /// The error object containing numeric code and detail message for the most recent failed SQLite operation. If there is no recent failed, none is returned. + pub fn errcode(&self,) -> Option{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:sqlite/api")] + extern "C" { + #[link_name = "[method]sqlite.errcode"] + 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 = *ptr0.add(4).cast::(); + let l3 = *ptr0.add(8).cast::<*mut u8>(); + let l4 = *ptr0.add(12).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + ErrorInfo{ + code: l2, + message: _rt::string_lift(bytes5), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Sqlite { + #[allow(unused_unsafe, clippy::all)] + /// Compiles SQL text into byte-code that will do the work of querying or updating the database. + /// + /// ## Parameters + /// + /// - `db`: Database handle. + /// - `sql`: SQL statement, UTF-8 encoded. + /// + /// ## Returns + /// + /// A compiled prepared statement that can be executed using `sqlite3_step()`. + /// If there is an error or the input text contains no SQL (if the input is an empty string or a comment) then an error code is returned. + pub fn prepare(&self,sql: &str,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = sql; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:sqlite/api")] + extern "C" { + #[link_name = "[method]sqlite.prepare"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(4).cast::(); + + Statement::from_handle(l3 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr1.add(4).cast::()); + let v6 = match l4 { + 0 => { + let e6 = { + let l5 = *ptr1.add(8).cast::(); + + l5 + }; + Errno::Sqlite(e6) + } + 1 => { + Errno::ConvertingCString + } + 2 => { + Errno::InvalidInMemoryConfig + } + 3 => { + Errno::InvalidPersistentConfig + } + 4 => { + Errno::MissingDatabaseNameForPersistentConfig + } + 5 => { + Errno::FailedOpeningDatabase + } + 6 => { + Errno::FailedSettingDatabaseSize + } + 7 => { + Errno::UnknownColumnType + } + 8 => { + Errno::ForbiddenPragmaCommand + } + 9 => { + Errno::ReturnedNullPointer + } + n => { + debug_assert_eq!(n, 10, "invalid enum discriminant"); + Errno::ConvertingNumeric + } + }; + + v6 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Sqlite { + #[allow(unused_unsafe, clippy::all)] + /// Executes an SQL query directly without preparing it into a statement and returns the result. + /// + /// ## Parameters + /// + /// - `sql`: SQL statement, UTF-8 encoded. + pub fn execute(&self,sql: &str,) -> Result<(),Errno>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = sql; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:sqlite/api")] + extern "C" { + #[link_name = "[method]sqlite.execute"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr1.add(8).cast::(); + + l4 + }; + Errno::Sqlite(e5) + } + 1 => { + Errno::ConvertingCString + } + 2 => { + Errno::InvalidInMemoryConfig + } + 3 => { + Errno::InvalidPersistentConfig + } + 4 => { + Errno::MissingDatabaseNameForPersistentConfig + } + 5 => { + Errno::FailedOpeningDatabase + } + 6 => { + Errno::FailedSettingDatabaseSize + } + 7 => { + Errno::UnknownColumnType + } + 8 => { + Errno::ForbiddenPragmaCommand + } + 9 => { + Errno::ReturnedNullPointer + } + n => { + debug_assert_eq!(n, 10, "invalid enum discriminant"); + Errno::ConvertingNumeric + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Statement { + #[allow(unused_unsafe, clippy::all)] + /// Stores application data into parameters of the original SQL. + /// + /// ## Parameters + /// + /// - `index`: The index of the SQL parameter to be set. + /// - `value`: The value to bind to the parameter. + pub fn bind(&self,index: u32,value: &Value,) -> Result<(),Errno>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let (result2_0,result2_1,result2_2,) = match value { + Value::Blob(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (0i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr0.cast_mut()); + t + }, len0) + }, + Value::Double(e) => (1i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), + Value::Int32(e) => (2i32, ::core::mem::MaybeUninit::new(i64::from(_rt::as_i32(e)) as u64), 0usize), + Value::Int64(e) => (3i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), + Value::Null=> { + (4i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) + } + Value::Text(e) => { + let vec1 = e; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + (5i32, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(ptr1.cast_mut()); + t + }, len1) + }, + }; + let ptr3 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:sqlite/api")] + extern "C" { + #[link_name = "[method]statement.bind"] + fn wit_import(_: i32, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, _rt::as_i32(&index), result2_0, result2_1, result2_2, ptr3); + let l4 = i32::from(*ptr3.add(0).cast::()); + match l4 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr3.add(4).cast::()); + let v7 = match l5 { + 0 => { + let e7 = { + let l6 = *ptr3.add(8).cast::(); + + l6 + }; + Errno::Sqlite(e7) + } + 1 => { + Errno::ConvertingCString + } + 2 => { + Errno::InvalidInMemoryConfig + } + 3 => { + Errno::InvalidPersistentConfig + } + 4 => { + Errno::MissingDatabaseNameForPersistentConfig + } + 5 => { + Errno::FailedOpeningDatabase + } + 6 => { + Errno::FailedSettingDatabaseSize + } + 7 => { + Errno::UnknownColumnType + } + 8 => { + Errno::ForbiddenPragmaCommand + } + 9 => { + Errno::ReturnedNullPointer + } + n => { + debug_assert_eq!(n, 10, "invalid enum discriminant"); + Errno::ConvertingNumeric + } + }; + + v7 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Statement { + #[allow(unused_unsafe, clippy::all)] + /// Advances a statement to the next result row or to completion. + /// + /// After a prepared statement has been prepared, this function must be called one or more times to evaluate the statement. + pub fn step(&self,) -> Result<(),Errno>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:sqlite/api")] + extern "C" { + #[link_name = "[method]statement.step"] + 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 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + l3 + }; + Errno::Sqlite(e4) + } + 1 => { + Errno::ConvertingCString + } + 2 => { + Errno::InvalidInMemoryConfig + } + 3 => { + Errno::InvalidPersistentConfig + } + 4 => { + Errno::MissingDatabaseNameForPersistentConfig + } + 5 => { + Errno::FailedOpeningDatabase + } + 6 => { + Errno::FailedSettingDatabaseSize + } + 7 => { + Errno::UnknownColumnType + } + 8 => { + Errno::ForbiddenPragmaCommand + } + 9 => { + Errno::ReturnedNullPointer + } + n => { + debug_assert_eq!(n, 10, "invalid enum discriminant"); + Errno::ConvertingNumeric + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Statement { + #[allow(unused_unsafe, clippy::all)] + /// Returns information about a single column of the current result row of a query. + /// + /// If the SQL statement does not currently point to a valid row, or if the column index is out of range, the result is undefined. + /// + /// ## Parameters + /// + /// - `index`: The index of the column for which information should be returned. The leftmost column of the result set has the index 0. + /// + /// ## Returns + /// + /// The value of a result column in a specific data format. + pub fn column(&self,index: u32,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:sqlite/api")] + extern "C" { + #[link_name = "[method]statement.column"] + fn wit_import(_: i32, _: i32, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, _rt::as_i32(&index), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = i32::from(*ptr0.add(8).cast::()); + let v12 = match l2 { + 0 => { + let e12 = { + let l3 = *ptr0.add(16).cast::<*mut u8>(); + let l4 = *ptr0.add(20).cast::(); + let len5 = l4; + + _rt::Vec::from_raw_parts(l3.cast(), len5, len5) + }; + Value::Blob(e12) + } + 1 => { + let e12 = { + let l6 = *ptr0.add(16).cast::(); + + l6 + }; + Value::Double(e12) + } + 2 => { + let e12 = { + let l7 = *ptr0.add(16).cast::(); + + l7 + }; + Value::Int32(e12) + } + 3 => { + let e12 = { + let l8 = *ptr0.add(16).cast::(); + + l8 + }; + Value::Int64(e12) + } + 4 => { + Value::Null + } + n => { + debug_assert_eq!(n, 5, "invalid enum discriminant"); + let e12 = { + let l9 = *ptr0.add(16).cast::<*mut u8>(); + let l10 = *ptr0.add(20).cast::(); + let len11 = l10; + let bytes11 = _rt::Vec::from_raw_parts(l9.cast(), len11, len11); + + _rt::string_lift(bytes11) + }; + Value::Text(e12) + } + }; + + v12 + }; + Ok(e) + } + 1 => { + let e = { + let l13 = i32::from(*ptr0.add(8).cast::()); + let v15 = match l13 { + 0 => { + let e15 = { + let l14 = *ptr0.add(12).cast::(); + + l14 + }; + Errno::Sqlite(e15) + } + 1 => { + Errno::ConvertingCString + } + 2 => { + Errno::InvalidInMemoryConfig + } + 3 => { + Errno::InvalidPersistentConfig + } + 4 => { + Errno::MissingDatabaseNameForPersistentConfig + } + 5 => { + Errno::FailedOpeningDatabase + } + 6 => { + Errno::FailedSettingDatabaseSize + } + 7 => { + Errno::UnknownColumnType + } + 8 => { + Errno::ForbiddenPragmaCommand + } + 9 => { + Errno::ReturnedNullPointer + } + n => { + debug_assert_eq!(n, 10, "invalid enum discriminant"); + Errno::ConvertingNumeric + } + }; + + v15 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Statement { + #[allow(unused_unsafe, clippy::all)] + /// Destroys a prepared statement object. If the most recent evaluation of the statement encountered no errors or if the statement is never been evaluated, + /// then the function results without errors. If the most recent evaluation of statement failed, then the function results the appropriate error code. + /// + /// The application must finalize every prepared statement in order to avoid resource leaks. + /// It is a grievous error for the application to try to use a prepared statement after it has been finalized. + /// Any use of a prepared statement after it has been finalized can result in undefined and undesirable behavior such as segfaults and heap corruption. + pub fn finalize(&self,) -> Result<(),Errno>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:sqlite/api")] + extern "C" { + #[link_name = "[method]statement.finalize"] + 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 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + l3 + }; + Errno::Sqlite(e4) + } + 1 => { + Errno::ConvertingCString + } + 2 => { + Errno::InvalidInMemoryConfig + } + 3 => { + Errno::InvalidPersistentConfig + } + 4 => { + Errno::MissingDatabaseNameForPersistentConfig + } + 5 => { + Errno::FailedOpeningDatabase + } + 6 => { + Errno::FailedSettingDatabaseSize + } + 7 => { + Errno::UnknownColumnType + } + 8 => { + Errno::ForbiddenPragmaCommand + } + 9 => { + Errno::ReturnedNullPointer + } + n => { + debug_assert_eq!(n, 10, "invalid enum discriminant"); + Errno::ConvertingNumeric + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Opens a connection to a new or existing SQLite database. + /// + /// ## Parameters + /// + /// - `readonly`: If set to true, the database is opened in read-only mode. An error is returned if the database doesn't already exist. + /// - `memory`: If set to true, the database will be opened as an in-memory database. + /// + /// ## Returns + /// + /// If the database is opened (and/or created) successfully, then the `sqlite3` object is returned. Otherwise an error code is returned. + pub fn open(readonly: bool,memory: bool,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "hermes:sqlite/api")] + extern "C" { + #[link_name = "open"] + fn wit_import(_: i32, _: i32, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, ){ unreachable!() } + wit_import(match &readonly { true => 1, false => 0 }, match &memory { true => 1, false => 0 }, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + Sqlite::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(8).cast::(); + + l4 + }; + Errno::Sqlite(e5) + } + 1 => { + Errno::ConvertingCString + } + 2 => { + Errno::InvalidInMemoryConfig + } + 3 => { + Errno::InvalidPersistentConfig + } + 4 => { + Errno::MissingDatabaseNameForPersistentConfig + } + 5 => { + Errno::FailedOpeningDatabase + } + 6 => { + Errno::FailedSettingDatabaseSize + } + 7 => { + Errno::UnknownColumnType + } + 8 => { + Errno::ForbiddenPragmaCommand + } + 9 => { + Errno::ReturnedNullPointer + } + n => { + debug_assert_eq!(n, 10, "invalid enum discriminant"); + Errno::ConvertingNumeric + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + + } + + } +} +#[allow(dead_code)] +pub mod wasi { + #[allow(dead_code)] + pub mod cli { + #[allow(dead_code, clippy::all)] + pub mod environment { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + #[allow(unused_unsafe, clippy::all)] + /// Get the POSIX-style environment variables. + /// + /// Each environment variable is provided as a pair of string variable names + /// and string value. + /// + /// Morally, these are a value import, but until value imports are available + /// in the component model, this import function should return the same + /// values each time it is called. + pub fn get_environment() -> _rt::Vec::<(_rt::String,_rt::String,)>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:cli/environment@0.2.0")] + extern "C" { + #[link_name = "get-environment"] + 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::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let base9 = l1; + let len9 = l2; + let mut result9 = _rt::Vec::with_capacity(len9); + for i in 0..len9 { + let base = base9.add(i * 16); + let e9 = { + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + let l6 = *base.add(8).cast::<*mut u8>(); + let l7 = *base.add(12).cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts(l6.cast(), len8, len8); + + (_rt::string_lift(bytes5), _rt::string_lift(bytes8)) + }; + result9.push(e9); + } + _rt::cabi_dealloc(base9, len9 * 16, 4); + result9 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Get the POSIX-style arguments to the program. + pub fn get_arguments() -> _rt::Vec::<_rt::String>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:cli/environment@0.2.0")] + extern "C" { + #[link_name = "get-arguments"] + 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::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let base6 = l1; + let len6 = l2; + let mut result6 = _rt::Vec::with_capacity(len6); + for i in 0..len6 { + let base = base6.add(i * 8); + let e6 = { + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + result6.push(e6); + } + _rt::cabi_dealloc(base6, len6 * 8, 4); + result6 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Return a path that programs should use as their initial current working + /// directory, interpreting `.` as shorthand for this. + pub fn initial_cwd() -> Option<_rt::String>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:cli/environment@0.2.0")] + extern "C" { + #[link_name = "initial-cwd"] + fn wit_import(_: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, ){ unreachable!() } + wit_import(ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => None, + 1 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + + } + + #[allow(dead_code, clippy::all)] + pub mod exit { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + #[allow(unused_unsafe, clippy::all)] + /// Exit the current instance and any linked instances. + pub fn exit(status: Result<(),()>,){ + unsafe { + let result0 = match status { + Ok(_) => { 0i32 }, + Err(_) => { 1i32 }, + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:cli/exit@0.2.0")] + extern "C" { + #[link_name = "exit"] + fn wit_import(_: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ){ unreachable!() } + wit_import(result0); + } + } + + } + + #[allow(dead_code, clippy::all)] + pub mod stdin { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + pub type InputStream = super::super::super::wasi::io::streams::InputStream; + #[allow(unused_unsafe, clippy::all)] + pub fn get_stdin() -> InputStream{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:cli/stdin@0.2.0")] + extern "C" { + #[link_name = "get-stdin"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32{ unreachable!() } + let ret = wit_import(); + super::super::super::wasi::io::streams::InputStream::from_handle(ret as u32) + } + } + + } + + #[allow(dead_code, clippy::all)] + pub mod stdout { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; + #[allow(unused_unsafe, clippy::all)] + pub fn get_stdout() -> OutputStream{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:cli/stdout@0.2.0")] + extern "C" { + #[link_name = "get-stdout"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32{ unreachable!() } + let ret = wit_import(); + super::super::super::wasi::io::streams::OutputStream::from_handle(ret as u32) + } + } + + } + + #[allow(dead_code, clippy::all)] + pub mod stderr { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; + #[allow(unused_unsafe, clippy::all)] + pub fn get_stderr() -> OutputStream{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:cli/stderr@0.2.0")] + extern "C" { + #[link_name = "get-stderr"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32{ unreachable!() } + let ret = wit_import(); + super::super::super::wasi::io::streams::OutputStream::from_handle(ret as u32) + } + } + + } + + } + #[allow(dead_code)] + pub mod clocks { + #[allow(dead_code, clippy::all)] + pub mod monotonic_clock { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + /// Hermes does not support `poll` + /// use wasi:io/poll@0.2.0.{pollable}; + /// An instant in time, in nanoseconds. An instant is relative to an + /// unspecified initial value, and can only be compared to instances from + /// the same monotonic-clock. + pub type Instant = u64; + /// A duration of time, in nanoseconds. + pub type Duration = u64; + #[allow(unused_unsafe, clippy::all)] + /// Read the current value of the clock. + /// + /// The clock is monotonic, therefore calling this function repeatedly will + /// produce a sequence of non-decreasing values. + pub fn now() -> Instant{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] + extern "C" { + #[link_name = "now"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64{ unreachable!() } + let ret = wit_import(); + ret as u64 + } + } + #[allow(unused_unsafe, clippy::all)] + /// Query the resolution of the clock. Returns the duration of time + /// corresponding to a clock tick. + pub fn resolution() -> Duration{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] + extern "C" { + #[link_name = "resolution"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64{ unreachable!() } + let ret = wit_import(); + ret as u64 + } + } + + } + + #[allow(dead_code, clippy::all)] + pub mod wall_clock { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + /// A time and date in seconds plus nanoseconds. + #[repr(C)] + #[derive(Clone, Copy)] + pub struct Datetime { + pub seconds: u64, + pub nanoseconds: u32, + } + impl ::core::fmt::Debug for Datetime { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Datetime").field("seconds", &self.seconds).field("nanoseconds", &self.nanoseconds).finish() + } + } + #[allow(unused_unsafe, clippy::all)] + /// Read the current value of the clock. + /// + /// This clock is not monotonic, therefore calling this function repeatedly + /// will not necessarily produce a sequence of non-decreasing values. + /// + /// The returned timestamps represent the number of seconds since + /// 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch], + /// also known as [Unix Time]. + /// + /// The nanoseconds field of the output is always less than 1000000000. + /// + /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 + /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time + pub fn now() -> Datetime{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.0")] + extern "C" { + #[link_name = "now"] + 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::(); + Datetime{ + seconds: l1 as u64, + nanoseconds: l2 as u32, + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Query the resolution of the clock. + /// + /// The nanoseconds field of the output is always less than 1000000000. + pub fn resolution() -> Datetime{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.0")] + extern "C" { + #[link_name = "resolution"] + 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::(); + Datetime{ + seconds: l1 as u64, + nanoseconds: l2 as u32, + } + } + } + + } + + } + #[allow(dead_code)] + pub mod filesystem { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type InputStream = super::super::super::wasi::io::streams::InputStream; + pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; + pub type Error = super::super::super::wasi::io::streams::Error; + pub type Datetime = super::super::super::wasi::clocks::wall_clock::Datetime; + /// File size or length of a region within a file. + pub type Filesize = u64; + /// The type of a filesystem object referenced by a descriptor. + /// + /// Note: This was called `filetype` in earlier versions of WASI. + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum DescriptorType { + /// The type of the descriptor or file is unknown or is different from + /// any of the other types specified. + Unknown, + /// The descriptor refers to a block device inode. + BlockDevice, + /// The descriptor refers to a character device inode. + CharacterDevice, + /// The descriptor refers to a directory inode. + Directory, + /// The descriptor refers to a named pipe. + Fifo, + /// The file refers to a symbolic link inode. + SymbolicLink, + /// The descriptor refers to a regular file inode. + RegularFile, + /// The descriptor refers to a socket. + Socket, + } + impl ::core::fmt::Debug for DescriptorType { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + DescriptorType::Unknown => { + f.debug_tuple("DescriptorType::Unknown").finish() + } + DescriptorType::BlockDevice => { + f.debug_tuple("DescriptorType::BlockDevice").finish() + } + DescriptorType::CharacterDevice => { + f.debug_tuple("DescriptorType::CharacterDevice").finish() + } + DescriptorType::Directory => { + f.debug_tuple("DescriptorType::Directory").finish() + } + DescriptorType::Fifo => { + f.debug_tuple("DescriptorType::Fifo").finish() + } + DescriptorType::SymbolicLink => { + f.debug_tuple("DescriptorType::SymbolicLink").finish() + } + DescriptorType::RegularFile => { + f.debug_tuple("DescriptorType::RegularFile").finish() + } + DescriptorType::Socket => { + f.debug_tuple("DescriptorType::Socket").finish() + } + } + } + } + + impl DescriptorType{ + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> DescriptorType{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => DescriptorType::Unknown, + 1 => DescriptorType::BlockDevice, + 2 => DescriptorType::CharacterDevice, + 3 => DescriptorType::Directory, + 4 => DescriptorType::Fifo, + 5 => DescriptorType::SymbolicLink, + 6 => DescriptorType::RegularFile, + 7 => DescriptorType::Socket, + + _ => panic!("invalid enum discriminant"), + } + } + } + + wit_bindgen::rt::bitflags::bitflags! { + /// Descriptor flags. + /// + /// Note: This was called `fdflags` in earlier versions of WASI. + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] + pub struct DescriptorFlags: u8 { + /// Read mode: Data can be read. + const READ = 1 << 0; + /// Write mode: Data can be written to. + const WRITE = 1 << 1; + /// Request that writes be performed according to synchronized I/O file + /// integrity completion. The data stored in the file and the file's + /// metadata are synchronized. This is similar to `O_SYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. + const FILE_INTEGRITY_SYNC = 1 << 2; + /// Request that writes be performed according to synchronized I/O data + /// integrity completion. Only the data stored in the file is + /// synchronized. This is similar to `O_DSYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. + const DATA_INTEGRITY_SYNC = 1 << 3; + /// Requests that reads be performed at the same level of integrety + /// requested for writes. This is similar to `O_RSYNC` in POSIX. + /// + /// The precise semantics of this operation have not yet been defined for + /// WASI. At this time, it should be interpreted as a request, and not a + /// requirement. + const REQUESTED_WRITE_SYNC = 1 << 4; + /// Mutating directories mode: Directory contents may be mutated. + /// + /// When this flag is unset on a descriptor, operations using the + /// descriptor which would create, rename, delete, modify the data or + /// metadata of filesystem objects, or obtain another handle which + /// would permit any of those, shall fail with `error-code::read-only` if + /// they would otherwise succeed. + /// + /// This may only be set on directories. + const MUTATE_DIRECTORY = 1 << 5; + } + } + wit_bindgen::rt::bitflags::bitflags! { + /// Flags determining the method of how paths are resolved. + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] + pub struct PathFlags: u8 { + /// As long as the resolved path corresponds to a symbolic link, it is + /// expanded. + const SYMLINK_FOLLOW = 1 << 0; + } + } + wit_bindgen::rt::bitflags::bitflags! { + /// Open flags used by `open-at`. + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] + pub struct OpenFlags: u8 { + /// Create file if it does not exist, similar to `O_CREAT` in POSIX. + const CREATE = 1 << 0; + /// Fail if not a directory, similar to `O_DIRECTORY` in POSIX. + const DIRECTORY = 1 << 1; + /// Fail if file already exists, similar to `O_EXCL` in POSIX. + const EXCLUSIVE = 1 << 2; + /// Truncate file to size 0, similar to `O_TRUNC` in POSIX. + const TRUNCATE = 1 << 3; + } + } + /// Number of hard links to an inode. + pub type LinkCount = u64; + /// File attributes. + /// + /// Note: This was called `filestat` in earlier versions of WASI. + #[repr(C)] + #[derive(Clone, Copy)] + pub struct DescriptorStat { + /// File type. + pub type_: DescriptorType, + /// Number of hard links to the file. + pub link_count: LinkCount, + /// For regular files, the file size in bytes. For symbolic links, the + /// length in bytes of the pathname contained in the symbolic link. + pub size: Filesize, + /// Last data access timestamp. + /// + /// If the `option` is none, the platform doesn't maintain an access + /// timestamp for this file. + pub data_access_timestamp: Option, + /// Last data modification timestamp. + /// + /// If the `option` is none, the platform doesn't maintain a + /// modification timestamp for this file. + pub data_modification_timestamp: Option, + /// Last file status-change timestamp. + /// + /// If the `option` is none, the platform doesn't maintain a + /// status-change timestamp for this file. + pub status_change_timestamp: Option, + } + impl ::core::fmt::Debug for DescriptorStat { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DescriptorStat").field("type", &self.type_).field("link-count", &self.link_count).field("size", &self.size).field("data-access-timestamp", &self.data_access_timestamp).field("data-modification-timestamp", &self.data_modification_timestamp).field("status-change-timestamp", &self.status_change_timestamp).finish() + } + } + /// When setting a timestamp, this gives the value to set it to. + #[derive(Clone, Copy)] + pub enum NewTimestamp { + /// Leave the timestamp set to its previous value. + NoChange, + /// Set the timestamp to the current time of the system clock associated + /// with the filesystem. + Now, + /// Set the timestamp to the given value. + Timestamp(Datetime), + } + impl ::core::fmt::Debug for NewTimestamp { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + NewTimestamp::NoChange => { + f.debug_tuple("NewTimestamp::NoChange").finish() + } + NewTimestamp::Now => { + f.debug_tuple("NewTimestamp::Now").finish() + } + NewTimestamp::Timestamp(e) => { + f.debug_tuple("NewTimestamp::Timestamp").field(e).finish() + } + } + } + } + /// A directory entry. + #[derive(Clone)] + pub struct DirectoryEntry { + /// The type of the file referred to by this directory entry. + pub type_: DescriptorType, + /// The name of the object. + pub name: _rt::String, + } + impl ::core::fmt::Debug for DirectoryEntry { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DirectoryEntry").field("type", &self.type_).field("name", &self.name).finish() + } + } + /// Error codes returned by functions, similar to `errno` in POSIX. + /// Not all of these error codes are returned by the functions provided by this + /// API; some are used in higher-level library layers, and others are provided + /// merely for alignment with POSIX. + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum ErrorCode { + /// Permission denied, similar to `EACCES` in POSIX. + Access, + /// Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX. + WouldBlock, + /// Connection already in progress, similar to `EALREADY` in POSIX. + Already, + /// Bad descriptor, similar to `EBADF` in POSIX. + BadDescriptor, + /// Device or resource busy, similar to `EBUSY` in POSIX. + Busy, + /// Resource deadlock would occur, similar to `EDEADLK` in POSIX. + Deadlock, + /// Storage quota exceeded, similar to `EDQUOT` in POSIX. + Quota, + /// File exists, similar to `EEXIST` in POSIX. + Exist, + /// File too large, similar to `EFBIG` in POSIX. + FileTooLarge, + /// Illegal byte sequence, similar to `EILSEQ` in POSIX. + IllegalByteSequence, + /// Operation in progress, similar to `EINPROGRESS` in POSIX. + InProgress, + /// Interrupted function, similar to `EINTR` in POSIX. + Interrupted, + /// Invalid argument, similar to `EINVAL` in POSIX. + Invalid, + /// I/O error, similar to `EIO` in POSIX. + Io, + /// Is a directory, similar to `EISDIR` in POSIX. + IsDirectory, + /// Too many levels of symbolic links, similar to `ELOOP` in POSIX. + Loop, + /// Too many links, similar to `EMLINK` in POSIX. + TooManyLinks, + /// Message too large, similar to `EMSGSIZE` in POSIX. + MessageSize, + /// Filename too long, similar to `ENAMETOOLONG` in POSIX. + NameTooLong, + /// No such device, similar to `ENODEV` in POSIX. + NoDevice, + /// No such file or directory, similar to `ENOENT` in POSIX. + NoEntry, + /// No locks available, similar to `ENOLCK` in POSIX. + NoLock, + /// Not enough space, similar to `ENOMEM` in POSIX. + InsufficientMemory, + /// No space left on device, similar to `ENOSPC` in POSIX. + InsufficientSpace, + /// Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX. + NotDirectory, + /// Directory not empty, similar to `ENOTEMPTY` in POSIX. + NotEmpty, + /// State not recoverable, similar to `ENOTRECOVERABLE` in POSIX. + NotRecoverable, + /// Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX. + Unsupported, + /// Inappropriate I/O control operation, similar to `ENOTTY` in POSIX. + NoTty, + /// No such device or address, similar to `ENXIO` in POSIX. + NoSuchDevice, + /// Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX. + Overflow, + /// Operation not permitted, similar to `EPERM` in POSIX. + NotPermitted, + /// Broken pipe, similar to `EPIPE` in POSIX. + Pipe, + /// Read-only file system, similar to `EROFS` in POSIX. + ReadOnly, + /// Invalid seek, similar to `ESPIPE` in POSIX. + InvalidSeek, + /// Text file busy, similar to `ETXTBSY` in POSIX. + TextFileBusy, + /// Cross-device link, similar to `EXDEV` in POSIX. + CrossDevice, + } + impl ErrorCode{ + pub fn name(&self) -> &'static str { + match self { + ErrorCode::Access => "access", + ErrorCode::WouldBlock => "would-block", + ErrorCode::Already => "already", + ErrorCode::BadDescriptor => "bad-descriptor", + ErrorCode::Busy => "busy", + ErrorCode::Deadlock => "deadlock", + ErrorCode::Quota => "quota", + ErrorCode::Exist => "exist", + ErrorCode::FileTooLarge => "file-too-large", + ErrorCode::IllegalByteSequence => "illegal-byte-sequence", + ErrorCode::InProgress => "in-progress", + ErrorCode::Interrupted => "interrupted", + ErrorCode::Invalid => "invalid", + ErrorCode::Io => "io", + ErrorCode::IsDirectory => "is-directory", + ErrorCode::Loop => "loop", + ErrorCode::TooManyLinks => "too-many-links", + ErrorCode::MessageSize => "message-size", + ErrorCode::NameTooLong => "name-too-long", + ErrorCode::NoDevice => "no-device", + ErrorCode::NoEntry => "no-entry", + ErrorCode::NoLock => "no-lock", + ErrorCode::InsufficientMemory => "insufficient-memory", + ErrorCode::InsufficientSpace => "insufficient-space", + ErrorCode::NotDirectory => "not-directory", + ErrorCode::NotEmpty => "not-empty", + ErrorCode::NotRecoverable => "not-recoverable", + ErrorCode::Unsupported => "unsupported", + ErrorCode::NoTty => "no-tty", + ErrorCode::NoSuchDevice => "no-such-device", + ErrorCode::Overflow => "overflow", + ErrorCode::NotPermitted => "not-permitted", + ErrorCode::Pipe => "pipe", + ErrorCode::ReadOnly => "read-only", + ErrorCode::InvalidSeek => "invalid-seek", + ErrorCode::TextFileBusy => "text-file-busy", + ErrorCode::CrossDevice => "cross-device", + } + } + 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.", + } + } + } + impl ::core::fmt::Debug for ErrorCode{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ErrorCode") + .field("code", &(*self as i32)) + .field("name", &self.name()) + .field("message", &self.message()) + .finish() + } + } + impl ::core::fmt::Display for ErrorCode{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{} (error {})", self.name(), *self as i32) + } + } + + impl std::error::Error for ErrorCode {} + + impl ErrorCode{ + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> ErrorCode{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => ErrorCode::Access, + 1 => ErrorCode::WouldBlock, + 2 => ErrorCode::Already, + 3 => ErrorCode::BadDescriptor, + 4 => ErrorCode::Busy, + 5 => ErrorCode::Deadlock, + 6 => ErrorCode::Quota, + 7 => ErrorCode::Exist, + 8 => ErrorCode::FileTooLarge, + 9 => ErrorCode::IllegalByteSequence, + 10 => ErrorCode::InProgress, + 11 => ErrorCode::Interrupted, + 12 => ErrorCode::Invalid, + 13 => ErrorCode::Io, + 14 => ErrorCode::IsDirectory, + 15 => ErrorCode::Loop, + 16 => ErrorCode::TooManyLinks, + 17 => ErrorCode::MessageSize, + 18 => ErrorCode::NameTooLong, + 19 => ErrorCode::NoDevice, + 20 => ErrorCode::NoEntry, + 21 => ErrorCode::NoLock, + 22 => ErrorCode::InsufficientMemory, + 23 => ErrorCode::InsufficientSpace, + 24 => ErrorCode::NotDirectory, + 25 => ErrorCode::NotEmpty, + 26 => ErrorCode::NotRecoverable, + 27 => ErrorCode::Unsupported, + 28 => ErrorCode::NoTty, + 29 => ErrorCode::NoSuchDevice, + 30 => ErrorCode::Overflow, + 31 => ErrorCode::NotPermitted, + 32 => ErrorCode::Pipe, + 33 => ErrorCode::ReadOnly, + 34 => ErrorCode::InvalidSeek, + 35 => ErrorCode::TextFileBusy, + 36 => ErrorCode::CrossDevice, + + _ => panic!("invalid enum discriminant"), + } + } + } + + /// File or memory access pattern advisory information. + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum Advice { + /// The application has no advice to give on its behavior with respect + /// to the specified data. + Normal, + /// The application expects to access the specified data sequentially + /// from lower offsets to higher offsets. + Sequential, + /// The application expects to access the specified data in a random + /// order. + Random, + /// The application expects to access the specified data in the near + /// future. + WillNeed, + /// The application expects that it will not access the specified data + /// in the near future. + DontNeed, + /// The application expects to access the specified data once and then + /// not reuse it thereafter. + NoReuse, + } + impl ::core::fmt::Debug for Advice { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Advice::Normal => { + f.debug_tuple("Advice::Normal").finish() + } + Advice::Sequential => { + f.debug_tuple("Advice::Sequential").finish() + } + Advice::Random => { + f.debug_tuple("Advice::Random").finish() + } + Advice::WillNeed => { + f.debug_tuple("Advice::WillNeed").finish() + } + Advice::DontNeed => { + f.debug_tuple("Advice::DontNeed").finish() + } + Advice::NoReuse => { + f.debug_tuple("Advice::NoReuse").finish() + } + } + } + } + + impl Advice{ + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> Advice{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => Advice::Normal, + 1 => Advice::Sequential, + 2 => Advice::Random, + 3 => Advice::WillNeed, + 4 => Advice::DontNeed, + 5 => Advice::NoReuse, + + _ => panic!("invalid enum discriminant"), + } + } + } + + /// A 128-bit hash value, split into parts because wasm doesn't have a + /// 128-bit integer type. + #[repr(C)] + #[derive(Clone, Copy)] + pub struct MetadataHashValue { + /// 64 bits of a 128-bit hash value. + pub lower: u64, + /// Another 64 bits of a 128-bit hash value. + pub upper: u64, + } + impl ::core::fmt::Debug for MetadataHashValue { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("MetadataHashValue").field("lower", &self.lower).field("upper", &self.upper).finish() + } + } + /// A descriptor is a reference to a filesystem object, which may be a file, + /// directory, named pipe, special file, or other object on which filesystem + /// calls may be made. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Descriptor{ + handle: _rt::Resource, + } + + impl Descriptor{ + #[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 Descriptor{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]descriptor"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// A stream of directory entries. + + #[derive(Debug)] + #[repr(transparent)] + pub struct DirectoryEntryStream{ + handle: _rt::Resource, + } + + impl DirectoryEntryStream{ + #[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 DirectoryEntryStream{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]directory-entry-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return a stream for reading from a file, if available. + /// + /// May fail with an error-code describing why the file cannot be read. + /// + /// Multiple read, write, and append streams may be active on the same open + /// file and they do not interfere with each other. + /// + /// Note: This allows using `read-stream`, which is similar to `read` in POSIX. + pub fn read_via_stream(&self,offset: Filesize,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.read-via-stream"] + fn wit_import(_: i32, _: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, _rt::as_i64(offset), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::InputStream::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(4).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return a stream for writing to a file, if available. + /// + /// May fail with an error-code describing why the file cannot be written. + /// + /// Note: This allows using `write-stream`, which is similar to `write` in + /// POSIX. + pub fn write_via_stream(&self,offset: Filesize,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.write-via-stream"] + fn wit_import(_: i32, _: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, _rt::as_i64(offset), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(4).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return a stream for appending to a file, if available. + /// + /// May fail with an error-code describing why the file cannot be appended. + /// + /// Note: This allows using `write-stream`, which is similar to `write` with + /// `O_APPEND` in in POSIX. + pub fn append_via_stream(&self,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.append-via-stream"] + 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 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(4).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Provide file advisory information on a descriptor. + /// + /// This is similar to `posix_fadvise` in POSIX. + pub fn advise(&self,offset: Filesize,length: Filesize,advice: Advice,) -> Result<(),ErrorCode>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.advise"] + fn wit_import(_: i32, _: i64, _: i64, _: i32, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: i64, _: i32, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, _rt::as_i64(offset), _rt::as_i64(length), advice.clone() as i32, ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(1).cast::()); + + ErrorCode::_lift(l2 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Synchronize the data of a file to disk. + /// + /// This function succeeds with no effect if the file descriptor is not + /// opened for writing. + /// + /// Note: This is similar to `fdatasync` in POSIX. + pub fn sync_data(&self,) -> Result<(),ErrorCode>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.sync-data"] + 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 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(1).cast::()); + + ErrorCode::_lift(l2 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Get flags associated with a descriptor. + /// + /// Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX. + /// + /// Note: This returns the value that was the `fs_flags` value returned + /// from `fdstat_get` in earlier versions of WASI. + pub fn get_flags(&self,) -> Result{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.get-flags"] + 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 => { + let e = { + let l2 = i32::from(*ptr0.add(1).cast::()); + + DescriptorFlags::empty() | DescriptorFlags::from_bits_retain(((l2 as u8) << 0) as _) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(1).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Get the dynamic type of a descriptor. + /// + /// Note: This returns the same value as the `type` field of the `fd-stat` + /// returned by `stat`, `stat-at` and similar. + /// + /// Note: This returns similar flags to the `st_mode & S_IFMT` value provided + /// by `fstat` in POSIX. + /// + /// Note: This returns the value that was the `fs_filetype` value returned + /// from `fdstat_get` in earlier versions of WASI. + pub fn get_type(&self,) -> Result{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.get-type"] + 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 => { + let e = { + let l2 = i32::from(*ptr0.add(1).cast::()); + + DescriptorType::_lift(l2 as u8) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(1).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Adjust the size of an open file. If this increases the file's size, the + /// extra bytes are filled with zeros. + /// + /// Note: This was called `fd_filestat_set_size` in earlier versions of WASI. + pub fn set_size(&self,size: Filesize,) -> Result<(),ErrorCode>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.set-size"] + fn wit_import(_: i32, _: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, _rt::as_i64(size), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(1).cast::()); + + ErrorCode::_lift(l2 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Adjust the timestamps of an open file or directory. + /// + /// Note: This is similar to `futimens` in POSIX. + /// + /// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. + pub fn set_times(&self,data_access_timestamp: NewTimestamp,data_modification_timestamp: NewTimestamp,) -> Result<(),ErrorCode>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let (result1_0,result1_1,result1_2,) = match data_access_timestamp { + NewTimestamp::NoChange=> { + (0i32, 0i64, 0i32) + } + NewTimestamp::Now=> { + (1i32, 0i64, 0i32) + } + NewTimestamp::Timestamp(e) => { + let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds0, nanoseconds:nanoseconds0, } = e; + + (2i32, _rt::as_i64(seconds0), _rt::as_i32(nanoseconds0)) + }, + }; + let (result3_0,result3_1,result3_2,) = match data_modification_timestamp { + NewTimestamp::NoChange=> { + (0i32, 0i64, 0i32) + } + NewTimestamp::Now=> { + (1i32, 0i64, 0i32) + } + NewTimestamp::Timestamp(e) => { + let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds2, nanoseconds:nanoseconds2, } = e; + + (2i32, _rt::as_i64(seconds2), _rt::as_i32(nanoseconds2)) + }, + }; + let ptr4 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.set-times"] + fn wit_import(_: i32, _: i32, _: i64, _: i32, _: i32, _: i64, _: i32, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: i32, _: i32, _: i64, _: i32, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, result1_0, result1_1, result1_2, result3_0, result3_1, result3_2, ptr4); + let l5 = i32::from(*ptr4.add(0).cast::()); + match l5 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from(*ptr4.add(1).cast::()); + + ErrorCode::_lift(l6 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Read from a descriptor, without using and updating the descriptor's offset. + /// + /// This function returns a list of bytes containing the data that was + /// read, along with a bool which, when true, indicates that the end of the + /// file was reached. The returned list will contain up to `length` bytes; it + /// may return fewer than requested, if the end of the file is reached or + /// if the I/O operation is interrupted. + /// + /// In the future, this may change to return a `stream`. + /// + /// Note: This is similar to `pread` in POSIX. + pub fn read(&self,length: Filesize,offset: Filesize,) -> Result<(_rt::Vec::,bool,),ErrorCode>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.read"] + fn wit_import(_: i32, _: i64, _: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: i64, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, _rt::as_i64(length), _rt::as_i64(offset), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let l5 = i32::from(*ptr0.add(12).cast::()); + + (_rt::Vec::from_raw_parts(l2.cast(), len4, len4), _rt::bool_lift(l5 as u8)) + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from(*ptr0.add(4).cast::()); + + ErrorCode::_lift(l6 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Write to a descriptor, without using and updating the descriptor's offset. + /// + /// It is valid to write past the end of a file; the file is extended to the + /// extent of the write, with bytes between the previous end and the start of + /// the write set to zero. + /// + /// In the future, this may change to take a `stream`. + /// + /// Note: This is similar to `pwrite` in POSIX. + pub fn write(&self,buffer: &[u8],offset: Filesize,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let vec0 = buffer; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.write"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i64, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, _rt::as_i64(offset), ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(8).cast::(); + + l3 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr1.add(8).cast::()); + + ErrorCode::_lift(l4 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Read directory entries from a directory. + /// + /// On filesystems where directories contain entries referring to themselves + /// and their parents, often named `.` and `..` respectively, these entries + /// are omitted. + /// + /// This always returns a new stream which starts at the beginning of the + /// directory. Multiple streams may be active on the same directory, and they + /// do not interfere with each other. + pub fn read_directory(&self,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.read-directory"] + 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 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + DirectoryEntryStream::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(4).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Synchronize the data and metadata of a file to disk. + /// + /// This function succeeds with no effect if the file descriptor is not + /// opened for writing. + /// + /// Note: This is similar to `fsync` in POSIX. + pub fn sync(&self,) -> Result<(),ErrorCode>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.sync"] + 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 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(1).cast::()); + + ErrorCode::_lift(l2 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Create a directory. + /// + /// Note: This is similar to `mkdirat` in POSIX. + pub fn create_directory_at(&self,path: &str,) -> Result<(),ErrorCode>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.create-directory-at"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return the attributes of an open file or directory. + /// + /// Note: This is similar to `fstat` in POSIX, except that it does not return + /// device and inode information. For testing whether two descriptors refer to + /// the same underlying filesystem object, use `is-same-object`. To obtain + /// additional data that can be used do determine whether a file has been + /// modified, use `metadata-hash`. + /// + /// Note: This was called `fd_filestat_get` in earlier versions of WASI. + pub fn stat(&self,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 104]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 104]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.stat"] + 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 => { + let e = { + let l2 = i32::from(*ptr0.add(8).cast::()); + let l3 = *ptr0.add(16).cast::(); + let l4 = *ptr0.add(24).cast::(); + let l5 = i32::from(*ptr0.add(32).cast::()); + let l8 = i32::from(*ptr0.add(56).cast::()); + let l11 = i32::from(*ptr0.add(80).cast::()); + + DescriptorStat{ + type_: DescriptorType::_lift(l2 as u8), + link_count: l3 as u64, + size: l4 as u64, + data_access_timestamp: match l5 { + 0 => None, + 1 => { + let e = { + let l6 = *ptr0.add(40).cast::(); + let l7 = *ptr0.add(48).cast::(); + + super::super::super::wasi::clocks::wall_clock::Datetime{ + seconds: l6 as u64, + nanoseconds: l7 as u32, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + data_modification_timestamp: match l8 { + 0 => None, + 1 => { + let e = { + let l9 = *ptr0.add(64).cast::(); + let l10 = *ptr0.add(72).cast::(); + + super::super::super::wasi::clocks::wall_clock::Datetime{ + seconds: l9 as u64, + nanoseconds: l10 as u32, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + status_change_timestamp: match l11 { + 0 => None, + 1 => { + let e = { + let l12 = *ptr0.add(88).cast::(); + let l13 = *ptr0.add(96).cast::(); + + super::super::super::wasi::clocks::wall_clock::Datetime{ + seconds: l12 as u64, + nanoseconds: l13 as u32, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + Ok(e) + } + 1 => { + let e = { + let l14 = i32::from(*ptr0.add(8).cast::()); + + ErrorCode::_lift(l14 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return the attributes of a file or directory. + /// + /// Note: This is similar to `fstatat` in POSIX, except that it does not + /// return device and inode information. See the `stat` description for a + /// discussion of alternatives. + /// + /// Note: This was called `path_filestat_get` in earlier versions of WASI. + pub fn stat_at(&self,path_flags: PathFlags,path: &str,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 104]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 104]); + let flags0 = path_flags; + let vec1 = path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.stat-at"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1.cast_mut(), len1, ptr2); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = { + let l4 = i32::from(*ptr2.add(8).cast::()); + let l5 = *ptr2.add(16).cast::(); + let l6 = *ptr2.add(24).cast::(); + let l7 = i32::from(*ptr2.add(32).cast::()); + let l10 = i32::from(*ptr2.add(56).cast::()); + let l13 = i32::from(*ptr2.add(80).cast::()); + + DescriptorStat{ + type_: DescriptorType::_lift(l4 as u8), + link_count: l5 as u64, + size: l6 as u64, + data_access_timestamp: match l7 { + 0 => None, + 1 => { + let e = { + let l8 = *ptr2.add(40).cast::(); + let l9 = *ptr2.add(48).cast::(); + + super::super::super::wasi::clocks::wall_clock::Datetime{ + seconds: l8 as u64, + nanoseconds: l9 as u32, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + data_modification_timestamp: match l10 { + 0 => None, + 1 => { + let e = { + let l11 = *ptr2.add(64).cast::(); + let l12 = *ptr2.add(72).cast::(); + + super::super::super::wasi::clocks::wall_clock::Datetime{ + seconds: l11 as u64, + nanoseconds: l12 as u32, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + status_change_timestamp: match l13 { + 0 => None, + 1 => { + let e = { + let l14 = *ptr2.add(88).cast::(); + let l15 = *ptr2.add(96).cast::(); + + super::super::super::wasi::clocks::wall_clock::Datetime{ + seconds: l14 as u64, + nanoseconds: l15 as u32, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + Ok(e) + } + 1 => { + let e = { + let l16 = i32::from(*ptr2.add(8).cast::()); + + ErrorCode::_lift(l16 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Adjust the timestamps of a file or directory. + /// + /// Note: This is similar to `utimensat` in POSIX. + /// + /// Note: This was called `path_filestat_set_times` in earlier versions of + /// WASI. + pub fn set_times_at(&self,path_flags: PathFlags,path: &str,data_access_timestamp: NewTimestamp,data_modification_timestamp: NewTimestamp,) -> Result<(),ErrorCode>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let flags0 = path_flags; + let vec1 = path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let (result3_0,result3_1,result3_2,) = match data_access_timestamp { + NewTimestamp::NoChange=> { + (0i32, 0i64, 0i32) + } + NewTimestamp::Now=> { + (1i32, 0i64, 0i32) + } + NewTimestamp::Timestamp(e) => { + let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds2, nanoseconds:nanoseconds2, } = e; + + (2i32, _rt::as_i64(seconds2), _rt::as_i32(nanoseconds2)) + }, + }; + let (result5_0,result5_1,result5_2,) = match data_modification_timestamp { + NewTimestamp::NoChange=> { + (0i32, 0i64, 0i32) + } + NewTimestamp::Now=> { + (1i32, 0i64, 0i32) + } + NewTimestamp::Timestamp(e) => { + let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds4, nanoseconds:nanoseconds4, } = e; + + (2i32, _rt::as_i64(seconds4), _rt::as_i32(nanoseconds4)) + }, + }; + let ptr6 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.set-times-at"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: i32, _: i64, _: i32, _: i32, _: i64, _: i32, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: i32, _: i64, _: i32, _: i32, _: i64, _: i32, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1.cast_mut(), len1, result3_0, result3_1, result3_2, result5_0, result5_1, result5_2, ptr6); + let l7 = i32::from(*ptr6.add(0).cast::()); + match l7 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l8 = i32::from(*ptr6.add(1).cast::()); + + ErrorCode::_lift(l8 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Create a hard link. + /// + /// Note: This is similar to `linkat` in POSIX. + pub fn link_at(&self,old_path_flags: PathFlags,old_path: &str,new_descriptor: &Descriptor,new_path: &str,) -> Result<(),ErrorCode>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let flags0 = old_path_flags; + let vec1 = old_path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let vec2 = new_path; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let ptr3 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.link-at"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1.cast_mut(), len1, (new_descriptor).handle() as i32, ptr2.cast_mut(), len2, ptr3); + let l4 = i32::from(*ptr3.add(0).cast::()); + match l4 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr3.add(1).cast::()); + + ErrorCode::_lift(l5 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Open a file or directory. + /// + /// The returned descriptor is not guaranteed to be the lowest-numbered + /// descriptor not currently open/ it is randomized to prevent applications + /// from depending on making assumptions about indexes, since this is + /// error-prone in multi-threaded contexts. The returned descriptor is + /// guaranteed to be less than 2**31. + /// + /// If `flags` contains `descriptor-flags::mutate-directory`, and the base + /// descriptor doesn't have `descriptor-flags::mutate-directory` set, + /// `open-at` fails with `error-code::read-only`. + /// + /// If `flags` contains `write` or `mutate-directory`, or `open-flags` + /// contains `truncate` or `create`, and the base descriptor doesn't have + /// `descriptor-flags::mutate-directory` set, `open-at` fails with + /// `error-code::read-only`. + /// + /// Note: This is similar to `openat` in POSIX. + pub fn open_at(&self,path_flags: PathFlags,path: &str,open_flags: OpenFlags,flags: DescriptorFlags,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let flags0 = path_flags; + let vec1 = path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let flags2 = open_flags; + let flags3 = flags; + let ptr4 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.open-at"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1.cast_mut(), len1, (flags2.bits() >> 0) as i32, (flags3.bits() >> 0) as i32, ptr4); + let l5 = i32::from(*ptr4.add(0).cast::()); + match l5 { + 0 => { + let e = { + let l6 = *ptr4.add(4).cast::(); + + Descriptor::from_handle(l6 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l7 = i32::from(*ptr4.add(4).cast::()); + + ErrorCode::_lift(l7 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Read the contents of a symbolic link. + /// + /// If the contents contain an absolute or rooted path in the underlying + /// filesystem, this function fails with `error-code::not-permitted`. + /// + /// Note: This is similar to `readlinkat` in POSIX. + pub fn readlink_at(&self,path: &str,) -> Result<_rt::String,ErrorCode>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.readlink-at"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(4).cast::<*mut u8>(); + let l4 = *ptr1.add(8).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from(*ptr1.add(4).cast::()); + + ErrorCode::_lift(l6 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Remove a directory. + /// + /// Return `error-code::not-empty` if the directory is not empty. + /// + /// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. + pub fn remove_directory_at(&self,path: &str,) -> Result<(),ErrorCode>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.remove-directory-at"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Rename a filesystem object. + /// + /// Note: This is similar to `renameat` in POSIX. + pub fn rename_at(&self,old_path: &str,new_descriptor: &Descriptor,new_path: &str,) -> Result<(),ErrorCode>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = old_path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec1 = new_path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.rename-at"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, (new_descriptor).handle() as i32, ptr1.cast_mut(), len1, ptr2); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr2.add(1).cast::()); + + ErrorCode::_lift(l4 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Create a symbolic link (also known as a "symlink"). + /// + /// If `old-path` starts with `/`, the function fails with + /// `error-code::not-permitted`. + /// + /// Note: This is similar to `symlinkat` in POSIX. + pub fn symlink_at(&self,old_path: &str,new_path: &str,) -> Result<(),ErrorCode>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = old_path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec1 = new_path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.symlink-at"] + 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, ptr1.cast_mut(), len1, ptr2); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr2.add(1).cast::()); + + ErrorCode::_lift(l4 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Unlink a filesystem object that is not a directory. + /// + /// Return `error-code::is-directory` if the path refers to a directory. + /// Note: This is similar to `unlinkat(fd, path, 0)` in POSIX. + pub fn unlink_file_at(&self,path: &str,) -> Result<(),ErrorCode>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = path; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.unlink-file-at"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + + ErrorCode::_lift(l3 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Test whether two descriptors refer to the same filesystem object. + /// + /// In POSIX, this corresponds to testing whether the two descriptors have the + /// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. + /// wasi-filesystem does not expose device and inode numbers, so this function + /// may be used instead. + pub fn is_same_object(&self,other: &Descriptor,) -> bool{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.is-same-object"] + fn wit_import(_: i32, _: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32, (other).handle() as i32); + _rt::bool_lift(ret as u8) + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return a hash of the metadata associated with a filesystem object referred + /// to by a descriptor. + /// + /// This returns a hash of the last-modification timestamp and file size, and + /// may also include the inode number, device number, birth timestamp, and + /// other metadata fields that may change when the file is modified or + /// replaced. It may also include a secret value chosen by the + /// implementation and not otherwise exposed. + /// + /// Implementations are encourated to provide the following properties: + /// + /// - If the file is not modified or replaced, the computed hash value should + /// usually not change. + /// - If the object is modified or replaced, the computed hash value should + /// usually change. + /// - The inputs to the hash should not be easily computable from the + /// computed hash. + /// + /// However, none of these is required. + pub fn metadata_hash(&self,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.metadata-hash"] + 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 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + let l3 = *ptr0.add(16).cast::(); + + MetadataHashValue{ + lower: l2 as u64, + upper: l3 as u64, + } + }; + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr0.add(8).cast::()); + + ErrorCode::_lift(l4 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Descriptor { + #[allow(unused_unsafe, clippy::all)] + /// Return a hash of the metadata associated with a filesystem object referred + /// to by a directory descriptor and a relative path. + /// + /// This performs the same hash computation as `metadata-hash`. + pub fn metadata_hash_at(&self,path_flags: PathFlags,path: &str,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 24]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let flags0 = path_flags; + let vec1 = path; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]descriptor.metadata-hash-at"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1.cast_mut(), len1, ptr2); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = { + let l4 = *ptr2.add(8).cast::(); + let l5 = *ptr2.add(16).cast::(); + + MetadataHashValue{ + lower: l4 as u64, + upper: l5 as u64, + } + }; + Ok(e) + } + 1 => { + let e = { + let l6 = i32::from(*ptr2.add(8).cast::()); + + ErrorCode::_lift(l6 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl DirectoryEntryStream { + #[allow(unused_unsafe, clippy::all)] + /// Read a single directory entry from a `directory-entry-stream`. + pub fn read_directory_entry(&self,) -> Result,ErrorCode>{ + 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 = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "[method]directory-entry-stream.read-directory-entry"] + 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 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + + match l2 { + 0 => None, + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let l4 = *ptr0.add(12).cast::<*mut u8>(); + let l5 = *ptr0.add(16).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + DirectoryEntry{ + type_: DescriptorType::_lift(l3 as u8), + name: _rt::string_lift(bytes6), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Ok(e) + } + 1 => { + let e = { + let l7 = i32::from(*ptr0.add(4).cast::()); + + ErrorCode::_lift(l7 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + #[allow(unused_unsafe, clippy::all)] + /// Attempts to extract a filesystem-related `error-code` from the stream + /// `error` provided. + /// + /// Stream operations which return `stream-error::last-operation-failed` + /// have a payload with more information about the operation that failed. + /// This payload can be passed through to this function to see if there's + /// filesystem-related information about the error to return. + /// + /// Note that this function is fallible because not all stream-related + /// errors are filesystem-related errors. + pub fn filesystem_error_code(err: &Error,) -> Option{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] + extern "C" { + #[link_name = "filesystem-error-code"] + fn wit_import(_: i32, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, ){ unreachable!() } + wit_import((err).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(1).cast::()); + + ErrorCode::_lift(l2 as u8) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + + } + + #[allow(dead_code, clippy::all)] + pub mod preopens { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Descriptor = super::super::super::wasi::filesystem::types::Descriptor; + #[allow(unused_unsafe, clippy::all)] + /// Return the set of preopened directories, and their path. + pub fn get_directories() -> _rt::Vec::<(Descriptor,_rt::String,)>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:filesystem/preopens@0.2.0")] + extern "C" { + #[link_name = "get-directories"] + 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::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let base7 = l1; + let len7 = l2; + let mut result7 = _rt::Vec::with_capacity(len7); + for i in 0..len7 { + let base = base7.add(i * 12); + let e7 = { + let l3 = *base.add(0).cast::(); + let l4 = *base.add(4).cast::<*mut u8>(); + let l5 = *base.add(8).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + (super::super::super::wasi::filesystem::types::Descriptor::from_handle(l3 as u32), _rt::string_lift(bytes6)) + }; + result7.push(e7); + } + _rt::cabi_dealloc(base7, len7 * 12, 4); + result7 + } + } + + } + + } + #[allow(dead_code)] + pub mod http { + #[allow(dead_code, clippy::all)] + pub mod types { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; + pub type InputStream = super::super::super::wasi::io::streams::InputStream; + pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; + pub type IoError = super::super::super::wasi::io::error::Error; + /// Hermes doews not support `poll` + /// use wasi:io/poll@0.2.0.{pollable}; + /// This type corresponds to HTTP standard Methods. + #[derive(Clone)] + pub enum Method { + Get, + Head, + Post, + Put, + Delete, + Connect, + Options, + Trace, + Patch, + Other(_rt::String), + } + impl ::core::fmt::Debug for Method { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Method::Get => { + f.debug_tuple("Method::Get").finish() + } + Method::Head => { + f.debug_tuple("Method::Head").finish() + } + Method::Post => { + f.debug_tuple("Method::Post").finish() + } + Method::Put => { + f.debug_tuple("Method::Put").finish() + } + Method::Delete => { + f.debug_tuple("Method::Delete").finish() + } + Method::Connect => { + f.debug_tuple("Method::Connect").finish() + } + Method::Options => { + f.debug_tuple("Method::Options").finish() + } + Method::Trace => { + f.debug_tuple("Method::Trace").finish() + } + Method::Patch => { + f.debug_tuple("Method::Patch").finish() + } + Method::Other(e) => { + f.debug_tuple("Method::Other").field(e).finish() + } + } + } + } + /// This type corresponds to HTTP standard Related Schemes. + #[derive(Clone)] + pub enum Scheme { + Http, + Https, + Other(_rt::String), + } + impl ::core::fmt::Debug for Scheme { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + Scheme::Http => { + f.debug_tuple("Scheme::Http").finish() + } + Scheme::Https => { + f.debug_tuple("Scheme::Https").finish() + } + Scheme::Other(e) => { + f.debug_tuple("Scheme::Other").field(e).finish() + } + } + } + } + /// Defines the case payload type for `DNS-error` above: + #[derive(Clone)] + pub struct DnsErrorPayload { + pub rcode: Option<_rt::String>, + pub info_code: Option, + } + impl ::core::fmt::Debug for DnsErrorPayload { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("DnsErrorPayload").field("rcode", &self.rcode).field("info-code", &self.info_code).finish() + } + } + /// Defines the case payload type for `TLS-alert-received` above: + #[derive(Clone)] + pub struct TlsAlertReceivedPayload { + pub alert_id: Option, + pub alert_message: Option<_rt::String>, + } + impl ::core::fmt::Debug for TlsAlertReceivedPayload { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("TlsAlertReceivedPayload").field("alert-id", &self.alert_id).field("alert-message", &self.alert_message).finish() + } + } + /// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: + #[derive(Clone)] + pub struct FieldSizePayload { + pub field_name: Option<_rt::String>, + pub field_size: Option, + } + impl ::core::fmt::Debug for FieldSizePayload { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("FieldSizePayload").field("field-name", &self.field_name).field("field-size", &self.field_size).finish() + } + } + /// These cases are inspired by the IANA HTTP Proxy Error Types: + /// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types + #[derive(Clone)] + pub enum ErrorCode { + DnsTimeout, + DnsError(DnsErrorPayload), + DestinationNotFound, + DestinationUnavailable, + DestinationIpProhibited, + DestinationIpUnroutable, + ConnectionRefused, + ConnectionTerminated, + ConnectionTimeout, + ConnectionReadTimeout, + ConnectionWriteTimeout, + ConnectionLimitReached, + TlsProtocolError, + TlsCertificateError, + TlsAlertReceived(TlsAlertReceivedPayload), + HttpRequestDenied, + HttpRequestLengthRequired, + HttpRequestBodySize(Option), + HttpRequestMethodInvalid, + HttpRequestUriInvalid, + HttpRequestUriTooLong, + HttpRequestHeaderSectionSize(Option), + HttpRequestHeaderSize(Option), + HttpRequestTrailerSectionSize(Option), + HttpRequestTrailerSize(FieldSizePayload), + HttpResponseIncomplete, + HttpResponseHeaderSectionSize(Option), + HttpResponseHeaderSize(FieldSizePayload), + HttpResponseBodySize(Option), + HttpResponseTrailerSectionSize(Option), + HttpResponseTrailerSize(FieldSizePayload), + HttpResponseTransferCoding(Option<_rt::String>), + HttpResponseContentCoding(Option<_rt::String>), + HttpResponseTimeout, + HttpUpgradeFailed, + HttpProtocolError, + LoopDetected, + ConfigurationError, + /// This is a catch-all error for anything that doesn't fit cleanly into a + /// more specific case. It also includes an optional string for an + /// unstructured description of the error. Users should not depend on the + /// string for diagnosing errors, as it's not required to be consistent + /// between implementations. + InternalError(Option<_rt::String>), + } + impl ::core::fmt::Debug for ErrorCode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + ErrorCode::DnsTimeout => { + f.debug_tuple("ErrorCode::DnsTimeout").finish() + } + ErrorCode::DnsError(e) => { + f.debug_tuple("ErrorCode::DnsError").field(e).finish() + } + ErrorCode::DestinationNotFound => { + f.debug_tuple("ErrorCode::DestinationNotFound").finish() + } + ErrorCode::DestinationUnavailable => { + f.debug_tuple("ErrorCode::DestinationUnavailable").finish() + } + ErrorCode::DestinationIpProhibited => { + f.debug_tuple("ErrorCode::DestinationIpProhibited").finish() + } + ErrorCode::DestinationIpUnroutable => { + f.debug_tuple("ErrorCode::DestinationIpUnroutable").finish() + } + ErrorCode::ConnectionRefused => { + f.debug_tuple("ErrorCode::ConnectionRefused").finish() + } + ErrorCode::ConnectionTerminated => { + f.debug_tuple("ErrorCode::ConnectionTerminated").finish() + } + ErrorCode::ConnectionTimeout => { + f.debug_tuple("ErrorCode::ConnectionTimeout").finish() + } + ErrorCode::ConnectionReadTimeout => { + f.debug_tuple("ErrorCode::ConnectionReadTimeout").finish() + } + ErrorCode::ConnectionWriteTimeout => { + f.debug_tuple("ErrorCode::ConnectionWriteTimeout").finish() + } + ErrorCode::ConnectionLimitReached => { + f.debug_tuple("ErrorCode::ConnectionLimitReached").finish() + } + ErrorCode::TlsProtocolError => { + f.debug_tuple("ErrorCode::TlsProtocolError").finish() + } + ErrorCode::TlsCertificateError => { + f.debug_tuple("ErrorCode::TlsCertificateError").finish() + } + ErrorCode::TlsAlertReceived(e) => { + f.debug_tuple("ErrorCode::TlsAlertReceived").field(e).finish() + } + ErrorCode::HttpRequestDenied => { + f.debug_tuple("ErrorCode::HttpRequestDenied").finish() + } + ErrorCode::HttpRequestLengthRequired => { + f.debug_tuple("ErrorCode::HttpRequestLengthRequired").finish() + } + ErrorCode::HttpRequestBodySize(e) => { + f.debug_tuple("ErrorCode::HttpRequestBodySize").field(e).finish() + } + ErrorCode::HttpRequestMethodInvalid => { + f.debug_tuple("ErrorCode::HttpRequestMethodInvalid").finish() + } + ErrorCode::HttpRequestUriInvalid => { + f.debug_tuple("ErrorCode::HttpRequestUriInvalid").finish() + } + ErrorCode::HttpRequestUriTooLong => { + f.debug_tuple("ErrorCode::HttpRequestUriTooLong").finish() + } + ErrorCode::HttpRequestHeaderSectionSize(e) => { + f.debug_tuple("ErrorCode::HttpRequestHeaderSectionSize").field(e).finish() + } + ErrorCode::HttpRequestHeaderSize(e) => { + f.debug_tuple("ErrorCode::HttpRequestHeaderSize").field(e).finish() + } + ErrorCode::HttpRequestTrailerSectionSize(e) => { + f.debug_tuple("ErrorCode::HttpRequestTrailerSectionSize").field(e).finish() + } + ErrorCode::HttpRequestTrailerSize(e) => { + f.debug_tuple("ErrorCode::HttpRequestTrailerSize").field(e).finish() + } + ErrorCode::HttpResponseIncomplete => { + f.debug_tuple("ErrorCode::HttpResponseIncomplete").finish() + } + ErrorCode::HttpResponseHeaderSectionSize(e) => { + f.debug_tuple("ErrorCode::HttpResponseHeaderSectionSize").field(e).finish() + } + ErrorCode::HttpResponseHeaderSize(e) => { + f.debug_tuple("ErrorCode::HttpResponseHeaderSize").field(e).finish() + } + ErrorCode::HttpResponseBodySize(e) => { + f.debug_tuple("ErrorCode::HttpResponseBodySize").field(e).finish() + } + ErrorCode::HttpResponseTrailerSectionSize(e) => { + f.debug_tuple("ErrorCode::HttpResponseTrailerSectionSize").field(e).finish() + } + ErrorCode::HttpResponseTrailerSize(e) => { + f.debug_tuple("ErrorCode::HttpResponseTrailerSize").field(e).finish() + } + ErrorCode::HttpResponseTransferCoding(e) => { + f.debug_tuple("ErrorCode::HttpResponseTransferCoding").field(e).finish() + } + ErrorCode::HttpResponseContentCoding(e) => { + f.debug_tuple("ErrorCode::HttpResponseContentCoding").field(e).finish() + } + ErrorCode::HttpResponseTimeout => { + f.debug_tuple("ErrorCode::HttpResponseTimeout").finish() + } + ErrorCode::HttpUpgradeFailed => { + f.debug_tuple("ErrorCode::HttpUpgradeFailed").finish() + } + ErrorCode::HttpProtocolError => { + f.debug_tuple("ErrorCode::HttpProtocolError").finish() + } + ErrorCode::LoopDetected => { + f.debug_tuple("ErrorCode::LoopDetected").finish() + } + ErrorCode::ConfigurationError => { + f.debug_tuple("ErrorCode::ConfigurationError").finish() + } + ErrorCode::InternalError(e) => { + f.debug_tuple("ErrorCode::InternalError").field(e).finish() + } + } + } + } + impl ::core::fmt::Display for ErrorCode { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } + + impl std::error::Error for ErrorCode {} + /// This type enumerates the different kinds of errors that may occur when + /// setting or appending to a `fields` resource. + #[derive(Clone, Copy)] + pub enum HeaderError { + /// This error indicates that a `field-key` or `field-value` was + /// syntactically invalid when used with an operation that sets headers in a + /// `fields`. + InvalidSyntax, + /// This error indicates that a forbidden `field-key` was used when trying + /// to set a header in a `fields`. + Forbidden, + /// This error indicates that the operation on the `fields` was not + /// permitted because the fields are immutable. + Immutable, + } + impl ::core::fmt::Debug for HeaderError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + HeaderError::InvalidSyntax => { + f.debug_tuple("HeaderError::InvalidSyntax").finish() + } + HeaderError::Forbidden => { + f.debug_tuple("HeaderError::Forbidden").finish() + } + HeaderError::Immutable => { + f.debug_tuple("HeaderError::Immutable").finish() + } + } + } + } + impl ::core::fmt::Display for HeaderError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } + + impl std::error::Error for HeaderError {} + /// Field keys are always strings. + pub type FieldKey = _rt::String; + /// Field values should always be ASCII strings. However, in + /// reality, HTTP implementations often have to interpret malformed values, + /// so they are provided as a list of bytes. + pub type FieldValue = _rt::Vec::; + /// This following block defines the `fields` resource which corresponds to + /// HTTP standard Fields. Fields are a common representation used for both + /// Headers and Trailers. + /// + /// A `fields` may be mutable or immutable. A `fields` created using the + /// constructor, `from-list`, or `clone` will be mutable, but a `fields` + /// resource given by other means (including, but not limited to, + /// `incoming-request.headers`, `outgoing-request.headers`) might be be + /// immutable. In an immutable fields, the `set`, `append`, and `delete` + /// operations will fail with `header-error.immutable`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Fields{ + handle: _rt::Resource, + } + + impl Fields{ + #[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 Fields{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]fields"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Headers is an alias for Fields. + pub type Headers = Fields; + /// Trailers is an alias for Fields. + pub type Trailers = Fields; + /// Represents an incoming HTTP Request. + + #[derive(Debug)] + #[repr(transparent)] + pub struct IncomingRequest{ + handle: _rt::Resource, + } + + impl IncomingRequest{ + #[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 IncomingRequest{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]incoming-request"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents an outgoing HTTP Request. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutgoingRequest{ + handle: _rt::Resource, + } + + impl OutgoingRequest{ + #[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 OutgoingRequest{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]outgoing-request"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Parameters for making an HTTP Request. Each of these parameters is + /// currently an optional timeout applicable to the transport layer of the + /// HTTP protocol. + /// + /// These timeouts are separate from any the user may use to bound a + /// blocking call to `wasi:io/poll.poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct RequestOptions{ + handle: _rt::Resource, + } + + impl RequestOptions{ + #[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 RequestOptions{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]request-options"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents the ability to send an HTTP Response. + /// + /// This resource is used by the `wasi:http/incoming-handler` interface to + /// allow a Response to be sent corresponding to the Request provided as the + /// other argument to `incoming-handler.handle`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct ResponseOutparam{ + handle: _rt::Resource, + } + + impl ResponseOutparam{ + #[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 ResponseOutparam{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]response-outparam"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// This type corresponds to the HTTP standard Status Code. + pub type StatusCode = u16; + /// Represents an incoming HTTP Response. + + #[derive(Debug)] + #[repr(transparent)] + pub struct IncomingResponse{ + handle: _rt::Resource, + } + + impl IncomingResponse{ + #[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 IncomingResponse{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]incoming-response"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents an incoming HTTP Request or Response's Body. + /// + /// A body has both its contents - a stream of bytes - and a (possibly + /// empty) set of trailers, indicating that the full contents of the + /// body have been received. This resource represents the contents as + /// an `input-stream` and the delivery of trailers as a `future-trailers`, + /// and ensures that the user of this interface may only be consuming either + /// the body contents or waiting on trailers at any given time. + + #[derive(Debug)] + #[repr(transparent)] + pub struct IncomingBody{ + handle: _rt::Resource, + } + + impl IncomingBody{ + #[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 IncomingBody{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]incoming-body"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents a future which may eventaully return trailers, or an error. + /// + /// In the case that the incoming HTTP Request or Response did not have any + /// trailers, this future will resolve to the empty set of trailers once the + /// complete Request or Response body has been received. + + #[derive(Debug)] + #[repr(transparent)] + pub struct FutureTrailers{ + handle: _rt::Resource, + } + + impl FutureTrailers{ + #[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 FutureTrailers{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]future-trailers"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents an outgoing HTTP Response. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutgoingResponse{ + handle: _rt::Resource, + } + + impl OutgoingResponse{ + #[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 OutgoingResponse{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]outgoing-response"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents an outgoing HTTP Request or Response's Body. + /// + /// A body has both its contents - a stream of bytes - and a (possibly + /// empty) set of trailers, inducating the full contents of the body + /// have been sent. This resource represents the contents as an + /// `output-stream` child resource, and the completion of the body (with + /// optional trailers) with a static function that consumes the + /// `outgoing-body` resource, and ensures that the user of this interface + /// may not write to the body contents after the body has been finished. + /// + /// If the user code drops this resource, as opposed to calling the static + /// method `finish`, the implementation should treat the body as incomplete, + /// and that an error has occured. The implementation should propogate this + /// error to the HTTP protocol by whatever means it has available, + /// including: corrupting the body on the wire, aborting the associated + /// Request, or sending a late status code for the Response. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutgoingBody{ + handle: _rt::Resource, + } + + impl OutgoingBody{ + #[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 OutgoingBody{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]outgoing-body"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// Represents a future which may eventaully return an incoming HTTP + /// Response, or an error. + /// + /// This resource is returned by the `wasi:http/outgoing-handler` interface to + /// provide the HTTP Response corresponding to the sent Request. + + #[derive(Debug)] + #[repr(transparent)] + pub struct FutureIncomingResponse{ + handle: _rt::Resource, + } + + impl FutureIncomingResponse{ + #[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 FutureIncomingResponse{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]future-incoming-response"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + #[allow(unused_unsafe, clippy::all)] + /// Attempts to extract a http-related `error` from the wasi:io `error` + /// provided. + /// + /// Stream operations which return + /// `wasi:io/stream/stream-error::last-operation-failed` have a payload of + /// type `wasi:io/error/error` with more information about the operation + /// that failed. This payload can be passed through to this function to see + /// if there's http-related information about the error to return. + /// + /// Note that this function is fallible because not all io-errors are + /// http-related errors. + pub fn http_error_code(err: &IoError,) -> Option{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 40]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "http-error-code"] + fn wit_import(_: i32, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, ){ unreachable!() } + wit_import((err).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::()); + let v64 = match l2 { + 0 => { + ErrorCode::DnsTimeout + } + 1 => { + let e64 = { + let l3 = i32::from(*ptr0.add(16).cast::()); + let l7 = i32::from(*ptr0.add(28).cast::()); + + DnsErrorPayload{ + rcode: match l3 { + 0 => None, + 1 => { + let e = { + let l4 = *ptr0.add(20).cast::<*mut u8>(); + let l5 = *ptr0.add(24).cast::(); + let len6 = l5; + let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); + + _rt::string_lift(bytes6) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + info_code: match l7 { + 0 => None, + 1 => { + let e = { + let l8 = i32::from(*ptr0.add(30).cast::()); + + l8 as u16 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::DnsError(e64) + } + 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 e64 = { + let l9 = i32::from(*ptr0.add(16).cast::()); + let l11 = i32::from(*ptr0.add(20).cast::()); + + TlsAlertReceivedPayload{ + alert_id: match l9 { + 0 => None, + 1 => { + let e = { + let l10 = i32::from(*ptr0.add(17).cast::()); + + l10 as u8 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + alert_message: match l11 { + 0 => None, + 1 => { + let e = { + let l12 = *ptr0.add(24).cast::<*mut u8>(); + let l13 = *ptr0.add(28).cast::(); + let len14 = l13; + let bytes14 = _rt::Vec::from_raw_parts(l12.cast(), len14, len14); + + _rt::string_lift(bytes14) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::TlsAlertReceived(e64) + } + 15 => { + ErrorCode::HttpRequestDenied + } + 16 => { + ErrorCode::HttpRequestLengthRequired + } + 17 => { + let e64 = { + let l15 = i32::from(*ptr0.add(16).cast::()); + + match l15 { + 0 => None, + 1 => { + let e = { + let l16 = *ptr0.add(24).cast::(); + + l16 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestBodySize(e64) + } + 18 => { + ErrorCode::HttpRequestMethodInvalid + } + 19 => { + ErrorCode::HttpRequestUriInvalid + } + 20 => { + ErrorCode::HttpRequestUriTooLong + } + 21 => { + let e64 = { + let l17 = i32::from(*ptr0.add(16).cast::()); + + match l17 { + 0 => None, + 1 => { + let e = { + let l18 = *ptr0.add(20).cast::(); + + l18 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSectionSize(e64) + } + 22 => { + let e64 = { + let l19 = i32::from(*ptr0.add(16).cast::()); + + match l19 { + 0 => None, + 1 => { + let e = { + let l20 = i32::from(*ptr0.add(20).cast::()); + let l24 = i32::from(*ptr0.add(32).cast::()); + + FieldSizePayload{ + field_name: match l20 { + 0 => None, + 1 => { + let e = { + let l21 = *ptr0.add(24).cast::<*mut u8>(); + let l22 = *ptr0.add(28).cast::(); + let len23 = l22; + let bytes23 = _rt::Vec::from_raw_parts(l21.cast(), len23, len23); + + _rt::string_lift(bytes23) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l24 { + 0 => None, + 1 => { + let e = { + let l25 = *ptr0.add(36).cast::(); + + l25 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSize(e64) + } + 23 => { + let e64 = { + let l26 = i32::from(*ptr0.add(16).cast::()); + + match l26 { + 0 => None, + 1 => { + let e = { + let l27 = *ptr0.add(20).cast::(); + + l27 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestTrailerSectionSize(e64) + } + 24 => { + let e64 = { + let l28 = i32::from(*ptr0.add(16).cast::()); + let l32 = i32::from(*ptr0.add(28).cast::()); + + FieldSizePayload{ + field_name: match l28 { + 0 => None, + 1 => { + let e = { + let l29 = *ptr0.add(20).cast::<*mut u8>(); + let l30 = *ptr0.add(24).cast::(); + let len31 = l30; + let bytes31 = _rt::Vec::from_raw_parts(l29.cast(), len31, len31); + + _rt::string_lift(bytes31) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l32 { + 0 => None, + 1 => { + let e = { + let l33 = *ptr0.add(32).cast::(); + + l33 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpRequestTrailerSize(e64) + } + 25 => { + ErrorCode::HttpResponseIncomplete + } + 26 => { + let e64 = { + let l34 = i32::from(*ptr0.add(16).cast::()); + + match l34 { + 0 => None, + 1 => { + let e = { + let l35 = *ptr0.add(20).cast::(); + + l35 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseHeaderSectionSize(e64) + } + 27 => { + let e64 = { + let l36 = i32::from(*ptr0.add(16).cast::()); + let l40 = i32::from(*ptr0.add(28).cast::()); + + FieldSizePayload{ + field_name: match l36 { + 0 => None, + 1 => { + let e = { + let l37 = *ptr0.add(20).cast::<*mut u8>(); + let l38 = *ptr0.add(24).cast::(); + let len39 = l38; + let bytes39 = _rt::Vec::from_raw_parts(l37.cast(), len39, len39); + + _rt::string_lift(bytes39) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l40 { + 0 => None, + 1 => { + let e = { + let l41 = *ptr0.add(32).cast::(); + + l41 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseHeaderSize(e64) + } + 28 => { + let e64 = { + let l42 = i32::from(*ptr0.add(16).cast::()); + + match l42 { + 0 => None, + 1 => { + let e = { + let l43 = *ptr0.add(24).cast::(); + + l43 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseBodySize(e64) + } + 29 => { + let e64 = { + let l44 = i32::from(*ptr0.add(16).cast::()); + + match l44 { + 0 => None, + 1 => { + let e = { + let l45 = *ptr0.add(20).cast::(); + + l45 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTrailerSectionSize(e64) + } + 30 => { + let e64 = { + let l46 = i32::from(*ptr0.add(16).cast::()); + let l50 = i32::from(*ptr0.add(28).cast::()); + + FieldSizePayload{ + field_name: match l46 { + 0 => None, + 1 => { + let e = { + let l47 = *ptr0.add(20).cast::<*mut u8>(); + let l48 = *ptr0.add(24).cast::(); + let len49 = l48; + let bytes49 = _rt::Vec::from_raw_parts(l47.cast(), len49, len49); + + _rt::string_lift(bytes49) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l50 { + 0 => None, + 1 => { + let e = { + let l51 = *ptr0.add(32).cast::(); + + l51 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseTrailerSize(e64) + } + 31 => { + let e64 = { + let l52 = i32::from(*ptr0.add(16).cast::()); + + match l52 { + 0 => None, + 1 => { + let e = { + let l53 = *ptr0.add(20).cast::<*mut u8>(); + let l54 = *ptr0.add(24).cast::(); + let len55 = l54; + let bytes55 = _rt::Vec::from_raw_parts(l53.cast(), len55, len55); + + _rt::string_lift(bytes55) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTransferCoding(e64) + } + 32 => { + let e64 = { + let l56 = i32::from(*ptr0.add(16).cast::()); + + match l56 { + 0 => None, + 1 => { + let e = { + let l57 = *ptr0.add(20).cast::<*mut u8>(); + let l58 = *ptr0.add(24).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::HttpResponseContentCoding(e64) + } + 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 e64 = { + let l60 = i32::from(*ptr0.add(16).cast::()); + + match l60 { + 0 => None, + 1 => { + let e = { + let l61 = *ptr0.add(20).cast::<*mut u8>(); + let l62 = *ptr0.add(24).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::InternalError(e64) + } + }; + + v64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Construct an empty HTTP Fields. + /// + /// The resulting `fields` is mutable. + pub fn new() -> Self{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[constructor]fields"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32{ unreachable!() } + let ret = wit_import(); + Fields::from_handle(ret as u32) + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Construct an HTTP Fields. + /// + /// The resulting `fields` is mutable. + /// + /// The list represents each key-value pair in the Fields. Keys + /// which have multiple values are represented by multiple entries in this + /// list with the same key. + /// + /// The tuple is a pair of the field key, represented as a string, and + /// Value, represented as a list of bytes. In a valid Fields, all keys + /// and values are valid UTF-8 strings. However, values are not always + /// well-formed, so they are represented as a raw list of bytes. + /// + /// An error result will be returned if any header or value was + /// syntactically invalid, or if a header was forbidden. + pub fn from_list(entries: &[(FieldKey,FieldValue,)],) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec3 = entries; + let len3 = vec3.len(); + let layout3 = _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 16, 4); + let result3 = if layout3.size() != 0 { + let ptr = _rt::alloc::alloc(layout3).cast::(); + if ptr.is_null() + { + _rt::alloc::handle_alloc_error(layout3); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec3.into_iter().enumerate() { + let base = result3.add(i * 16); + { + let (t0_0, t0_1, ) = e; + let vec1 = t0_0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + *base.add(4).cast::() = len1; + *base.add(0).cast::<*mut u8>() = ptr1.cast_mut(); + let vec2 = t0_1; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + *base.add(12).cast::() = len2; + *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); + } + } + let ptr4 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[static]fields.from-list"] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(result3, len3, ptr4); + let l5 = i32::from(*ptr4.add(0).cast::()); + if layout3.size() != 0 { + _rt::alloc::dealloc(result3.cast(), layout3); + } + match l5 { + 0 => { + let e = { + let l6 = *ptr4.add(4).cast::(); + + Fields::from_handle(l6 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l7 = i32::from(*ptr4.add(4).cast::()); + let v8 = match l7 { + 0 => { + HeaderError::InvalidSyntax + } + 1 => { + HeaderError::Forbidden + } + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + HeaderError::Immutable + } + }; + + v8 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Get all of the values corresponding to a key. If the key is not present + /// in this `fields`, an empty list is returned. However, if the key is + /// present but empty, this is represented by a list with one or more + /// empty field-values present. + pub fn get(&self,name: &FieldKey,) -> _rt::Vec::{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.get"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = *ptr1.add(0).cast::<*mut u8>(); + let l3 = *ptr1.add(4).cast::(); + let base7 = l2; + let len7 = l3; + let mut result7 = _rt::Vec::with_capacity(len7); + for i in 0..len7 { + let base = base7.add(i * 8); + let e7 = { + let l4 = *base.add(0).cast::<*mut u8>(); + let l5 = *base.add(4).cast::(); + let len6 = l5; + + _rt::Vec::from_raw_parts(l4.cast(), len6, len6) + }; + result7.push(e7); + } + _rt::cabi_dealloc(base7, len7 * 8, 4); + result7 + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Returns `true` when the key is present in this `fields`. If the key is + /// syntactically invalid, `false` is returned. + pub fn has(&self,name: &FieldKey,) -> bool{ + unsafe { + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.has"] + fn wit_import(_: i32, _: *mut u8, _: usize, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32, ptr0.cast_mut(), len0); + _rt::bool_lift(ret as u8) + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Set all of the values for a key. Clears any existing values for that + /// key, if they have been set. + /// + /// Fails with `header-error.immutable` if the `fields` are immutable. + pub fn set(&self,name: &FieldKey,value: &[FieldValue],) -> Result<(),HeaderError>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec2 = value; + let len2 = vec2.len(); + let layout2 = _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); + let result2 = if layout2.size() != 0 { + let ptr = _rt::alloc::alloc(layout2).cast::(); + if ptr.is_null() + { + _rt::alloc::handle_alloc_error(layout2); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec2.into_iter().enumerate() { + let base = result2.add(i * 8); + { + let vec1 = e; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + *base.add(4).cast::() = len1; + *base.add(0).cast::<*mut u8>() = ptr1.cast_mut(); + } + } + let ptr3 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.set"] + 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, result2, len2, ptr3); + let l4 = i32::from(*ptr3.add(0).cast::()); + if layout2.size() != 0 { + _rt::alloc::dealloc(result2.cast(), layout2); + } + match l4 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr3.add(1).cast::()); + let v6 = match l5 { + 0 => { + HeaderError::InvalidSyntax + } + 1 => { + HeaderError::Forbidden + } + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + HeaderError::Immutable + } + }; + + v6 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Delete all values for a key. Does nothing if no values for the key + /// exist. + /// + /// Fails with `header-error.immutable` if the `fields` are immutable. + pub fn delete(&self,name: &FieldKey,) -> Result<(),HeaderError>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.delete"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(1).cast::()); + let v4 = match l3 { + 0 => { + HeaderError::InvalidSyntax + } + 1 => { + HeaderError::Forbidden + } + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + HeaderError::Immutable + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Append a value for a key. Does not change or delete any existing + /// values for that key. + /// + /// Fails with `header-error.immutable` if the `fields` are immutable. + pub fn append(&self,name: &FieldKey,value: &FieldValue,) -> Result<(),HeaderError>{ + unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let vec0 = name; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let vec1 = value; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let ptr2 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.append"] + 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, ptr1.cast_mut(), len1, ptr2); + let l3 = i32::from(*ptr2.add(0).cast::()); + match l3 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr2.add(1).cast::()); + let v5 = match l4 { + 0 => { + HeaderError::InvalidSyntax + } + 1 => { + HeaderError::Forbidden + } + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + HeaderError::Immutable + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Retrieve the full set of keys and values in the Fields. Like the + /// constructor, the list represents each key-value pair. + /// + /// The outer list represents each key-value pair in the Fields. Keys + /// which have multiple values are represented by multiple entries in this + /// list with the same key. + pub fn entries(&self,) -> _rt::Vec::<(FieldKey,FieldValue,)>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.entries"] + 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 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let base9 = l1; + let len9 = l2; + let mut result9 = _rt::Vec::with_capacity(len9); + for i in 0..len9 { + let base = base9.add(i * 16); + let e9 = { + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + let l6 = *base.add(8).cast::<*mut u8>(); + let l7 = *base.add(12).cast::(); + let len8 = l7; + + (_rt::string_lift(bytes5), _rt::Vec::from_raw_parts(l6.cast(), len8, len8)) + }; + result9.push(e9); + } + _rt::cabi_dealloc(base9, len9 * 16, 4); + result9 + } + } + } + impl Fields { + #[allow(unused_unsafe, clippy::all)] + /// Make a deep copy of the Fields. Equivelant in behavior to calling the + /// `fields` constructor on the return value of `entries`. The resulting + /// `fields` is mutable. + pub fn clone(&self,) -> Fields{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]fields.clone"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Returns the method of the incoming request. + pub fn method(&self,) -> Method{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.method"] + 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::()); + let v5 = match l1 { + 0 => { + Method::Get + } + 1 => { + Method::Head + } + 2 => { + Method::Post + } + 3 => { + Method::Put + } + 4 => { + Method::Delete + } + 5 => { + Method::Connect + } + 6 => { + Method::Options + } + 7 => { + Method::Trace + } + 8 => { + Method::Patch + } + n => { + debug_assert_eq!(n, 9, "invalid enum discriminant"); + let e5 = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Method::Other(e5) + } + }; + v5 + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Returns the path with query parameters from the request, as a string. + pub fn path_with_query(&self,) -> Option<_rt::String>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.path-with-query"] + 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 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Returns the protocol scheme from the request. + pub fn scheme(&self,) -> Option{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.scheme"] + 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::()); + let v6 = match l2 { + 0 => { + Scheme::Http + } + 1 => { + Scheme::Https + } + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + let e6 = { + let l3 = *ptr0.add(8).cast::<*mut u8>(); + let l4 = *ptr0.add(12).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Scheme::Other(e6) + } + }; + + v6 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Returns the authority from the request, if it was present. + pub fn authority(&self,) -> Option<_rt::String>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.authority"] + 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 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the `headers` associated with the request. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// The `headers` returned are a child resource: it must be dropped before + /// the parent `incoming-request` is dropped. Dropping this + /// `incoming-request` before all children are dropped will trap. + pub fn headers(&self,) -> Headers{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.headers"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) + } + } + } + impl IncomingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Gives the `incoming-body` associated with this request. Will only + /// return success at most once, and subsequent calls will return error. + pub fn consume(&self,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-request.consume"] + 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 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + IncomingBody::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Construct a new `outgoing-request` with a default `method` of `GET`, and + /// `none` values for `path-with-query`, `scheme`, and `authority`. + /// + /// * `headers` is the HTTP Headers for the Request. + /// + /// It is possible to construct, or manipulate with the accessor functions + /// below, an `outgoing-request` with an invalid combination of `scheme` + /// and `authority`, or `headers` which are not permitted to be sent. + /// It is the obligation of the `outgoing-handler.handle` implementation + /// to reject invalid constructions of `outgoing-request`. + pub fn new(headers: Headers,) -> Self{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[constructor]outgoing-request"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import((&headers).take_handle() as i32); + OutgoingRequest::from_handle(ret as u32) + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Returns the resource corresponding to the outgoing Body for this + /// Request. + /// + /// Returns success on the first call: the `outgoing-body` resource for + /// this `outgoing-request` can be retrieved at most once. Subsequent + /// calls will return error. + pub fn body(&self,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.body"] + 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 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + OutgoingBody::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the Method for the Request. + pub fn method(&self,) -> Method{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.method"] + 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::()); + let v5 = match l1 { + 0 => { + Method::Get + } + 1 => { + Method::Head + } + 2 => { + Method::Post + } + 3 => { + Method::Put + } + 4 => { + Method::Delete + } + 5 => { + Method::Connect + } + 6 => { + Method::Options + } + 7 => { + Method::Trace + } + 8 => { + Method::Patch + } + n => { + debug_assert_eq!(n, 9, "invalid enum discriminant"); + let e5 = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Method::Other(e5) + } + }; + v5 + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Set the Method for the Request. Fails if the string present in a + /// `method.other` argument is not a syntactically valid method. + pub fn set_method(&self,method: &Method,) -> Result<(),()>{ + unsafe { + let (result1_0,result1_1,result1_2,) = match method { + Method::Get=> { + (0i32, ::core::ptr::null_mut(), 0usize) + } + Method::Head=> { + (1i32, ::core::ptr::null_mut(), 0usize) + } + Method::Post=> { + (2i32, ::core::ptr::null_mut(), 0usize) + } + Method::Put=> { + (3i32, ::core::ptr::null_mut(), 0usize) + } + Method::Delete=> { + (4i32, ::core::ptr::null_mut(), 0usize) + } + Method::Connect=> { + (5i32, ::core::ptr::null_mut(), 0usize) + } + Method::Options=> { + (6i32, ::core::ptr::null_mut(), 0usize) + } + Method::Trace=> { + (7i32, ::core::ptr::null_mut(), 0usize) + } + Method::Patch=> { + (8i32, ::core::ptr::null_mut(), 0usize) + } + Method::Other(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (9i32, ptr0.cast_mut(), len0) + }, + }; + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.set-method"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32, result1_0, result1_1, result1_2); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the combination of the HTTP Path and Query for the Request. + /// When `none`, this represents an empty Path and empty Query. + pub fn path_with_query(&self,) -> Option<_rt::String>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.path-with-query"] + 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 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Set the combination of the HTTP Path and Query for the Request. + /// When `none`, this represents an empty Path and empty Query. Fails is the + /// string given is not a syntactically valid path and query uri component. + pub fn set_path_with_query(&self,path_with_query: Option<&str>,) -> Result<(),()>{ + unsafe { + let (result1_0,result1_1,result1_2,) = match path_with_query { + Some(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (1i32, ptr0.cast_mut(), len0) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.set-path-with-query"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32, result1_0, result1_1, result1_2); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the HTTP Related Scheme for the Request. When `none`, the + /// implementation may choose an appropriate default scheme. + pub fn scheme(&self,) -> Option{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.scheme"] + 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::()); + let v6 = match l2 { + 0 => { + Scheme::Http + } + 1 => { + Scheme::Https + } + n => { + debug_assert_eq!(n, 2, "invalid enum discriminant"); + let e6 = { + let l3 = *ptr0.add(8).cast::<*mut u8>(); + let l4 = *ptr0.add(12).cast::(); + let len5 = l4; + let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); + + _rt::string_lift(bytes5) + }; + Scheme::Other(e6) + } + }; + + v6 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Set the HTTP Related Scheme for the Request. When `none`, the + /// implementation may choose an appropriate default scheme. Fails if the + /// string given is not a syntactically valid uri scheme. + pub fn set_scheme(&self,scheme: Option<&Scheme>,) -> Result<(),()>{ + unsafe { + let (result2_0,result2_1,result2_2,result2_3,) = match scheme { + Some(e) => { + let (result1_0,result1_1,result1_2,) = match e { + Scheme::Http=> { + (0i32, ::core::ptr::null_mut(), 0usize) + } + Scheme::Https=> { + (1i32, ::core::ptr::null_mut(), 0usize) + } + Scheme::Other(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (2i32, ptr0.cast_mut(), len0) + }, + }; + + (1i32, result1_0, result1_1, result1_2) + }, + None => { + (0i32, 0i32, ::core::ptr::null_mut(), 0usize) + }, + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.set-scheme"] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, _: usize, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32, result2_0, result2_1, result2_2, result2_3); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the HTTP Authority for the Request. A value of `none` may be used + /// with Related Schemes which do not require an Authority. The HTTP and + /// HTTPS schemes always require an authority. + pub fn authority(&self,) -> Option<_rt::String>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.authority"] + 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 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Set the HTTP Authority for the Request. A value of `none` may be used + /// with Related Schemes which do not require an Authority. The HTTP and + /// HTTPS schemes always require an authority. Fails if the string given is + /// not a syntactically valid uri authority. + pub fn set_authority(&self,authority: Option<&str>,) -> Result<(),()>{ + unsafe { + let (result1_0,result1_1,result1_2,) = match authority { + Some(e) => { + let vec0 = e; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + + (1i32, ptr0.cast_mut(), len0) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.set-authority"] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32, result1_0, result1_1, result1_2); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingRequest { + #[allow(unused_unsafe, clippy::all)] + /// Get the headers associated with the Request. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// This headers resource is a child: it must be dropped before the parent + /// `outgoing-request` is dropped, or its ownership is transfered to + /// another component by e.g. `outgoing-handler.handle`. + pub fn headers(&self,) -> Headers{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-request.headers"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// Construct a default `request-options` value. + pub fn new() -> Self{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[constructor]request-options"] + fn wit_import() -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i32{ unreachable!() } + let ret = wit_import(); + RequestOptions::from_handle(ret as u32) + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// The timeout for the initial connect to the HTTP Server. + pub fn connect_timeout(&self,) -> Option{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.connect-timeout"] + 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 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// Set the timeout for the initial connect to the HTTP Server. An error + /// return value indicates that this timeout is not supported. + pub fn set_connect_timeout(&self,duration: Option,) -> Result<(),()>{ + unsafe { + let (result0_0,result0_1,) = match duration { + Some(e) => (1i32, _rt::as_i64(e)), + None => { + (0i32, 0i64) + }, + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.set-connect-timeout"] + fn wit_import(_: i32, _: i32, _: i64, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32, result0_0, result0_1); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// The timeout for receiving the first byte of the Response body. + pub fn first_byte_timeout(&self,) -> Option{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.first-byte-timeout"] + 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 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// Set the timeout for receiving the first byte of the Response body. An + /// error return value indicates that this timeout is not supported. + pub fn set_first_byte_timeout(&self,duration: Option,) -> Result<(),()>{ + unsafe { + let (result0_0,result0_1,) = match duration { + Some(e) => (1i32, _rt::as_i64(e)), + None => { + (0i32, 0i64) + }, + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.set-first-byte-timeout"] + fn wit_import(_: i32, _: i32, _: i64, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32, result0_0, result0_1); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// The timeout for receiving subsequent chunks of bytes in the Response + /// body stream. + pub fn between_bytes_timeout(&self,) -> Option{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.between-bytes-timeout"] + 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 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl RequestOptions { + #[allow(unused_unsafe, clippy::all)] + /// Set the timeout for receiving subsequent chunks of bytes in the Response + /// body stream. An error return value indicates that this timeout is not + /// supported. + pub fn set_between_bytes_timeout(&self,duration: Option,) -> Result<(),()>{ + unsafe { + let (result0_0,result0_1,) = match duration { + Some(e) => (1i32, _rt::as_i64(e)), + None => { + (0i32, 0i64) + }, + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]request-options.set-between-bytes-timeout"] + fn wit_import(_: i32, _: i32, _: i64, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32, result0_0, result0_1); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl ResponseOutparam { + #[allow(unused_unsafe, clippy::all)] + /// Set the value of the `response-outparam` to either send a response, + /// or indicate an error. + /// + /// This method consumes the `response-outparam` to ensure that it is + /// called at most once. If it is never called, the implementation + /// will respond with an error. + /// + /// The user may provide an `error` to `response` to allow the + /// implementation determine how to respond with an HTTP error response. + pub fn set(param: ResponseOutparam,response: Result,){ + unsafe { + let (result38_0,result38_1,result38_2,result38_3,result38_4,result38_5,result38_6,result38_7,) = match &response { + Ok(e) => { (0i32, (e).take_handle() as i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) }, + Err(e) => { { + let (result37_0,result37_1,result37_2,result37_3,result37_4,result37_5,result37_6,) = match e { + ErrorCode::DnsTimeout=> { + (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::DnsError(e) => { + let DnsErrorPayload{ rcode:rcode0, info_code:info_code0, } = e; + let (result2_0,result2_1,result2_2,) = match rcode0 { + Some(e) => { + let vec1 = e; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + + (1i32, ptr1.cast_mut(), len1) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let (result3_0,result3_1,) = match info_code0 { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + }; + (1i32, result2_0, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result2_1); + t + }, result2_2 as *mut u8, result3_0 as *mut u8, result3_1 as usize, 0i32) + }, + ErrorCode::DestinationNotFound=> { + (2i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::DestinationUnavailable=> { + (3i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::DestinationIpProhibited=> { + (4i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::DestinationIpUnroutable=> { + (5i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::ConnectionRefused=> { + (6i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::ConnectionTerminated=> { + (7i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::ConnectionTimeout=> { + (8i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::ConnectionReadTimeout=> { + (9i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::ConnectionWriteTimeout=> { + (10i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::ConnectionLimitReached=> { + (11i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::TlsProtocolError=> { + (12i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::TlsCertificateError=> { + (13i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::TlsAlertReceived(e) => { + let TlsAlertReceivedPayload{ alert_id:alert_id4, alert_message:alert_message4, } = e; + let (result5_0,result5_1,) = match alert_id4 { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + };let (result7_0,result7_1,result7_2,) = match alert_message4 { + Some(e) => { + let vec6 = e; + let ptr6 = vec6.as_ptr().cast::(); + let len6 = vec6.len(); + + (1i32, ptr6.cast_mut(), len6) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + }; + (14i32, result5_0, ::core::mem::MaybeUninit::new(i64::from(result5_1) as u64), result7_0 as *mut u8, result7_1, result7_2, 0i32) + }, + ErrorCode::HttpRequestDenied=> { + (15i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::HttpRequestLengthRequired=> { + (16i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::HttpRequestBodySize(e) => { + let (result8_0,result8_1,) = match e { + Some(e) => (1i32, _rt::as_i64(e)), + None => { + (0i32, 0i64) + }, + }; + (17i32, result8_0, ::core::mem::MaybeUninit::new(result8_1 as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + }, + ErrorCode::HttpRequestMethodInvalid=> { + (18i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::HttpRequestUriInvalid=> { + (19i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::HttpRequestUriTooLong=> { + (20i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::HttpRequestHeaderSectionSize(e) => { + let (result9_0,result9_1,) = match e { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + }; + (21i32, result9_0, ::core::mem::MaybeUninit::new(i64::from(result9_1) as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + }, + ErrorCode::HttpRequestHeaderSize(e) => { + let (result14_0,result14_1,result14_2,result14_3,result14_4,result14_5,) = match e { + Some(e) => { + let FieldSizePayload{ field_name:field_name10, field_size:field_size10, } = e; + let (result12_0,result12_1,result12_2,) = match field_name10 { + Some(e) => { + let vec11 = e; + let ptr11 = vec11.as_ptr().cast::(); + let len11 = vec11.len(); + + (1i32, ptr11.cast_mut(), len11) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let (result13_0,result13_1,) = match field_size10 { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + }; + (1i32, result12_0, result12_1, result12_2, result13_0, result13_1) + }, + None => { + (0i32, 0i32, ::core::ptr::null_mut(), 0usize, 0i32, 0i32) + }, + }; + (22i32, result14_0, ::core::mem::MaybeUninit::new(i64::from(result14_1) as u64), result14_2, result14_3 as *mut u8, result14_4 as usize, result14_5) + }, + ErrorCode::HttpRequestTrailerSectionSize(e) => { + let (result15_0,result15_1,) = match e { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + }; + (23i32, result15_0, ::core::mem::MaybeUninit::new(i64::from(result15_1) as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + }, + ErrorCode::HttpRequestTrailerSize(e) => { + let FieldSizePayload{ field_name:field_name16, field_size:field_size16, } = e; + let (result18_0,result18_1,result18_2,) = match field_name16 { + Some(e) => { + let vec17 = e; + let ptr17 = vec17.as_ptr().cast::(); + let len17 = vec17.len(); + + (1i32, ptr17.cast_mut(), len17) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let (result19_0,result19_1,) = match field_size16 { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + }; + (24i32, result18_0, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result18_1); + t + }, result18_2 as *mut u8, result19_0 as *mut u8, result19_1 as usize, 0i32) + }, + ErrorCode::HttpResponseIncomplete=> { + (25i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::HttpResponseHeaderSectionSize(e) => { + let (result20_0,result20_1,) = match e { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + }; + (26i32, result20_0, ::core::mem::MaybeUninit::new(i64::from(result20_1) as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + }, + ErrorCode::HttpResponseHeaderSize(e) => { + let FieldSizePayload{ field_name:field_name21, field_size:field_size21, } = e; + let (result23_0,result23_1,result23_2,) = match field_name21 { + Some(e) => { + let vec22 = e; + let ptr22 = vec22.as_ptr().cast::(); + let len22 = vec22.len(); + + (1i32, ptr22.cast_mut(), len22) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let (result24_0,result24_1,) = match field_size21 { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + }; + (27i32, result23_0, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result23_1); + t + }, result23_2 as *mut u8, result24_0 as *mut u8, result24_1 as usize, 0i32) + }, + ErrorCode::HttpResponseBodySize(e) => { + let (result25_0,result25_1,) = match e { + Some(e) => (1i32, _rt::as_i64(e)), + None => { + (0i32, 0i64) + }, + }; + (28i32, result25_0, ::core::mem::MaybeUninit::new(result25_1 as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + }, + ErrorCode::HttpResponseTrailerSectionSize(e) => { + let (result26_0,result26_1,) = match e { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + }; + (29i32, result26_0, ::core::mem::MaybeUninit::new(i64::from(result26_1) as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + }, + ErrorCode::HttpResponseTrailerSize(e) => { + let FieldSizePayload{ field_name:field_name27, field_size:field_size27, } = e; + let (result29_0,result29_1,result29_2,) = match field_name27 { + Some(e) => { + let vec28 = e; + let ptr28 = vec28.as_ptr().cast::(); + let len28 = vec28.len(); + + (1i32, ptr28.cast_mut(), len28) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + };let (result30_0,result30_1,) = match field_size27 { + Some(e) => (1i32, _rt::as_i32(e)), + None => { + (0i32, 0i32) + }, + }; + (30i32, result29_0, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result29_1); + t + }, result29_2 as *mut u8, result30_0 as *mut u8, result30_1 as usize, 0i32) + }, + ErrorCode::HttpResponseTransferCoding(e) => { + let (result32_0,result32_1,result32_2,) = match e { + Some(e) => { + let vec31 = e; + let ptr31 = vec31.as_ptr().cast::(); + let len31 = vec31.len(); + + (1i32, ptr31.cast_mut(), len31) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + }; + (31i32, result32_0, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result32_1); + t + }, result32_2 as *mut u8, ::core::ptr::null_mut(), 0usize, 0i32) + }, + ErrorCode::HttpResponseContentCoding(e) => { + let (result34_0,result34_1,result34_2,) = match e { + Some(e) => { + let vec33 = e; + let ptr33 = vec33.as_ptr().cast::(); + let len33 = vec33.len(); + + (1i32, ptr33.cast_mut(), len33) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + }; + (32i32, result34_0, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result34_1); + t + }, result34_2 as *mut u8, ::core::ptr::null_mut(), 0usize, 0i32) + }, + ErrorCode::HttpResponseTimeout=> { + (33i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::HttpUpgradeFailed=> { + (34i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::HttpProtocolError=> { + (35i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::LoopDetected=> { + (36i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::ConfigurationError=> { + (37i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) + } + ErrorCode::InternalError(e) => { + let (result36_0,result36_1,result36_2,) = match e { + Some(e) => { + let vec35 = e; + let ptr35 = vec35.as_ptr().cast::(); + let len35 = vec35.len(); + + (1i32, ptr35.cast_mut(), len35) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + }; + (38i32, result36_0, { + let mut t = ::core::mem::MaybeUninit::::uninit(); + t.as_mut_ptr().cast::<*mut u8>().write(result36_1); + t + }, result36_2 as *mut u8, ::core::ptr::null_mut(), 0usize, 0i32) + }, + }; + + (1i32, result37_0, result37_1, result37_2, result37_3, result37_4, result37_5, result37_6) + } }, + }; + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[static]response-outparam.set"] + fn wit_import(_: i32, _: i32, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: *mut u8, _: *mut u8, _: usize, _: i32, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: *mut u8, _: *mut u8, _: usize, _: i32, ){ unreachable!() } + wit_import((¶m).take_handle() as i32, result38_0, result38_1, result38_2, result38_3, result38_4, result38_5, result38_6, result38_7); + } + } + } + impl IncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the status code from the incoming response. + pub fn status(&self,) -> StatusCode{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-response.status"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl IncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the headers from the incoming response. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// This headers resource is a child: it must be dropped before the parent + /// `incoming-response` is dropped. + pub fn headers(&self,) -> Headers{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-response.headers"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) + } + } + } + impl IncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the incoming body. May be called at most once. Returns error + /// if called additional times. + pub fn consume(&self,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-response.consume"] + 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 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + IncomingBody::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingBody { + #[allow(unused_unsafe, clippy::all)] + /// Returns the contents of the body, as a stream of bytes. + /// + /// Returns success on first call: the stream representing the contents + /// can be retrieved at most once. Subsequent calls will return error. + /// + /// The returned `input-stream` resource is a child: it must be dropped + /// before the parent `incoming-body` is dropped, or consumed by + /// `incoming-body.finish`. + /// + /// This invariant ensures that the implementation can determine whether + /// the user is consuming the contents of the body, waiting on the + /// `future-trailers` to be ready, or neither. This allows for network + /// backpressure is to be applied when the user is consuming the body, + /// and for that backpressure to not inhibit delivery of the trailers if + /// the user does not read the entire body. + pub fn stream(&self,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]incoming-body.stream"] + 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 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::InputStream::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl IncomingBody { + #[allow(unused_unsafe, clippy::all)] + /// Takes ownership of `incoming-body`, and returns a `future-trailers`. + /// This function will trap if the `input-stream` child is still alive. + pub fn finish(this: IncomingBody,) -> FutureTrailers{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[static]incoming-body.finish"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import((&this).take_handle() as i32); + FutureTrailers::from_handle(ret as u32) + } + } + } + impl FutureTrailers { + #[allow(unused_unsafe, clippy::all)] + /// Returns a pollable which becomes ready when either the trailers have + /// been received, or an error has occured. When this pollable is ready, + /// the `get` method will return `some`. + /// subscribe: func() -> pollable; // Hermes does NOT support `poll` + /// Returns the contents of the trailers, or an error which occured, + /// once the future is ready. + /// + /// The outer `option` represents future readiness. Users can wait on this + /// `option` to become `some` using the `subscribe` method. + /// + /// The outer `result` is used to retrieve the trailers or error at most + /// once. It will be success on the first call in which the outer option + /// is `some`, and error on subsequent calls. + /// + /// The inner `result` represents that either the HTTP Request or Response + /// body, as well as any trailers, were received successfully, or that an + /// error occured receiving them. The optional `trailers` indicates whether + /// or not trailers were present in the body. + /// + /// When some `trailers` are returned by this method, the `trailers` + /// resource is immutable, and a child. Use of the `set`, `append`, or + /// `delete` methods will return an error, and the resource must be + /// dropped before the parent `future-trailers` is dropped. + pub fn get(&self,) -> Option,ErrorCode>,()>>{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 56]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 56]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]future-trailers.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 = 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::()); + + 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 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Construct an `outgoing-response`, with a default `status-code` of `200`. + /// If a different `status-code` is needed, it must be set via the + /// `set-status-code` method. + /// + /// * `headers` is the HTTP Headers for the Response. + pub fn new(headers: Headers,) -> Self{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[constructor]outgoing-response"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import((&headers).take_handle() as i32); + OutgoingResponse::from_handle(ret as u32) + } + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Get the HTTP Status Code for the Response. + pub fn status_code(&self,) -> StatusCode{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-response.status-code"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32); + ret as u16 + } + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Set the HTTP Status Code for the Response. Fails if the status-code + /// given is not a valid http status code. + pub fn set_status_code(&self,status_code: StatusCode,) -> Result<(),()>{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-response.set-status-code"] + fn wit_import(_: i32, _: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32, _rt::as_i32(status_code)); + match ret { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Get the headers associated with the Request. + /// + /// The returned `headers` resource is immutable: `set`, `append`, and + /// `delete` operations will fail with `header-error.immutable`. + /// + /// This headers resource is a child: it must be dropped before the parent + /// `outgoing-request` is dropped, or its ownership is transfered to + /// another component by e.g. `outgoing-handler.handle`. + pub fn headers(&self,) -> Headers{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-response.headers"] + fn wit_import(_: i32, ) -> i32; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, ) -> i32{ unreachable!() } + let ret = wit_import((self).handle() as i32); + Fields::from_handle(ret as u32) + } + } + } + impl OutgoingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns the resource corresponding to the outgoing Body for this Response. + /// + /// Returns success on the first call: the `outgoing-body` resource for + /// this `outgoing-response` can be retrieved at most once. Subsequent + /// calls will return error. + pub fn body(&self,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-response.body"] + 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 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + OutgoingBody::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingBody { + #[allow(unused_unsafe, clippy::all)] + /// Returns a stream for writing the body contents. + /// + /// The returned `output-stream` is a child resource: it must be dropped + /// before the parent `outgoing-body` resource is dropped (or finished), + /// otherwise the `outgoing-body` drop or `finish` will trap. + /// + /// Returns success on the first call: the `output-stream` resource for + /// this `outgoing-body` may be retrieved at most once. Subsequent calls + /// will return error. + pub fn write(&self,) -> Result{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[method]outgoing-body.write"] + 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 => { + let e = { + let l2 = *ptr0.add(4).cast::(); + + super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutgoingBody { + #[allow(unused_unsafe, clippy::all)] + /// Finalize an outgoing body, optionally providing trailers. This must be + /// called to signal that the response is complete. If the `outgoing-body` + /// is dropped without calling `outgoing-body.finalize`, the implementation + /// should treat the body as corrupted. + /// + /// Fails if the body's `outgoing-request` or `outgoing-response` was + /// constructed with a Content-Length header, and the contents written + /// to the body (via `write`) does not match the value given in the + /// Content-Length. + pub fn finish(this: OutgoingBody,trailers: Option,) -> Result<(),ErrorCode>{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 40]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); + let (result0_0,result0_1,) = match &trailers { + Some(e) => (1i32, (e).take_handle() as i32), + None => { + (0i32, 0i32) + }, + };let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/types@0.2.0")] + extern "C" { + #[link_name = "[static]outgoing-body.finish"] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, ){ unreachable!() } + wit_import((&this).take_handle() as i32, result0_0, result0_1, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(8).cast::()); + let v65 = match l3 { + 0 => { + ErrorCode::DnsTimeout + } + 1 => { + let e65 = { + let l4 = i32::from(*ptr1.add(16).cast::()); + let l8 = i32::from(*ptr1.add(28).cast::()); + + DnsErrorPayload{ + rcode: match l4 { + 0 => None, + 1 => { + let e = { + let l5 = *ptr1.add(20).cast::<*mut u8>(); + let l6 = *ptr1.add(24).cast::(); + let len7 = l6; + let bytes7 = _rt::Vec::from_raw_parts(l5.cast(), len7, len7); + + _rt::string_lift(bytes7) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + info_code: match l8 { + 0 => None, + 1 => { + let e = { + let l9 = i32::from(*ptr1.add(30).cast::()); + + l9 as u16 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::DnsError(e65) + } + 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 e65 = { + let l10 = i32::from(*ptr1.add(16).cast::()); + let l12 = i32::from(*ptr1.add(20).cast::()); + + TlsAlertReceivedPayload{ + alert_id: match l10 { + 0 => None, + 1 => { + let e = { + let l11 = i32::from(*ptr1.add(17).cast::()); + + l11 as u8 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + alert_message: match l12 { + 0 => None, + 1 => { + let e = { + let l13 = *ptr1.add(24).cast::<*mut u8>(); + let l14 = *ptr1.add(28).cast::(); + let len15 = l14; + let bytes15 = _rt::Vec::from_raw_parts(l13.cast(), len15, len15); + + _rt::string_lift(bytes15) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::TlsAlertReceived(e65) + } + 15 => { + ErrorCode::HttpRequestDenied + } + 16 => { + ErrorCode::HttpRequestLengthRequired + } + 17 => { + let e65 = { + let l16 = i32::from(*ptr1.add(16).cast::()); + + match l16 { + 0 => None, + 1 => { + let e = { + let l17 = *ptr1.add(24).cast::(); + + l17 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestBodySize(e65) + } + 18 => { + ErrorCode::HttpRequestMethodInvalid + } + 19 => { + ErrorCode::HttpRequestUriInvalid + } + 20 => { + ErrorCode::HttpRequestUriTooLong + } + 21 => { + let e65 = { + let l18 = i32::from(*ptr1.add(16).cast::()); + + match l18 { + 0 => None, + 1 => { + let e = { + let l19 = *ptr1.add(20).cast::(); + + l19 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSectionSize(e65) + } + 22 => { + let e65 = { + let l20 = i32::from(*ptr1.add(16).cast::()); + + match l20 { + 0 => None, + 1 => { + let e = { + let l21 = i32::from(*ptr1.add(20).cast::()); + let l25 = i32::from(*ptr1.add(32).cast::()); + + 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::(); + + l26 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestHeaderSize(e65) + } + 23 => { + let e65 = { + let l27 = i32::from(*ptr1.add(16).cast::()); + + match l27 { + 0 => None, + 1 => { + let e = { + let l28 = *ptr1.add(20).cast::(); + + l28 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpRequestTrailerSectionSize(e65) + } + 24 => { + let e65 = { + let l29 = i32::from(*ptr1.add(16).cast::()); + let l33 = i32::from(*ptr1.add(28).cast::()); + + FieldSizePayload{ + field_name: match l29 { + 0 => None, + 1 => { + let e = { + let l30 = *ptr1.add(20).cast::<*mut u8>(); + let l31 = *ptr1.add(24).cast::(); + let len32 = l31; + let bytes32 = _rt::Vec::from_raw_parts(l30.cast(), len32, len32); + + _rt::string_lift(bytes32) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l33 { + 0 => None, + 1 => { + let e = { + let l34 = *ptr1.add(32).cast::(); + + l34 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpRequestTrailerSize(e65) + } + 25 => { + ErrorCode::HttpResponseIncomplete + } + 26 => { + let e65 = { + let l35 = i32::from(*ptr1.add(16).cast::()); + + match l35 { + 0 => None, + 1 => { + let e = { + let l36 = *ptr1.add(20).cast::(); + + l36 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseHeaderSectionSize(e65) + } + 27 => { + let e65 = { + let l37 = i32::from(*ptr1.add(16).cast::()); + let l41 = i32::from(*ptr1.add(28).cast::()); + + FieldSizePayload{ + field_name: match l37 { + 0 => None, + 1 => { + let e = { + let l38 = *ptr1.add(20).cast::<*mut u8>(); + let l39 = *ptr1.add(24).cast::(); + let len40 = l39; + let bytes40 = _rt::Vec::from_raw_parts(l38.cast(), len40, len40); + + _rt::string_lift(bytes40) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l41 { + 0 => None, + 1 => { + let e = { + let l42 = *ptr1.add(32).cast::(); + + l42 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseHeaderSize(e65) + } + 28 => { + let e65 = { + let l43 = i32::from(*ptr1.add(16).cast::()); + + match l43 { + 0 => None, + 1 => { + let e = { + let l44 = *ptr1.add(24).cast::(); + + l44 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseBodySize(e65) + } + 29 => { + let e65 = { + let l45 = i32::from(*ptr1.add(16).cast::()); + + match l45 { + 0 => None, + 1 => { + let e = { + let l46 = *ptr1.add(20).cast::(); + + l46 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTrailerSectionSize(e65) + } + 30 => { + let e65 = { + let l47 = i32::from(*ptr1.add(16).cast::()); + let l51 = i32::from(*ptr1.add(28).cast::()); + + FieldSizePayload{ + field_name: match l47 { + 0 => None, + 1 => { + let e = { + let l48 = *ptr1.add(20).cast::<*mut u8>(); + let l49 = *ptr1.add(24).cast::(); + let len50 = l49; + let bytes50 = _rt::Vec::from_raw_parts(l48.cast(), len50, len50); + + _rt::string_lift(bytes50) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + field_size: match l51 { + 0 => None, + 1 => { + let e = { + let l52 = *ptr1.add(32).cast::(); + + l52 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + ErrorCode::HttpResponseTrailerSize(e65) + } + 31 => { + let e65 = { + let l53 = i32::from(*ptr1.add(16).cast::()); + + match l53 { + 0 => None, + 1 => { + let e = { + let l54 = *ptr1.add(20).cast::<*mut u8>(); + let l55 = *ptr1.add(24).cast::(); + let len56 = l55; + let bytes56 = _rt::Vec::from_raw_parts(l54.cast(), len56, len56); + + _rt::string_lift(bytes56) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseTransferCoding(e65) + } + 32 => { + let e65 = { + let l57 = i32::from(*ptr1.add(16).cast::()); + + match l57 { + 0 => None, + 1 => { + let e = { + let l58 = *ptr1.add(20).cast::<*mut u8>(); + let l59 = *ptr1.add(24).cast::(); + let len60 = l59; + let bytes60 = _rt::Vec::from_raw_parts(l58.cast(), len60, len60); + + _rt::string_lift(bytes60) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::HttpResponseContentCoding(e65) + } + 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 e65 = { + let l61 = i32::from(*ptr1.add(16).cast::()); + + match l61 { + 0 => None, + 1 => { + let e = { + let l62 = *ptr1.add(20).cast::<*mut u8>(); + let l63 = *ptr1.add(24).cast::(); + let len64 = l63; + let bytes64 = _rt::Vec::from_raw_parts(l62.cast(), len64, len64); + + _rt::string_lift(bytes64) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + ErrorCode::InternalError(e65) + } + }; + + v65 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl FutureIncomingResponse { + #[allow(unused_unsafe, clippy::all)] + /// Returns a pollable which becomes ready when either the Response has + /// been received, or an error has occured. When this pollable is ready, + /// the `get` method will return `some`. + /// subscribe: func() -> pollable; // Hermes does NOT support `poll` + /// Returns the incoming HTTP Response, or an error, once one is ready. + /// + /// The outer `option` represents future readiness. Users can wait on this + /// `option` to become `some` using the `subscribe` method. + /// + /// The outer `result` is used to retrieve the response or error at most + /// once. It will be success on the first call in which the outer option + /// is `some`, and error on subsequent calls. + /// + /// The inner `result` represents that either the incoming HTTP Response + /// status and headers have recieved successfully, or that an error + /// occured. Errors may also occur while consuming the response body, + /// but those will be reported by the `incoming-body` and its + /// `output-stream` child. + pub fn get(&self,) -> Option,()>>{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 56]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 56]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[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::()); + + 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 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Ok(e) + } + 1 => { + let e = (); + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + + } + + #[allow(dead_code, clippy::all)] + pub mod outgoing_handler { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type OutgoingRequest = super::super::super::wasi::http::types::OutgoingRequest; + pub type RequestOptions = super::super::super::wasi::http::types::RequestOptions; + pub type FutureIncomingResponse = super::super::super::wasi::http::types::FutureIncomingResponse; + pub type ErrorCode = super::super::super::wasi::http::types::ErrorCode; + #[allow(unused_unsafe, clippy::all)] + /// This function is invoked with an outgoing HTTP Request, and it returns + /// a resource `future-incoming-response` which represents an HTTP Response + /// which may arrive in the future. + /// + /// The `options` argument accepts optional parameters for the HTTP + /// protocol's transport layer. + /// + /// This function may return an error if the `outgoing-request` is invalid + /// or not allowed to be made. Otherwise, protocol errors are reported + /// through the `future-incoming-response`. + pub fn handle(request: OutgoingRequest,options: Option,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 40]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); + let (result0_0,result0_1,) = match &options { + Some(e) => (1i32, (e).take_handle() as i32), + None => { + (0i32, 0i32) + }, + };let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:http/outgoing-handler@0.2.0")] + extern "C" { + #[link_name = "handle"] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, ){ unreachable!() } + wit_import((&request).take_handle() as i32, result0_0, result0_1, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = { + let l3 = *ptr1.add(8).cast::(); + + super::super::super::wasi::http::types::FutureIncomingResponse::from_handle(l3 as u32) + }; + Ok(e) + } + 1 => { + let e = { + let l4 = i32::from(*ptr1.add(8).cast::()); + use super::super::super::wasi::http::types::ErrorCode as V66; + let v66 = match l4 { + 0 => { + V66::DnsTimeout + } + 1 => { + let e66 = { + let l5 = i32::from(*ptr1.add(16).cast::()); + 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::()); + + l10 as u16 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + V66::DnsError(e66) + } + 2 => { + V66::DestinationNotFound + } + 3 => { + V66::DestinationUnavailable + } + 4 => { + V66::DestinationIpProhibited + } + 5 => { + V66::DestinationIpUnroutable + } + 6 => { + V66::ConnectionRefused + } + 7 => { + V66::ConnectionTerminated + } + 8 => { + V66::ConnectionTimeout + } + 9 => { + V66::ConnectionReadTimeout + } + 10 => { + V66::ConnectionWriteTimeout + } + 11 => { + V66::ConnectionLimitReached + } + 12 => { + V66::TlsProtocolError + } + 13 => { + V66::TlsCertificateError + } + 14 => { + let e66 = { + let l11 = i32::from(*ptr1.add(16).cast::()); + 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::()); + + 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) + } + 15 => { + V66::HttpRequestDenied + } + 16 => { + V66::HttpRequestLengthRequired + } + 17 => { + let e66 = { + let l17 = i32::from(*ptr1.add(16).cast::()); + + match l17 { + 0 => None, + 1 => { + let e = { + let l18 = *ptr1.add(24).cast::(); + + l18 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpRequestBodySize(e66) + } + 18 => { + V66::HttpRequestMethodInvalid + } + 19 => { + V66::HttpRequestUriInvalid + } + 20 => { + V66::HttpRequestUriTooLong + } + 21 => { + let e66 = { + let l19 = i32::from(*ptr1.add(16).cast::()); + + match l19 { + 0 => None, + 1 => { + let e = { + let l20 = *ptr1.add(20).cast::(); + + l20 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpRequestHeaderSectionSize(e66) + } + 22 => { + let e66 = { + let l21 = i32::from(*ptr1.add(16).cast::()); + + match l21 { + 0 => None, + 1 => { + let e = { + let l22 = i32::from(*ptr1.add(20).cast::()); + let l26 = 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); + + _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(), + }, + } + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpRequestHeaderSize(e66) + } + 23 => { + let e66 = { + let l28 = i32::from(*ptr1.add(16).cast::()); + + match l28 { + 0 => None, + 1 => { + let e = { + let l29 = *ptr1.add(20).cast::(); + + l29 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpRequestTrailerSectionSize(e66) + } + 24 => { + let e66 = { + let l30 = i32::from(*ptr1.add(16).cast::()); + 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::(); + + l35 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + V66::HttpRequestTrailerSize(e66) + } + 25 => { + V66::HttpResponseIncomplete + } + 26 => { + let e66 = { + let l36 = i32::from(*ptr1.add(16).cast::()); + + match l36 { + 0 => None, + 1 => { + let e = { + let l37 = *ptr1.add(20).cast::(); + + l37 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseHeaderSectionSize(e66) + } + 27 => { + let e66 = { + let l38 = i32::from(*ptr1.add(16).cast::()); + 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::(); + + l43 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + V66::HttpResponseHeaderSize(e66) + } + 28 => { + let e66 = { + let l44 = i32::from(*ptr1.add(16).cast::()); + + match l44 { + 0 => None, + 1 => { + let e = { + let l45 = *ptr1.add(24).cast::(); + + l45 as u64 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseBodySize(e66) + } + 29 => { + let e66 = { + let l46 = i32::from(*ptr1.add(16).cast::()); + + match l46 { + 0 => None, + 1 => { + let e = { + let l47 = *ptr1.add(20).cast::(); + + l47 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseTrailerSectionSize(e66) + } + 30 => { + let e66 = { + let l48 = i32::from(*ptr1.add(16).cast::()); + 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::(); + + l53 as u32 + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + } + }; + V66::HttpResponseTrailerSize(e66) + } + 31 => { + let e66 = { + let l54 = i32::from(*ptr1.add(16).cast::()); + + match l54 { + 0 => None, + 1 => { + let e = { + let l55 = *ptr1.add(20).cast::<*mut u8>(); + let l56 = *ptr1.add(24).cast::(); + let len57 = l56; + let bytes57 = _rt::Vec::from_raw_parts(l55.cast(), len57, len57); + + _rt::string_lift(bytes57) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseTransferCoding(e66) + } + 32 => { + let e66 = { + let l58 = i32::from(*ptr1.add(16).cast::()); + + match l58 { + 0 => None, + 1 => { + let e = { + let l59 = *ptr1.add(20).cast::<*mut u8>(); + let l60 = *ptr1.add(24).cast::(); + let len61 = l60; + let bytes61 = _rt::Vec::from_raw_parts(l59.cast(), len61, len61); + + _rt::string_lift(bytes61) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::HttpResponseContentCoding(e66) + } + 33 => { + V66::HttpResponseTimeout + } + 34 => { + V66::HttpUpgradeFailed + } + 35 => { + V66::HttpProtocolError + } + 36 => { + V66::LoopDetected + } + 37 => { + V66::ConfigurationError + } + n => { + debug_assert_eq!(n, 38, "invalid enum discriminant"); + let e66 = { + let l62 = i32::from(*ptr1.add(16).cast::()); + + match l62 { + 0 => None, + 1 => { + let e = { + let l63 = *ptr1.add(20).cast::<*mut u8>(); + let l64 = *ptr1.add(24).cast::(); + let len65 = l64; + let bytes65 = _rt::Vec::from_raw_parts(l63.cast(), len65, len65); + + _rt::string_lift(bytes65) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + } + }; + V66::InternalError(e66) + } + }; + + v66 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + + } + + } + #[allow(dead_code)] + pub mod io { + #[allow(dead_code, clippy::all)] + pub mod error { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + /// A resource which represents some error information. + /// + /// The only method provided by this resource is `to-debug-string`, + /// which provides some human-readable information about the error. + /// + /// In the `wasi:io` package, this resource is returned through the + /// `wasi:io/streams/stream-error` type. + /// + /// To provide more specific error information, other interfaces may + /// provide functions to further "downcast" this error into more specific + /// error information. For example, `error`s returned in streams derived + /// from filesystem types to be described using the filesystem's own + /// error-code type, using the function + /// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter + /// `borrow` and returns + /// `option`. + /// + /// The set of functions which can "downcast" an `error` into a more + /// concrete type is open. + + #[derive(Debug)] + #[repr(transparent)] + pub struct Error{ + handle: _rt::Resource, + } + + impl Error{ + #[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 Error{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/error@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]error"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl Error { + #[allow(unused_unsafe, clippy::all)] + /// Returns a string that is suitable to assist humans in debugging + /// this error. + /// + /// WARNING: The returned string should not be consumed mechanically! + /// It may change across platforms, hosts, or other implementation + /// details. Parsing this string is a major platform-compatibility + /// hazard. + pub fn to_debug_string(&self,) -> _rt::String{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/error@0.2.0")] + extern "C" { + #[link_name = "[method]error.to-debug-string"] + 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 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let len3 = l2; + let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); + _rt::string_lift(bytes3) + } + } + } + + } + + #[allow(dead_code, clippy::all)] + pub mod streams { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + pub type Error = super::super::super::wasi::io::error::Error; + /// * + /// // Hermes does not support `poll` + /// use poll.{pollable}; + /// */ + /// An error for input-stream and output-stream operations. + pub enum StreamError { + /// The last operation (a write or flush) failed before completion. + /// + /// More information is available in the `error` payload. + LastOperationFailed(Error), + /// The stream is closed: no more input will be accepted by the + /// stream. A closed output-stream will return this error on all + /// future operations. + Closed, + } + impl ::core::fmt::Debug for StreamError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + match self { + StreamError::LastOperationFailed(e) => { + f.debug_tuple("StreamError::LastOperationFailed").field(e).finish() + } + StreamError::Closed => { + f.debug_tuple("StreamError::Closed").finish() + } + } + } + } + impl ::core::fmt::Display for StreamError { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{:?}", self) + } + } + + impl std::error::Error for StreamError {} + /// An input bytestream. + /// + /// `input-stream`s are *non-blocking* to the extent practical on underlying + /// platforms. I/O operations always return promptly; if fewer bytes are + /// promptly available than requested, they return the number of bytes promptly + /// available, which could even be zero. To wait for data to be available, + /// use the `subscribe` function to obtain a `pollable` which can be polled + /// for using `wasi:io/poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct InputStream{ + handle: _rt::Resource, + } + + impl InputStream{ + #[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 InputStream{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]input-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + /// An output bytestream. + /// + /// `output-stream`s are *non-blocking* to the extent practical on + /// underlying platforms. Except where specified otherwise, I/O operations also + /// always return promptly, after the number of bytes that can be written + /// promptly, which could even be zero. To wait for the stream to be ready to + /// accept data, the `subscribe` function to obtain a `pollable` which can be + /// polled for using `wasi:io/poll`. + + #[derive(Debug)] + #[repr(transparent)] + pub struct OutputStream{ + handle: _rt::Resource, + } + + impl OutputStream{ + #[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 OutputStream{ + #[inline] + unsafe fn drop(_handle: u32) { + #[cfg(not(target_arch = "wasm32"))] + unreachable!(); + + #[cfg(target_arch = "wasm32")] + { + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[resource-drop]output-stream"] + fn drop(_: u32); + } + + drop(_handle); + } + } + } + + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a non-blocking read from the stream. + /// + /// This function returns a list of bytes containing the read data, + /// when successful. The returned list will contain up to `len` bytes; + /// it may return fewer than requested, but not more. The list is + /// empty when no bytes are available for reading at this time. The + /// pollable given by `subscribe` will be ready when more bytes are + /// available. + /// + /// This function fails with a `stream-error` when the operation + /// encounters an error, giving `last-operation-failed`, or when the + /// stream is closed, giving `closed`. + /// + /// When the caller gives a `len` of 0, it represents a request to + /// read 0 bytes. If the stream is still open, this call should + /// succeed and return an empty list, or otherwise fail with `closed`. + /// + /// The `len` parameter is a `u64`, which could represent a list of u8 which + /// is not possible to allocate in wasm32, or not desirable to allocate as + /// as a return value by the callee. The callee may return a list of bytes + /// less than `len` in size while more bytes are available for reading. + pub fn read(&self,len: u64,) -> Result<_rt::Vec::,StreamError>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.read"] + fn wit_import(_: i32, _: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr0.add(4).cast::()); + let v7 = match l5 { + 0 => { + let e7 = { + let l6 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l6 as u32) + }; + StreamError::LastOperationFailed(e7) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v7 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read bytes from a stream, after blocking until at least one byte can + /// be read. Except for blocking, behavior is identical to `read`. + pub fn blocking_read(&self,len: u64,) -> Result<_rt::Vec::,StreamError>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.blocking-read"] + fn wit_import(_: i32, _: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(4).cast::<*mut u8>(); + let l3 = *ptr0.add(8).cast::(); + let len4 = l3; + + _rt::Vec::from_raw_parts(l2.cast(), len4, len4) + }; + Ok(e) + } + 1 => { + let e = { + let l5 = i32::from(*ptr0.add(4).cast::()); + let v7 = match l5 { + 0 => { + let e7 = { + let l6 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l6 as u32) + }; + StreamError::LastOperationFailed(e7) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v7 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Skip bytes from a stream. Returns number of bytes skipped. + /// + /// Behaves identical to `read`, except instead of returning a list + /// of bytes, returns the number of bytes consumed from the stream. + pub fn skip(&self,len: u64,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.skip"] + fn wit_import(_: i32, _: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl InputStream { + #[allow(unused_unsafe, clippy::all)] + /// Skip bytes from a stream, after blocking until at least one byte + /// can be skipped. Except for blocking behavior, identical to `skip`. + pub fn blocking_skip(&self,len: u64,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]input-stream.blocking-skip"] + fn wit_import(_: i32, _: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Check readiness for writing. This function never blocks. + /// + /// Returns the number of bytes permitted for the next call to `write`, + /// or an error. Calling `write` with more bytes than this function has + /// permitted will trap. + /// + /// When this function returns 0 bytes, the `subscribe` pollable will + /// become ready when this function will report at least 1 byte, or an + /// error. + pub fn check_write(&self,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.check-write"] + 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 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write. This function never blocks. + /// + /// Precondition: check-write gave permit of Ok(n) and contents has a + /// length of less than or equal to n. Otherwise, this function will trap. + /// + /// returns Err(closed) without writing if the stream has closed since + /// the last call to check-write provided a permit. + pub fn write(&self,contents: &[u8],) -> Result<(),StreamError>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = contents; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.write"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr1.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write of up to 4096 bytes, and then flush the stream. Block + /// until all of these operations are complete, or an error occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write`, and `flush`, and is implemented with the + /// following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while !contents.is_empty() { + /// // Wait for the stream to become writable + /// poll-one(pollable); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, contents.len()); + /// let (chunk, rest) = contents.split_at(len); + /// this.write(chunk ); // eliding error handling + /// contents = rest; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// poll-one(pollable); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + pub fn blocking_write_and_flush(&self,contents: &[u8],) -> Result<(),StreamError>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let vec0 = contents; + let ptr0 = vec0.as_ptr().cast::(); + let len0 = vec0.len(); + let ptr1 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-write-and-flush"] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); + let l2 = i32::from(*ptr1.add(0).cast::()); + match l2 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr1.add(4).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr1.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Request to flush buffered output. This function never blocks. + /// + /// This tells the output-stream that the caller intends any buffered + /// output to be flushed. the output which is expected to be flushed + /// is all that has been passed to `write` prior to this call. + /// + /// Upon calling this function, the `output-stream` will not accept any + /// writes (`check-write` will return `ok(0)`) until the flush has + /// completed. The `subscribe` pollable will become ready when the + /// flush has completed and the stream can accept more writes. + pub fn flush(&self,) -> Result<(),StreamError>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.flush"] + 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 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Request to flush buffered output, and block until flush completes + /// and stream is ready for writing again. + pub fn blocking_flush(&self,) -> Result<(),StreamError>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-flush"] + 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 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Create a `pollable` which will resolve once the output-stream + /// is ready for more writing, or an error has occured. When this + /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an + /// error. + /// + /// If the stream is closed, this pollable is always ready immediately. + /// + /// The created `pollable` is a child resource of the `output-stream`. + /// Implementations may trap if the `output-stream` is dropped before + /// all derived `pollable`s created with this function are dropped. + /// subscribe: func() -> pollable; // Hermes does NOT support `poll` + /// Write zeroes to a stream. + /// + /// this should be used precisely like `write` with the exact same + /// preconditions (must use check-write first), but instead of + /// passing a list of bytes, you simply pass the number of zero-bytes + /// that should be written. + pub fn write_zeroes(&self,len: u64,) -> Result<(),StreamError>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.write-zeroes"] + fn wit_import(_: i32, _: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Perform a write of up to 4096 zeroes, and then flush the stream. + /// Block until all of these operations are complete, or an error + /// occurs. + /// + /// This is a convenience wrapper around the use of `check-write`, + /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with + /// the following pseudo-code: + /// + /// ```text + /// let pollable = this.subscribe(); + /// while num_zeroes != 0 { + /// // Wait for the stream to become writable + /// poll-one(pollable); + /// let Ok(n) = this.check-write(); // eliding error handling + /// let len = min(n, num_zeroes); + /// this.write-zeroes(len); // eliding error handling + /// num_zeroes -= len; + /// } + /// this.flush(); + /// // Wait for completion of `flush` + /// poll-one(pollable); + /// // Check for any errors that arose during `flush` + /// let _ = this.check-write(); // eliding error handling + /// ``` + pub fn blocking_write_zeroes_and_flush(&self,len: u64,) -> Result<(),StreamError>{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 12]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-write-zeroes-and-flush"] + fn wit_import(_: i32, _: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l2 = i32::from(*ptr0.add(4).cast::()); + let v4 = match l2 { + 0 => { + let e4 = { + let l3 = *ptr0.add(8).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l3 as u32) + }; + StreamError::LastOperationFailed(e4) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v4 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read from one stream and write to another. + /// + /// The behavior of splice is equivelant to: + /// 1. calling `check-write` on the `output-stream` + /// 2. calling `read` on the `input-stream` with the smaller of the + /// `check-write` permitted length and the `len` provided to `splice` + /// 3. calling `write` on the `output-stream` with that read data. + /// + /// Any error reported by the call to `check-write`, `read`, or + /// `write` ends the splice and reports that error. + /// + /// This function returns the number of bytes transferred; it may be less + /// than `len`. + pub fn splice(&self,src: &InputStream,len: u64,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.splice"] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, (src).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + impl OutputStream { + #[allow(unused_unsafe, clippy::all)] + /// Read from one stream and write to another, with blocking. + /// + /// This is similar to `splice`, except that it blocks until the + /// `output-stream` is ready for writing, and the `input-stream` + /// is ready for reading, before performing the `splice`. + pub fn blocking_splice(&self,src: &InputStream,len: u64,) -> Result{ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:io/streams@0.2.0")] + extern "C" { + #[link_name = "[method]output-stream.blocking-splice"] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, ){ unreachable!() } + wit_import((self).handle() as i32, (src).handle() as i32, _rt::as_i64(&len), ptr0); + let l1 = i32::from(*ptr0.add(0).cast::()); + match l1 { + 0 => { + let e = { + let l2 = *ptr0.add(8).cast::(); + + l2 as u64 + }; + Ok(e) + } + 1 => { + let e = { + let l3 = i32::from(*ptr0.add(8).cast::()); + let v5 = match l3 { + 0 => { + let e5 = { + let l4 = *ptr0.add(12).cast::(); + + super::super::super::wasi::io::error::Error::from_handle(l4 as u32) + }; + StreamError::LastOperationFailed(e5) + } + n => { + debug_assert_eq!(n, 1, "invalid enum discriminant"); + StreamError::Closed + } + }; + + v5 + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } + } + } + } + + } + + } + #[allow(dead_code)] + pub mod random { + #[allow(dead_code, clippy::all)] + pub mod random { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + #[allow(unused_unsafe, clippy::all)] + /// Return `len` cryptographically-secure random or pseudo-random bytes. + /// + /// This function must produce data at least as cryptographically secure and + /// fast as an adequately seeded cryptographically-secure pseudo-random + /// number generator (CSPRNG). It must not block, from the perspective of + /// the calling program, under any circumstances, including on the first + /// request and on requests for numbers of bytes. The returned data must + /// always be unpredictable. + /// + /// This function must always return fresh data. Deterministic environments + /// must omit this function, rather than implementing it with deterministic + /// data. + pub fn get_random_bytes(len: u64,) -> _rt::Vec::{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:random/random@0.2.0")] + extern "C" { + #[link_name = "get-random-bytes"] + fn wit_import(_: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: *mut u8, ){ unreachable!() } + wit_import(_rt::as_i64(&len), ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let len3 = l2; + _rt::Vec::from_raw_parts(l1.cast(), len3, len3) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Return a cryptographically-secure random or pseudo-random `u64` value. + /// + /// This function returns the same type of data as `get-random-bytes`, + /// represented as a `u64`. + pub fn get_random_u64() -> u64{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:random/random@0.2.0")] + extern "C" { + #[link_name = "get-random-u64"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64{ unreachable!() } + let ret = wit_import(); + ret as u64 + } + } + + } + + #[allow(dead_code, clippy::all)] + pub mod insecure { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + use super::super::super::_rt; + #[allow(unused_unsafe, clippy::all)] + /// Return `len` insecure pseudo-random bytes. + /// + /// This function is not cryptographically secure. Do not use it for + /// anything related to security. + /// + /// There are no requirements on the values of the returned bytes, however + /// implementations are encouraged to return evenly distributed values with + /// a long period. + pub fn get_insecure_random_bytes(len: u64,) -> _rt::Vec::{ + unsafe { + #[repr(align(4))] + struct RetArea([::core::mem::MaybeUninit::; 8]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:random/insecure@0.2.0")] + extern "C" { + #[link_name = "get-insecure-random-bytes"] + fn wit_import(_: i64, _: *mut u8, ); + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import(_: i64, _: *mut u8, ){ unreachable!() } + wit_import(_rt::as_i64(&len), ptr0); + let l1 = *ptr0.add(0).cast::<*mut u8>(); + let l2 = *ptr0.add(4).cast::(); + let len3 = l2; + _rt::Vec::from_raw_parts(l1.cast(), len3, len3) + } + } + #[allow(unused_unsafe, clippy::all)] + /// Return an insecure pseudo-random `u64` value. + /// + /// This function returns the same type of pseudo-random data as + /// `get-insecure-random-bytes`, represented as a `u64`. + pub fn get_insecure_random_u64() -> u64{ + unsafe { + + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:random/insecure@0.2.0")] + extern "C" { + #[link_name = "get-insecure-random-u64"] + fn wit_import() -> i64; + } + + #[cfg(not(target_arch = "wasm32"))] + fn wit_import() -> i64{ unreachable!() } + let ret = wit_import(); + ret as u64 + } + } + + } + + #[allow(dead_code, clippy::all)] + pub mod insecure_seed { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; + #[allow(unused_unsafe, clippy::all)] + /// Return a 128-bit value that may contain a pseudo-random value. + /// + /// The returned value is not required to be computed from a CSPRNG, and may + /// even be entirely deterministic. Host implementations are encouraged to + /// provide pseudo-random values to any program exposed to + /// attacker-controlled content, to enable DoS protection built into many + /// languages' hash-map implementations. + /// + /// This function is intended to only be called once, by a source language + /// to initialize Denial Of Service (DoS) protection in its hash-map + /// implementation. + /// + /// # Expected future evolution + /// + /// This will likely be changed to a value import, to prevent it from being + /// called multiple times and potentially used for purposes other than DoS + /// protection. + pub fn insecure_seed() -> (u64,u64,){ + unsafe { + #[repr(align(8))] + struct RetArea([::core::mem::MaybeUninit::; 16]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let ptr0 = ret_area.0.as_mut_ptr().cast::(); + #[cfg(target_arch = "wasm32")] + #[link(wasm_import_module = "wasi:random/insecure-seed@0.2.0")] + extern "C" { + #[link_name = "insecure-seed"] + 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::(); + (l1 as u64, l2 as u64) + } + } + + } + + } +} +#[allow(dead_code)] +pub mod exports { + #[allow(dead_code)] + pub mod hermes { + #[allow(dead_code)] + pub mod cardano { + #[allow(dead_code, clippy::all)] + pub mod event_on_block { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type CardanoBlockchainId = super::super::super::super::hermes::cardano::api::CardanoBlockchainId; + pub type CardanoBlock = super::super::super::super::hermes::cardano::api::CardanoBlock; + pub type BlockSrc = super::super::super::super::hermes::cardano::api::BlockSrc; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_on_cardano_block_cabi(arg0: i32,arg1: *mut u8,arg2: usize,arg3: i32,) {#[cfg(target_arch="wasm32")] + _rt::run_ctors_once();let len0 = arg2; + T::on_cardano_block(super::super::super::super::hermes::cardano::api::CardanoBlockchainId::_lift(arg0 as u8), _rt::Vec::from_raw_parts(arg1.cast(), len0, len0), super::super::super::super::hermes::cardano::api::BlockSrc::empty() | super::super::super::super::hermes::cardano::api::BlockSrc::from_bits_retain(((arg3 as u8) << 0) as _)); + } + pub trait Guest { + /// Triggered when a cardano block event fires. + /// + /// The module must export this interface to use it. + /// + /// ## Parameters + /// + /// - `blockchain` : The blockchain id the block originated from. + /// - `block` : This raw CBOR block data. + /// - `source` : Source information about where the block came from, and if we are at tip or not. + /// + /// Returns: + /// Nothing. + fn on_cardano_block(blockchain: CardanoBlockchainId,block: CardanoBlock,source: BlockSrc,); + } + #[doc(hidden)] + + macro_rules! __export_hermes_cardano_event_on_block_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "hermes:cardano/event-on-block#on-cardano-block"] + unsafe extern "C" fn export_on_cardano_block(arg0: i32,arg1: *mut u8,arg2: usize,arg3: i32,) { + $($path_to_types)*::_export_on_cardano_block_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_hermes_cardano_event_on_block_cabi; + + } + + #[allow(dead_code, clippy::all)] + pub mod event_on_txn { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type CardanoBlockchainId = super::super::super::super::hermes::cardano::api::CardanoBlockchainId; + pub type CardanoTxn = super::super::super::super::hermes::cardano::api::CardanoTxn; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_on_cardano_txn_cabi(arg0: i32,arg1: i64,arg2: i32,arg3: *mut u8,arg4: usize,) {#[cfg(target_arch="wasm32")] + _rt::run_ctors_once();let len0 = arg4; + T::on_cardano_txn(super::super::super::super::hermes::cardano::api::CardanoBlockchainId::_lift(arg0 as u8), arg1 as u64, arg2 as u32, _rt::Vec::from_raw_parts(arg3.cast(), len0, len0)); + } + pub trait Guest { + /// Triggered when a cardano transaction event fires. + /// + /// The module must export this interface to use it. + /// + /// ## Parameters + /// + /// - `blockchain` : The blockchain id the block originated from. + /// - `slot` : The slot the transaction is in. + /// - `txn-index` : The offset in the block this transaction is at. + /// - `txn` : The raw transaction data itself. + /// + /// Returns: + /// Nothing. + fn on_cardano_txn(blockchain: CardanoBlockchainId,slot: u64,txn_index: u32,txn: CardanoTxn,); + } + #[doc(hidden)] + + macro_rules! __export_hermes_cardano_event_on_txn_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "hermes:cardano/event-on-txn#on-cardano-txn"] + unsafe extern "C" fn export_on_cardano_txn(arg0: i32,arg1: i64,arg2: i32,arg3: *mut u8,arg4: usize,) { + $($path_to_types)*::_export_on_cardano_txn_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_hermes_cardano_event_on_txn_cabi; + + } + + #[allow(dead_code, clippy::all)] + pub mod event_on_rollback { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type CardanoBlockchainId = super::super::super::super::hermes::cardano::api::CardanoBlockchainId; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_on_cardano_rollback_cabi(arg0: i32,arg1: i64,) {#[cfg(target_arch="wasm32")] + _rt::run_ctors_once();T::on_cardano_rollback(super::super::super::super::hermes::cardano::api::CardanoBlockchainId::_lift(arg0 as u8), arg1 as u64); + } + pub trait Guest { + /// Triggered when a cardano rollback event fires. + /// + /// The module must export this interface to use it. + /// + /// ## Parameters + /// + /// - `blockchain` : The blockchain id the rollback originated from. + /// - `slot` : The slot the rollback is targeting. (The next block event will be from this slot.) + /// + /// Returns: + /// Nothing. + fn on_cardano_rollback(blockchain: CardanoBlockchainId,slot: u64,); + } + #[doc(hidden)] + + macro_rules! __export_hermes_cardano_event_on_rollback_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "hermes:cardano/event-on-rollback#on-cardano-rollback"] + unsafe extern "C" fn export_on_cardano_rollback(arg0: i32,arg1: i64,) { + $($path_to_types)*::_export_on_cardano_rollback_cabi::<$ty>(arg0, arg1) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_hermes_cardano_event_on_rollback_cabi; + +} + +} +#[allow(dead_code)] +pub mod cron { + #[allow(dead_code, clippy::all)] + pub mod event { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type CronTagged = super::super::super::super::hermes::cron::api::CronTagged; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_on_cron_cabi(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: i32,) -> i32 {#[cfg(target_arch="wasm32")] + _rt::run_ctors_once();let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + let result2 = T::on_cron(super::super::super::super::hermes::cron::api::CronTagged{ + when: _rt::string_lift(bytes0), + tag: _rt::string_lift(bytes1), + }, _rt::bool_lift(arg4 as u8)); + match result2 { true => 1, false => 0 } + } + pub trait Guest { + /// Triggered when a cron event fires. + /// + /// This event is only ever generated for the application that added + /// the cron job. + /// + /// The module must export this interface to use it. + /// + /// ## Parameters + /// + /// - `event` : The tagged cron event that was triggered. + /// - `last` : This cron event will not retrigger. + /// + /// Returns: + /// - `true` - retrigger. (Ignored if the cron event is `final`). + /// - `false` - stop the cron. + fn on_cron(event: CronTagged,last: bool,) -> bool; + } + #[doc(hidden)] + + macro_rules! __export_hermes_cron_event_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "hermes:cron/event#on-cron"] + unsafe extern "C" fn export_on_cron(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: i32,) -> i32 { + $($path_to_types)*::_export_on_cron_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_hermes_cron_event_cabi; + +} + +} +#[allow(dead_code)] +pub mod http_gateway { + #[allow(dead_code, clippy::all)] + pub mod event { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type Bstr = super::super::super::super::hermes::binary::api::Bstr; + pub type Header = (_rt::String,_rt::Vec::<_rt::String>,); + pub type Headers = _rt::Vec::
; + #[derive(Clone)] + pub struct HttpResponse { + pub code: u16, + pub headers: Headers, + pub body: Bstr, + } + impl ::core::fmt::Debug for HttpResponse { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("HttpResponse").field("code", &self.code).field("headers", &self.headers).field("body", &self.body).finish() + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_reply_cabi(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: *mut u8,arg5: usize,arg6: *mut u8,arg7: usize,) -> *mut u8 {#[cfg(target_arch="wasm32")] + _rt::run_ctors_once();let len0 = arg1; + let base10 = arg2; + let len10 = arg3; + let mut result10 = _rt::Vec::with_capacity(len10); + for i in 0..len10 { + let base = base10.add(i * 16); + let e10 = { + let l1 = *base.add(0).cast::<*mut u8>(); + let l2 = *base.add(4).cast::(); + let len3 = l2; + let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); + let l4 = *base.add(8).cast::<*mut u8>(); + let l5 = *base.add(12).cast::(); + let base9 = l4; + let len9 = l5; + let mut result9 = _rt::Vec::with_capacity(len9); + for i in 0..len9 { + let base = base9.add(i * 8); + let e9 = { + let l6 = *base.add(0).cast::<*mut u8>(); + let l7 = *base.add(4).cast::(); + let len8 = l7; + let bytes8 = _rt::Vec::from_raw_parts(l6.cast(), len8, len8); + + _rt::string_lift(bytes8) + }; + result9.push(e9); + } + _rt::cabi_dealloc(base9, len9 * 8, 4); + + (_rt::string_lift(bytes3), result9) + }; + result10.push(e10); + } + _rt::cabi_dealloc(base10, len10 * 16, 4); + let len11 = arg5; + let bytes11 = _rt::Vec::from_raw_parts(arg4.cast(), len11, len11); + let len12 = arg7; + let bytes12 = _rt::Vec::from_raw_parts(arg6.cast(), len12, len12); + let result13 = T::reply(_rt::Vec::from_raw_parts(arg0.cast(), len0, len0), result10, _rt::string_lift(bytes11), _rt::string_lift(bytes12)); + let ptr14 = _RET_AREA.0.as_mut_ptr().cast::(); + match result13 { + Some(e) => { + *ptr14.add(0).cast::() = (1i32) as u8; + let HttpResponse{ code:code15, headers:headers15, body:body15, } = e; + *ptr14.add(4).cast::() = (_rt::as_i32(code15)) as u16; + let vec20 = headers15; + let len20 = vec20.len(); + let layout20 = _rt::alloc::Layout::from_size_align_unchecked(vec20.len() * 16, 4); + let result20 = if layout20.size() != 0 { + let ptr = _rt::alloc::alloc(layout20).cast::(); + if ptr.is_null() + { + _rt::alloc::handle_alloc_error(layout20); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec20.into_iter().enumerate() { + let base = result20.add(i * 16); + { + let (t16_0, t16_1, ) = e; + let vec17 = (t16_0.into_bytes()).into_boxed_slice(); + let ptr17 = vec17.as_ptr().cast::(); + let len17 = vec17.len(); + ::core::mem::forget(vec17); + *base.add(4).cast::() = len17; + *base.add(0).cast::<*mut u8>() = ptr17.cast_mut(); + let vec19 = t16_1; + let len19 = vec19.len(); + let layout19 = _rt::alloc::Layout::from_size_align_unchecked(vec19.len() * 8, 4); + let result19 = if layout19.size() != 0 { + let ptr = _rt::alloc::alloc(layout19).cast::(); + if ptr.is_null() + { + _rt::alloc::handle_alloc_error(layout19); + } + ptr + }else {{ + ::core::ptr::null_mut() + }}; + for (i, e) in vec19.into_iter().enumerate() { + let base = result19.add(i * 8); + { + let vec18 = (e.into_bytes()).into_boxed_slice(); + let ptr18 = vec18.as_ptr().cast::(); + let len18 = vec18.len(); + ::core::mem::forget(vec18); + *base.add(4).cast::() = len18; + *base.add(0).cast::<*mut u8>() = ptr18.cast_mut(); + } + } + *base.add(12).cast::() = len19; + *base.add(8).cast::<*mut u8>() = result19; + } + } + *ptr14.add(12).cast::() = len20; + *ptr14.add(8).cast::<*mut u8>() = result20; + let vec21 = (body15).into_boxed_slice(); + let ptr21 = vec21.as_ptr().cast::(); + let len21 = vec21.len(); + ::core::mem::forget(vec21); + *ptr14.add(20).cast::() = len21; + *ptr14.add(16).cast::<*mut u8>() = ptr21.cast_mut(); + }, + None => { + { + *ptr14.add(0).cast::() = (0i32) as u8; + } + }, + };ptr14 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_reply(arg0: *mut u8,) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(8).cast::<*mut u8>(); + let l2 = *arg0.add(12).cast::(); + let base10 = l1; + let len10 = l2; + for i in 0..len10 { + let base = base10.add(i * 16); + { + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + _rt::cabi_dealloc(l3, l4, 1); + let l5 = *base.add(8).cast::<*mut u8>(); + let l6 = *base.add(12).cast::(); + let base9 = l5; + let len9 = l6; + for i in 0..len9 { + let base = base9.add(i * 8); + { + let l7 = *base.add(0).cast::<*mut u8>(); + let l8 = *base.add(4).cast::(); + _rt::cabi_dealloc(l7, l8, 1); + } + } + _rt::cabi_dealloc(base9, len9 * 8, 4); + } + } + _rt::cabi_dealloc(base10, len10 * 16, 4); + let l11 = *arg0.add(16).cast::<*mut u8>(); + let l12 = *arg0.add(20).cast::(); + let base13 = l11; + let len13 = l12; + _rt::cabi_dealloc(base13, len13 * 1, 1); + }, + } + } + pub trait Guest { + fn reply(body: Bstr,headers: Headers,path: _rt::String,method: _rt::String,) -> Option; + } + #[doc(hidden)] + + macro_rules! __export_hermes_http_gateway_event_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "hermes:http-gateway/event#reply"] + unsafe extern "C" fn export_reply(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: *mut u8,arg5: usize,arg6: *mut u8,arg7: usize,) -> *mut u8 { + $($path_to_types)*::_export_reply_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) + } + #[export_name = "cabi_post_hermes:http-gateway/event#reply"] + unsafe extern "C" fn _post_return_reply(arg0: *mut u8,) { + $($path_to_types)*::__post_return_reply::<$ty>(arg0) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_hermes_http_gateway_event_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit::; 24]); + static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 24]); + +} + +} +#[allow(dead_code)] +pub mod init { + #[allow(dead_code, clippy::all)] + pub mod event { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_init_cabi() -> i32 {#[cfg(target_arch="wasm32")] + _rt::run_ctors_once();let result0 = T::init(); + match result0 { true => 1, false => 0 } + } + pub trait Guest { + /// Perform application start up initialization. + /// + /// This will only ever be called once when the application this module is a part of is started. + /// The module must export this interface to use it. + /// + /// Returns: + /// - `true` - Initialization is successful, the application may commence. + /// - `false` - Fatal error during Initialization. DO NOT START APPLICATION. + fn init() -> bool; + } + #[doc(hidden)] + + macro_rules! __export_hermes_init_event_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "hermes:init/event#init"] + unsafe extern "C" fn export_init() -> i32 { + $($path_to_types)*::_export_init_cabi::<$ty>() + } + };); + } + #[doc(hidden)] + pub(crate) use __export_hermes_init_event_cabi; + +} + +} +#[allow(dead_code)] +pub mod integration_test { + #[allow(dead_code, clippy::all)] + pub mod event { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + /// Time in localtime format. + #[derive(Clone)] + pub struct TestResult { + pub name: _rt::String, + /// Name of the test + pub status: bool, + } + impl ::core::fmt::Debug for TestResult { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("TestResult").field("name", &self.name).field("status", &self.status).finish() + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_test_cabi(arg0: i32,arg1: i32,) -> *mut u8 {#[cfg(target_arch="wasm32")] + _rt::run_ctors_once();let result0 = T::test(arg0 as u32, _rt::bool_lift(arg1 as u8)); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Some(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let TestResult{ name:name2, status:status2, } = e; + let vec3 = (name2.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr1.add(8).cast::() = len3; + *ptr1.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + *ptr1.add(12).cast::() = (match status2 { true => 1, false => 0 }) as u8; + }, + None => { + { + *ptr1.add(0).cast::() = (0i32) as u8; + } + }, + };ptr1 + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn __post_return_test(arg0: *mut u8,) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + }, + } + } + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_bench_cabi(arg0: i32,arg1: i32,) -> *mut u8 {#[cfg(target_arch="wasm32")] + _rt::run_ctors_once();let result0 = T::bench(arg0 as u32, _rt::bool_lift(arg1 as u8)); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Some(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + let TestResult{ name:name2, status:status2, } = e; + let vec3 = (name2.into_bytes()).into_boxed_slice(); + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + ::core::mem::forget(vec3); + *ptr1.add(8).cast::() = len3; + *ptr1.add(4).cast::<*mut u8>() = ptr3.cast_mut(); + *ptr1.add(12).cast::() = (match status2 { true => 1, false => 0 }) as u8; + }, + None => { + { + *ptr1.add(0).cast::() = (0i32) as u8; + } + }, + };ptr1 +} +#[doc(hidden)] +#[allow(non_snake_case)] +pub unsafe fn __post_return_bench(arg0: *mut u8,) { + let l0 = i32::from(*arg0.add(0).cast::()); + match l0 { + 0 => (), + _ => { + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + _rt::cabi_dealloc(l1, l2, 1); + }, + } +} +pub trait Guest { + /// Run or List a WASM provided integration test. + /// + /// This is a single entrypoint in a wasm component, which can provide multiple tests. + /// Each test must be numbered from 0-n, with no gaps. + /// + /// test : u32 - The test number to run/list + /// run : bool - True = Run the test, False = Just list the test name. + /// + /// Returns: + /// None - There is no test at that test number. + /// test-result - The result of the test, if the test was not run, just returns the name and + /// status is True. Otherwise the test is executed, and the result is + /// the result of the test run. + fn test(test: u32,run: bool,) -> Option; + /// Run or List a WASM provided benchmark test. + /// + /// This is a single entrypoint in a wasm component, which can provide multiple benchmarks. + /// Each benchmark must be numbered from 0-n, with no gaps. + /// + /// Each time this function is called the bench function is run exactly once. + /// + /// test : u32 - The bench number to run/list + /// run : bool - True = Run the benchmark, False = Just list the test name. + /// + /// Returns: + /// None - There is no test at that test number. + /// test-result - The result of the test, if the test was not run, just returns the name and + /// status is True. Otherwise the test is executed, and the result is + /// the result of the test run. + fn bench(test: u32,run: bool,) -> Option; +} +#[doc(hidden)] + +macro_rules! __export_hermes_integration_test_event_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "hermes:integration-test/event#test"] + unsafe extern "C" fn export_test(arg0: i32,arg1: i32,) -> *mut u8 { + $($path_to_types)*::_export_test_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_hermes:integration-test/event#test"] + unsafe extern "C" fn _post_return_test(arg0: *mut u8,) { + $($path_to_types)*::__post_return_test::<$ty>(arg0) + } + #[export_name = "hermes:integration-test/event#bench"] + unsafe extern "C" fn export_bench(arg0: i32,arg1: i32,) -> *mut u8 { + $($path_to_types)*::_export_bench_cabi::<$ty>(arg0, arg1) + } + #[export_name = "cabi_post_hermes:integration-test/event#bench"] + unsafe extern "C" fn _post_return_bench(arg0: *mut u8,) { + $($path_to_types)*::__post_return_bench::<$ty>(arg0) + } + };); +} +#[doc(hidden)] +pub(crate) use __export_hermes_integration_test_event_cabi; +#[repr(align(4))] +struct _RetArea([::core::mem::MaybeUninit::; 16]); +static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 16]); + +} + +} +#[allow(dead_code)] +pub mod ipfs { + #[allow(dead_code, clippy::all)] + pub mod event { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type PubsubMessage = super::super::super::super::hermes::ipfs::api::PubsubMessage; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_on_topic_cabi(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: i32,arg5: *mut u8,arg6: usize,) -> i32 {#[cfg(target_arch="wasm32")] + _rt::run_ctors_once();let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let result3 = T::on_topic(super::super::super::super::hermes::ipfs::api::PubsubMessage{ + topic: _rt::string_lift(bytes0), + message: _rt::Vec::from_raw_parts(arg2.cast(), len1, len1), + publisher: match arg4 { + 0 => None, + 1 => { + let e = { + let len2 = arg6; + let bytes2 = _rt::Vec::from_raw_parts(arg5.cast(), len2, len2); + + _rt::string_lift(bytes2) + }; + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + }); + match result3 { true => 1, false => 0 } + } + pub trait Guest { + /// Triggers when a message is received on a topic. + fn on_topic(message: PubsubMessage,) -> bool; + } + #[doc(hidden)] + + macro_rules! __export_hermes_ipfs_event_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "hermes:ipfs/event#on-topic"] + unsafe extern "C" fn export_on_topic(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: i32,arg5: *mut u8,arg6: usize,) -> i32 { + $($path_to_types)*::_export_on_topic_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5, arg6) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_hermes_ipfs_event_cabi; + +} + +} +#[allow(dead_code)] +pub mod kv_store { + #[allow(dead_code, clippy::all)] + pub mod event { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type KvValues = super::super::super::super::hermes::kv_store::api::KvValues; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_kv_update_cabi(arg0: *mut u8,arg1: usize,arg2: i32,arg3: ::core::mem::MaybeUninit::,arg4: usize,) {#[cfg(target_arch="wasm32")] + _rt::run_ctors_once();let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + use super::super::super::super::hermes::kv_store::api::KvValues as V5; + let v5 = match arg2 { + 0 => { + let e5 = { + let len1 = arg4; + let bytes1 = _rt::Vec::from_raw_parts(arg3.as_ptr().cast::<*mut u8>().read().cast(), len1, len1); + + _rt::string_lift(bytes1) + }; + V5::KvString(e5) + } + 1 => { + let e5 = arg3.assume_init() as i64; + V5::KvS64(e5) + } + 2 => { + let e5 = arg3.assume_init() as i64 as u64; + V5::KvU64(e5) + } + 3 => { + let e5 = f64::from_bits(arg3.assume_init() as i64 as u64); + V5::KvF64(e5) + } + 4 => { + let e5 = { + let len2 = arg4; + + _rt::Vec::from_raw_parts(arg3.as_ptr().cast::<*mut u8>().read().cast(), len2, len2) + }; + V5::KvBstr(e5) + } + 5 => { + let e5 = { + let len3 = arg4; + + _rt::Vec::from_raw_parts(arg3.as_ptr().cast::<*mut u8>().read().cast(), len3, len3) + }; + V5::KvCbor(e5) + } + n => { + debug_assert_eq!(n, 6, "invalid enum discriminant"); + let e5 = { + let len4 = arg4; + let bytes4 = _rt::Vec::from_raw_parts(arg3.as_ptr().cast::<*mut u8>().read().cast(), len4, len4); + + _rt::string_lift(bytes4) + }; + V5::KvJson(e5) + } + }; + T::kv_update(_rt::string_lift(bytes0), v5); + } + pub trait Guest { + /// A Subscribed key has updated. + /// + /// This will only ever be called if the module has subscribed to updates using + /// `kv-subscribe` + /// + /// Returns: + /// Nothing. + fn kv_update(key: _rt::String,value: KvValues,); + } + #[doc(hidden)] + + macro_rules! __export_hermes_kv_store_event_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "hermes:kv-store/event#kv-update"] + unsafe extern "C" fn export_kv_update(arg0: *mut u8,arg1: usize,arg2: i32,arg3: ::core::mem::MaybeUninit::,arg4: usize,) { + $($path_to_types)*::_export_kv_update_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_hermes_kv_store_event_cabi; + +} + +} +} +#[allow(dead_code)] +pub mod wasi { + #[allow(dead_code)] + pub mod http { + #[allow(dead_code, clippy::all)] + pub mod incoming_handler { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type IncomingRequest = super::super::super::super::wasi::http::types::IncomingRequest; + pub type ResponseOutparam = super::super::super::super::wasi::http::types::ResponseOutparam; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_handle_cabi(arg0: i32,arg1: i32,) {#[cfg(target_arch="wasm32")] + _rt::run_ctors_once();T::handle(super::super::super::super::wasi::http::types::IncomingRequest::from_handle(arg0 as u32), super::super::super::super::wasi::http::types::ResponseOutparam::from_handle(arg1 as u32)); + } + pub trait Guest { + /// This function is invoked with an incoming HTTP Request, and a resource + /// `response-outparam` which provides the capability to reply with an HTTP + /// Response. The response is sent by calling the `response-outparam.set` + /// method, which allows execution to continue after the response has been + /// sent. This enables both streaming to the response body, and performing other + /// work. + /// + /// The implementor of this function must write a response to the + /// `response-outparam` before returning, or else the caller will respond + /// with an error on its behalf. + fn handle(request: IncomingRequest,response_out: ResponseOutparam,); + } + #[doc(hidden)] + + macro_rules! __export_wasi_http_incoming_handler_0_2_0_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "wasi:http/incoming-handler@0.2.0#handle"] + unsafe extern "C" fn export_handle(arg0: i32,arg1: i32,) { + $($path_to_types)*::_export_handle_cabi::<$ty>(arg0, arg1) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_wasi_http_incoming_handler_0_2_0_cabi; + + } + +} +} +} +mod _rt { + pub use alloc_crate::vec::Vec; + pub use alloc_crate::string::String; + pub unsafe fn string_lift(bytes: Vec) -> String { + if cfg!(debug_assertions) { + String::from_utf8(bytes).unwrap() + } else { + String::from_utf8_unchecked(bytes) + } + } + pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { + if size == 0 { + return; + } + let layout = alloc::Layout::from_size_align_unchecked(size, align); + alloc::dealloc(ptr, layout); + } + pub unsafe fn invalid_enum_discriminant() -> T { + if cfg!(debug_assertions) { + panic!("invalid enum discriminant") + } else { + core::hint::unreachable_unchecked() + } + } + + + use core::fmt; + use core::marker; + use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; + + /// A type which represents a component model resource, either imported or + /// exported into this component. + /// + /// This is a low-level wrapper which handles the lifetime of the resource + /// (namely this has a destructor). The `T` provided defines the component model + /// intrinsics that this wrapper uses. + /// + /// One of the chief purposes of this type is to provide `Deref` implementations + /// to access the underlying data when it is owned. + /// + /// This type is primarily used in generated code for exported and imported + /// resources. + #[repr(transparent)] + pub struct Resource { + // NB: This would ideally be `u32` but it is not. The fact that this has + // interior mutability is not exposed in the API of this type except for the + // `take_handle` method which is supposed to in theory be private. + // + // This represents, almost all the time, a valid handle value. When it's + // invalid it's stored as `u32::MAX`. + handle: AtomicU32, + _marker: marker::PhantomData, + } + + /// A trait which all wasm resources implement, namely providing the ability to + /// drop a resource. + /// + /// This generally is implemented by generated code, not user-facing code. + #[allow(clippy::missing_safety_doc)] + pub unsafe trait WasmResource { + /// Invokes the `[resource-drop]...` intrinsic. + unsafe fn drop(handle: u32); + } + + impl Resource { + #[doc(hidden)] + pub unsafe fn from_handle(handle: u32) -> Self { + debug_assert!(handle != u32::MAX); + Self { + handle: AtomicU32::new(handle), + _marker: marker::PhantomData, + } + } + + /// Takes ownership of the handle owned by `resource`. + /// + /// Note that this ideally would be `into_handle` taking `Resource` by + /// ownership. The code generator does not enable that in all situations, + /// unfortunately, so this is provided instead. + /// + /// Also note that `take_handle` is in theory only ever called on values + /// owned by a generated function. For example a generated function might + /// take `Resource` as an argument but then call `take_handle` on a + /// reference to that argument. In that sense the dynamic nature of + /// `take_handle` should only be exposed internally to generated code, not + /// to user code. + #[doc(hidden)] + pub fn take_handle(resource: &Resource) -> u32 { + resource.handle.swap(u32::MAX, Relaxed) + } + + #[doc(hidden)] + pub fn handle(resource: &Resource) -> u32 { + resource.handle.load(Relaxed) + } + } + + impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("handle", &self.handle) + .finish() + } + } + + impl Drop for Resource { + fn drop(&mut self) { + unsafe { + match self.handle.load(Relaxed) { + // If this handle was "taken" then don't do anything in the + // destructor. + u32::MAX => {} + + // ... but otherwise do actually destroy it with the imported + // component model intrinsic as defined through `T`. + other => T::drop(other), + } + } + } + } + + pub fn as_i64(t: T) -> i64 { + t.as_i64() + } + + pub trait AsI64 { + fn as_i64(self) -> i64; + } + + impl<'a, T: Copy + AsI64> AsI64 for &'a T { + fn as_i64(self) -> i64 { + (*self).as_i64() + } + } + + impl AsI64 for i64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + impl AsI64 for u64 { + #[inline] + fn as_i64(self) -> i64 { + self as i64 + } + } + + pub fn as_i32(t: T) -> i32 { + t.as_i32() + } + + pub trait AsI32 { + fn as_i32(self) -> i32; + } + + impl<'a, T: Copy + AsI32> AsI32 for &'a T { + fn as_i32(self) -> i32 { + (*self).as_i32() + } + } + + impl AsI32 for i32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u32 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u16 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for i8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for u8 { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for char { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + + impl AsI32 for usize { + #[inline] + fn as_i32(self) -> i32 { + self as i32 + } + } + 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 fn as_f64(t: T) -> f64 { + t.as_f64() + } + + pub trait AsF64 { + fn as_f64(self) -> f64; + } + + impl<'a, T: Copy + AsF64> AsF64 for &'a T { + fn as_f64(self) -> f64 { + (*self).as_f64() + } + } + + impl AsF64 for f64 { + #[inline] + fn as_f64(self) -> f64 { + self as f64 + } + } + + #[cfg(target_arch = "wasm32")] + pub fn run_ctors_once() { + wit_bindgen::rt::run_ctors_once(); + } + extern crate alloc as alloc_crate; +} + +/// Generates `#[no_mangle]` functions to export the specified type as the +/// root implementation of all generated traits. +/// +/// For more information see the documentation of `wit_bindgen::generate!`. +/// +/// ```rust +/// # macro_rules! export{ ($($t:tt)*) => (); } +/// # trait Guest {} +/// struct MyType; +/// +/// impl Guest for MyType { +/// // ... +/// } +/// +/// export!(MyType); +/// ``` +#[allow(unused_macros)] +#[doc(hidden)] + +macro_rules! __export_hermes_impl { + ($ty:ident) => (self::export!($ty with_types_in self);); + ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( + $($path_to_types_root)*::exports::wasi::http::incoming_handler::__export_wasi_http_incoming_handler_0_2_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::wasi::http::incoming_handler); + $($path_to_types_root)*::exports::hermes::cardano::event_on_block::__export_hermes_cardano_event_on_block_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::cardano::event_on_block); + $($path_to_types_root)*::exports::hermes::cardano::event_on_txn::__export_hermes_cardano_event_on_txn_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::cardano::event_on_txn); + $($path_to_types_root)*::exports::hermes::cardano::event_on_rollback::__export_hermes_cardano_event_on_rollback_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::cardano::event_on_rollback); + $($path_to_types_root)*::exports::hermes::cron::event::__export_hermes_cron_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::cron::event); + $($path_to_types_root)*::exports::hermes::init::event::__export_hermes_init_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::init::event); + $($path_to_types_root)*::exports::hermes::ipfs::event::__export_hermes_ipfs_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::ipfs::event); + $($path_to_types_root)*::exports::hermes::kv_store::event::__export_hermes_kv_store_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::kv_store::event); + $($path_to_types_root)*::exports::hermes::integration_test::event::__export_hermes_integration_test_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::integration_test::event); + $($path_to_types_root)*::exports::hermes::http_gateway::event::__export_hermes_http_gateway_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::http_gateway::event); + ) +} +#[doc(inline)] +pub(crate) use __export_hermes_impl as export; + +#[cfg(target_arch = "wasm32")] +#[link_section = "component-type:wit-bindgen:0.29.0:hermes:encoded world"] +#[doc(hidden)] +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 16171] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xae}\x01A\x02\x01Ai\x01\ +B\x0a\x01o\x02ss\x01p\0\x01@\0\0\x01\x04\0\x0fget-environment\x01\x02\x01ps\x01@\ +\0\0\x03\x04\0\x0dget-arguments\x01\x04\x01ks\x01@\0\0\x05\x04\0\x0binitial-cwd\x01\ +\x06\x03\x01\x1awasi:cli/environment@0.2.0\x05\0\x01B\x03\x01j\0\0\x01@\x01\x06s\ +tatus\0\x01\0\x04\0\x04exit\x01\x01\x03\x01\x13wasi:cli/exit@0.2.0\x05\x01\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\x02\x02\x03\0\x02\x05er\ +ror\x01B!\x02\x03\x02\x01\x03\x04\0\x05error\x03\0\0\x01i\x01\x01q\x02\x15last-o\ +peration-failed\x01\x02\0\x06closed\0\0\x04\0\x0cstream-error\x03\0\x03\x04\0\x0c\ +input-stream\x03\x01\x04\0\x0doutput-stream\x03\x01\x01h\x05\x01p}\x01j\x01\x08\x01\ +\x04\x01@\x02\x04self\x07\x03lenw\0\x09\x04\0\x19[method]input-stream.read\x01\x0a\ +\x04\0\"[method]input-stream.blocking-read\x01\x0a\x01j\x01w\x01\x04\x01@\x02\x04\ +self\x07\x03lenw\0\x0b\x04\0\x19[method]input-stream.skip\x01\x0c\x04\0\"[method\ +]input-stream.blocking-skip\x01\x0c\x01h\x06\x01@\x01\x04self\x0d\0\x0b\x04\0![m\ +ethod]output-stream.check-write\x01\x0e\x01j\0\x01\x04\x01@\x02\x04self\x0d\x08c\ +ontents\x08\0\x0f\x04\0\x1b[method]output-stream.write\x01\x10\x04\0.[method]out\ +put-stream.blocking-write-and-flush\x01\x10\x01@\x01\x04self\x0d\0\x0f\x04\0\x1b\ +[method]output-stream.flush\x01\x11\x04\0$[method]output-stream.blocking-flush\x01\ +\x11\x01@\x02\x04self\x0d\x03lenw\0\x0f\x04\0\"[method]output-stream.write-zeroe\ +s\x01\x12\x04\05[method]output-stream.blocking-write-zeroes-and-flush\x01\x12\x01\ +@\x03\x04self\x0d\x03src\x07\x03lenw\0\x0b\x04\0\x1c[method]output-stream.splice\ +\x01\x13\x04\0%[method]output-stream.blocking-splice\x01\x13\x03\x01\x15wasi:io/\ +streams@0.2.0\x05\x04\x02\x03\0\x03\x0cinput-stream\x01B\x05\x02\x03\x02\x01\x05\ +\x04\0\x0cinput-stream\x03\0\0\x01i\x01\x01@\0\0\x02\x04\0\x09get-stdin\x01\x03\x03\ +\x01\x14wasi:cli/stdin@0.2.0\x05\x06\x02\x03\0\x03\x0doutput-stream\x01B\x05\x02\ +\x03\x02\x01\x07\x04\0\x0doutput-stream\x03\0\0\x01i\x01\x01@\0\0\x02\x04\0\x0ag\ +et-stdout\x01\x03\x03\x01\x15wasi:cli/stdout@0.2.0\x05\x08\x01B\x05\x02\x03\x02\x01\ +\x07\x04\0\x0doutput-stream\x03\0\0\x01i\x01\x01@\0\0\x02\x04\0\x0aget-stderr\x01\ +\x03\x03\x01\x15wasi:cli/stderr@0.2.0\x05\x09\x01B\x08\x01w\x04\0\x07instant\x03\ +\0\0\x01w\x04\0\x08duration\x03\0\x02\x01@\0\0\x01\x04\0\x03now\x01\x04\x01@\0\0\ +\x03\x04\0\x0aresolution\x01\x05\x03\x01!wasi:clocks/monotonic-clock@0.2.0\x05\x0a\ +\x01B\x05\x01r\x02\x07secondsw\x0bnanosecondsy\x04\0\x08datetime\x03\0\0\x01@\0\0\ +\x01\x04\0\x03now\x01\x02\x04\0\x0aresolution\x01\x02\x03\x01\x1cwasi:clocks/wal\ +l-clock@0.2.0\x05\x0b\x02\x03\0\x03\x05error\x02\x03\0\x08\x08datetime\x01Br\x02\ +\x03\x02\x01\x05\x04\0\x0cinput-stream\x03\0\0\x02\x03\x02\x01\x07\x04\0\x0doutp\ +ut-stream\x03\0\x02\x02\x03\x02\x01\x0c\x04\0\x05error\x03\0\x04\x02\x03\x02\x01\ +\x0d\x04\0\x08datetime\x03\0\x06\x01w\x04\0\x08filesize\x03\0\x08\x01m\x08\x07un\ +known\x0cblock-device\x10character-device\x09directory\x04fifo\x0dsymbolic-link\x0c\ +regular-file\x06socket\x04\0\x0fdescriptor-type\x03\0\x0a\x01n\x06\x04read\x05wr\ +ite\x13file-integrity-sync\x13data-integrity-sync\x14requested-write-sync\x10mut\ +ate-directory\x04\0\x10descriptor-flags\x03\0\x0c\x01n\x01\x0esymlink-follow\x04\ +\0\x0apath-flags\x03\0\x0e\x01n\x04\x06create\x09directory\x09exclusive\x08trunc\ +ate\x04\0\x0aopen-flags\x03\0\x10\x01w\x04\0\x0alink-count\x03\0\x12\x01k\x07\x01\ +r\x06\x04type\x0b\x0alink-count\x13\x04size\x09\x15data-access-timestamp\x14\x1b\ +data-modification-timestamp\x14\x17status-change-timestamp\x14\x04\0\x0fdescript\ +or-stat\x03\0\x15\x01q\x03\x09no-change\0\0\x03now\0\0\x09timestamp\x01\x07\0\x04\ +\0\x0dnew-timestamp\x03\0\x17\x01r\x02\x04type\x0b\x04names\x04\0\x0fdirectory-e\ +ntry\x03\0\x19\x01m%\x06access\x0bwould-block\x07already\x0ebad-descriptor\x04bu\ +sy\x08deadlock\x05quota\x05exist\x0efile-too-large\x15illegal-byte-sequence\x0bi\ +n-progress\x0binterrupted\x07invalid\x02io\x0cis-directory\x04loop\x0etoo-many-l\ +inks\x0cmessage-size\x0dname-too-long\x09no-device\x08no-entry\x07no-lock\x13ins\ +ufficient-memory\x12insufficient-space\x0dnot-directory\x09not-empty\x0fnot-reco\ +verable\x0bunsupported\x06no-tty\x0eno-such-device\x08overflow\x0dnot-permitted\x04\ +pipe\x09read-only\x0cinvalid-seek\x0etext-file-busy\x0ccross-device\x04\0\x0aerr\ +or-code\x03\0\x1b\x01m\x06\x06normal\x0asequential\x06random\x09will-need\x09don\ +t-need\x08no-reuse\x04\0\x06advice\x03\0\x1d\x01r\x02\x05lowerw\x05upperw\x04\0\x13\ +metadata-hash-value\x03\0\x1f\x04\0\x0adescriptor\x03\x01\x04\0\x16directory-ent\ +ry-stream\x03\x01\x01h!\x01i\x01\x01j\x01$\x01\x1c\x01@\x02\x04self#\x06offset\x09\ +\0%\x04\0\"[method]descriptor.read-via-stream\x01&\x01i\x03\x01j\x01'\x01\x1c\x01\ +@\x02\x04self#\x06offset\x09\0(\x04\0#[method]descriptor.write-via-stream\x01)\x01\ +@\x01\x04self#\0(\x04\0$[method]descriptor.append-via-stream\x01*\x01j\0\x01\x1c\ +\x01@\x04\x04self#\x06offset\x09\x06length\x09\x06advice\x1e\0+\x04\0\x19[method\ +]descriptor.advise\x01,\x01@\x01\x04self#\0+\x04\0\x1c[method]descriptor.sync-da\ +ta\x01-\x01j\x01\x0d\x01\x1c\x01@\x01\x04self#\0.\x04\0\x1c[method]descriptor.ge\ +t-flags\x01/\x01j\x01\x0b\x01\x1c\x01@\x01\x04self#\00\x04\0\x1b[method]descript\ +or.get-type\x011\x01@\x02\x04self#\x04size\x09\0+\x04\0\x1b[method]descriptor.se\ +t-size\x012\x01@\x03\x04self#\x15data-access-timestamp\x18\x1bdata-modification-\ +timestamp\x18\0+\x04\0\x1c[method]descriptor.set-times\x013\x01p}\x01o\x024\x7f\x01\ +j\x015\x01\x1c\x01@\x03\x04self#\x06length\x09\x06offset\x09\06\x04\0\x17[method\ +]descriptor.read\x017\x01j\x01\x09\x01\x1c\x01@\x03\x04self#\x06buffer4\x06offse\ +t\x09\08\x04\0\x18[method]descriptor.write\x019\x01i\"\x01j\x01:\x01\x1c\x01@\x01\ +\x04self#\0;\x04\0![method]descriptor.read-directory\x01<\x04\0\x17[method]descr\ +iptor.sync\x01-\x01@\x02\x04self#\x04paths\0+\x04\0&[method]descriptor.create-di\ +rectory-at\x01=\x01j\x01\x16\x01\x1c\x01@\x01\x04self#\0>\x04\0\x17[method]descr\ +iptor.stat\x01?\x01@\x03\x04self#\x0apath-flags\x0f\x04paths\0>\x04\0\x1a[method\ +]descriptor.stat-at\x01@\x01@\x05\x04self#\x0apath-flags\x0f\x04paths\x15data-ac\ +cess-timestamp\x18\x1bdata-modification-timestamp\x18\0+\x04\0\x1f[method]descri\ +ptor.set-times-at\x01A\x01@\x05\x04self#\x0eold-path-flags\x0f\x08old-paths\x0en\ +ew-descriptor#\x08new-paths\0+\x04\0\x1a[method]descriptor.link-at\x01B\x01i!\x01\ +j\x01\xc3\0\x01\x1c\x01@\x05\x04self#\x0apath-flags\x0f\x04paths\x0aopen-flags\x11\ +\x05flags\x0d\0\xc4\0\x04\0\x1a[method]descriptor.open-at\x01E\x01j\x01s\x01\x1c\ +\x01@\x02\x04self#\x04paths\0\xc6\0\x04\0\x1e[method]descriptor.readlink-at\x01G\ +\x04\0&[method]descriptor.remove-directory-at\x01=\x01@\x04\x04self#\x08old-path\ +s\x0enew-descriptor#\x08new-paths\0+\x04\0\x1c[method]descriptor.rename-at\x01H\x01\ +@\x03\x04self#\x08old-paths\x08new-paths\0+\x04\0\x1d[method]descriptor.symlink-\ +at\x01I\x04\0![method]descriptor.unlink-file-at\x01=\x01@\x02\x04self#\x05other#\ +\0\x7f\x04\0![method]descriptor.is-same-object\x01J\x01j\x01\x20\x01\x1c\x01@\x01\ +\x04self#\0\xcb\0\x04\0\x20[method]descriptor.metadata-hash\x01L\x01@\x03\x04sel\ +f#\x0apath-flags\x0f\x04paths\0\xcb\0\x04\0#[method]descriptor.metadata-hash-at\x01\ +M\x01h\"\x01k\x1a\x01j\x01\xcf\0\x01\x1c\x01@\x01\x04self\xce\0\0\xd0\0\x04\03[m\ +ethod]directory-entry-stream.read-directory-entry\x01Q\x01h\x05\x01k\x1c\x01@\x01\ +\x03err\xd2\0\0\xd3\0\x04\0\x15filesystem-error-code\x01T\x03\x01\x1bwasi:filesy\ +stem/types@0.2.0\x05\x0e\x02\x03\0\x09\x0adescriptor\x01B\x07\x02\x03\x02\x01\x0f\ +\x04\0\x0adescriptor\x03\0\0\x01i\x01\x01o\x02\x02s\x01p\x03\x01@\0\0\x04\x04\0\x0f\ +get-directories\x01\x05\x03\x01\x1ewasi:filesystem/preopens@0.2.0\x05\x10\x01B\x05\ +\x01p}\x01@\x01\x03lenw\0\0\x04\0\x10get-random-bytes\x01\x01\x01@\0\0w\x04\0\x0e\ +get-random-u64\x01\x02\x03\x01\x18wasi:random/random@0.2.0\x05\x11\x01B\x05\x01p\ +}\x01@\x01\x03lenw\0\0\x04\0\x19get-insecure-random-bytes\x01\x01\x01@\0\0w\x04\0\ +\x17get-insecure-random-u64\x01\x02\x03\x01\x1awasi:random/insecure@0.2.0\x05\x12\ +\x01B\x03\x01o\x02ww\x01@\0\0\0\x04\0\x0dinsecure-seed\x01\x01\x03\x01\x1fwasi:r\ +andom/insecure-seed@0.2.0\x05\x13\x02\x03\0\x07\x08duration\x01B\xb9\x01\x02\x03\ +\x02\x01\x14\x04\0\x08duration\x03\0\0\x02\x03\x02\x01\x05\x04\0\x0cinput-stream\ +\x03\0\x02\x02\x03\x02\x01\x07\x04\0\x0doutput-stream\x03\0\x04\x02\x03\x02\x01\x03\ +\x04\0\x08io-error\x03\0\x06\x01q\x0a\x03get\0\0\x04head\0\0\x04post\0\0\x03put\0\ +\0\x06delete\0\0\x07connect\0\0\x07options\0\0\x05trace\0\0\x05patch\0\0\x05othe\ +r\x01s\0\x04\0\x06method\x03\0\x08\x01q\x03\x04HTTP\0\0\x05HTTPS\0\0\x05other\x01\ +s\0\x04\0\x06scheme\x03\0\x0a\x01ks\x01k{\x01r\x02\x05rcode\x0c\x09info-code\x0d\ +\x04\0\x11DNS-error-payload\x03\0\x0e\x01k}\x01r\x02\x08alert-id\x10\x0dalert-me\ +ssage\x0c\x04\0\x1aTLS-alert-received-payload\x03\0\x11\x01ky\x01r\x02\x0afield-\ +name\x0c\x0afield-size\x13\x04\0\x12field-size-payload\x03\0\x14\x01kw\x01k\x15\x01\ +q'\x0bDNS-timeout\0\0\x09DNS-error\x01\x0f\0\x15destination-not-found\0\0\x17des\ +tination-unavailable\0\0\x19destination-IP-prohibited\0\0\x19destination-IP-unro\ +utable\0\0\x12connection-refused\0\0\x15connection-terminated\0\0\x12connection-\ +timeout\0\0\x17connection-read-timeout\0\0\x18connection-write-timeout\0\0\x18co\ +nnection-limit-reached\0\0\x12TLS-protocol-error\0\0\x15TLS-certificate-error\0\0\ +\x12TLS-alert-received\x01\x12\0\x13HTTP-request-denied\0\0\x1cHTTP-request-leng\ +th-required\0\0\x16HTTP-request-body-size\x01\x16\0\x1bHTTP-request-method-inval\ +id\0\0\x18HTTP-request-URI-invalid\0\0\x19HTTP-request-URI-too-long\0\0\x20HTTP-\ +request-header-section-size\x01\x13\0\x18HTTP-request-header-size\x01\x17\0!HTTP\ +-request-trailer-section-size\x01\x13\0\x19HTTP-request-trailer-size\x01\x15\0\x18\ +HTTP-response-incomplete\0\0!HTTP-response-header-section-size\x01\x13\0\x19HTTP\ +-response-header-size\x01\x15\0\x17HTTP-response-body-size\x01\x16\0\"HTTP-respo\ +nse-trailer-section-size\x01\x13\0\x1aHTTP-response-trailer-size\x01\x15\0\x1dHT\ +TP-response-transfer-coding\x01\x0c\0\x1cHTTP-response-content-coding\x01\x0c\0\x15\ +HTTP-response-timeout\0\0\x13HTTP-upgrade-failed\0\0\x13HTTP-protocol-error\0\0\x0d\ +loop-detected\0\0\x13configuration-error\0\0\x0einternal-error\x01\x0c\0\x04\0\x0a\ +error-code\x03\0\x18\x01q\x03\x0einvalid-syntax\0\0\x09forbidden\0\0\x09immutabl\ +e\0\0\x04\0\x0cheader-error\x03\0\x1a\x01s\x04\0\x09field-key\x03\0\x1c\x01p}\x04\ +\0\x0bfield-value\x03\0\x1e\x04\0\x06fields\x03\x01\x04\0\x07headers\x03\0\x20\x04\ +\0\x08trailers\x03\0\x20\x04\0\x10incoming-request\x03\x01\x04\0\x10outgoing-req\ +uest\x03\x01\x04\0\x0frequest-options\x03\x01\x04\0\x11response-outparam\x03\x01\ +\x01{\x04\0\x0bstatus-code\x03\0'\x04\0\x11incoming-response\x03\x01\x04\0\x0din\ +coming-body\x03\x01\x04\0\x0ffuture-trailers\x03\x01\x04\0\x11outgoing-response\x03\ +\x01\x04\0\x0doutgoing-body\x03\x01\x04\0\x18future-incoming-response\x03\x01\x01\ +i\x20\x01@\0\0/\x04\0\x13[constructor]fields\x010\x01o\x02\x1d\x1f\x01p1\x01j\x01\ +/\x01\x1b\x01@\x01\x07entries2\03\x04\0\x18[static]fields.from-list\x014\x01h\x20\ +\x01p\x1f\x01@\x02\x04self5\x04name\x1d\06\x04\0\x12[method]fields.get\x017\x01@\ +\x02\x04self5\x04name\x1d\0\x7f\x04\0\x12[method]fields.has\x018\x01j\0\x01\x1b\x01\ +@\x03\x04self5\x04name\x1d\x05value6\09\x04\0\x12[method]fields.set\x01:\x01@\x02\ +\x04self5\x04name\x1d\09\x04\0\x15[method]fields.delete\x01;\x01@\x03\x04self5\x04\ +name\x1d\x05value\x1f\09\x04\0\x15[method]fields.append\x01<\x01@\x01\x04self5\0\ +2\x04\0\x16[method]fields.entries\x01=\x01@\x01\x04self5\0/\x04\0\x14[method]fie\ +lds.clone\x01>\x01h#\x01@\x01\x04self?\0\x09\x04\0\x1f[method]incoming-request.m\ +ethod\x01@\x01@\x01\x04self?\0\x0c\x04\0([method]incoming-request.path-with-quer\ +y\x01A\x01k\x0b\x01@\x01\x04self?\0\xc2\0\x04\0\x1f[method]incoming-request.sche\ +me\x01C\x04\0\"[method]incoming-request.authority\x01A\x01i!\x01@\x01\x04self?\0\ +\xc4\0\x04\0\x20[method]incoming-request.headers\x01E\x01i*\x01j\x01\xc6\0\0\x01\ +@\x01\x04self?\0\xc7\0\x04\0\x20[method]incoming-request.consume\x01H\x01i$\x01@\ +\x01\x07headers\xc4\0\0\xc9\0\x04\0\x1d[constructor]outgoing-request\x01J\x01h$\x01\ +i-\x01j\x01\xcc\0\0\x01@\x01\x04self\xcb\0\0\xcd\0\x04\0\x1d[method]outgoing-req\ +uest.body\x01N\x01@\x01\x04self\xcb\0\0\x09\x04\0\x1f[method]outgoing-request.me\ +thod\x01O\x01j\0\0\x01@\x02\x04self\xcb\0\x06method\x09\0\xd0\0\x04\0#[method]ou\ +tgoing-request.set-method\x01Q\x01@\x01\x04self\xcb\0\0\x0c\x04\0([method]outgoi\ +ng-request.path-with-query\x01R\x01@\x02\x04self\xcb\0\x0fpath-with-query\x0c\0\xd0\ +\0\x04\0,[method]outgoing-request.set-path-with-query\x01S\x01@\x01\x04self\xcb\0\ +\0\xc2\0\x04\0\x1f[method]outgoing-request.scheme\x01T\x01@\x02\x04self\xcb\0\x06\ +scheme\xc2\0\0\xd0\0\x04\0#[method]outgoing-request.set-scheme\x01U\x04\0\"[meth\ +od]outgoing-request.authority\x01R\x01@\x02\x04self\xcb\0\x09authority\x0c\0\xd0\ +\0\x04\0&[method]outgoing-request.set-authority\x01V\x01@\x01\x04self\xcb\0\0\xc4\ +\0\x04\0\x20[method]outgoing-request.headers\x01W\x01i%\x01@\0\0\xd8\0\x04\0\x1c\ +[constructor]request-options\x01Y\x01h%\x01k\x01\x01@\x01\x04self\xda\0\0\xdb\0\x04\ +\0'[method]request-options.connect-timeout\x01\\\x01@\x02\x04self\xda\0\x08durat\ +ion\xdb\0\0\xd0\0\x04\0+[method]request-options.set-connect-timeout\x01]\x04\0*[\ +method]request-options.first-byte-timeout\x01\\\x04\0.[method]request-options.se\ +t-first-byte-timeout\x01]\x04\0-[method]request-options.between-bytes-timeout\x01\ +\\\x04\01[method]request-options.set-between-bytes-timeout\x01]\x01i&\x01i,\x01j\ +\x01\xdf\0\x01\x19\x01@\x02\x05param\xde\0\x08response\xe0\0\x01\0\x04\0\x1d[sta\ +tic]response-outparam.set\x01a\x01h)\x01@\x01\x04self\xe2\0\0(\x04\0\x20[method]\ +incoming-response.status\x01c\x01@\x01\x04self\xe2\0\0\xc4\0\x04\0![method]incom\ +ing-response.headers\x01d\x01@\x01\x04self\xe2\0\0\xc7\0\x04\0![method]incoming-\ +response.consume\x01e\x01h*\x01i\x03\x01j\x01\xe7\0\0\x01@\x01\x04self\xe6\0\0\xe8\ +\0\x04\0\x1c[method]incoming-body.stream\x01i\x01i+\x01@\x01\x04this\xc6\0\0\xea\ +\0\x04\0\x1c[static]incoming-body.finish\x01k\x01h+\x01i\"\x01k\xed\0\x01j\x01\xee\ +\0\x01\x19\x01j\x01\xef\0\0\x01k\xf0\0\x01@\x01\x04self\xec\0\0\xf1\0\x04\0\x1b[\ +method]future-trailers.get\x01r\x01@\x01\x07headers\xc4\0\0\xdf\0\x04\0\x1e[cons\ +tructor]outgoing-response\x01s\x01h,\x01@\x01\x04self\xf4\0\0(\x04\0%[method]out\ +going-response.status-code\x01u\x01@\x02\x04self\xf4\0\x0bstatus-code(\0\xd0\0\x04\ +\0)[method]outgoing-response.set-status-code\x01v\x01@\x01\x04self\xf4\0\0\xc4\0\ +\x04\0![method]outgoing-response.headers\x01w\x01@\x01\x04self\xf4\0\0\xcd\0\x04\ +\0\x1e[method]outgoing-response.body\x01x\x01h-\x01i\x05\x01j\x01\xfa\0\0\x01@\x01\ +\x04self\xf9\0\0\xfb\0\x04\0\x1b[method]outgoing-body.write\x01|\x01j\0\x01\x19\x01\ +@\x02\x04this\xcc\0\x08trailers\xee\0\0\xfd\0\x04\0\x1c[static]outgoing-body.fin\ +ish\x01~\x01h.\x01i)\x01j\x01\x80\x01\x01\x19\x01j\x01\x81\x01\0\x01k\x82\x01\x01\ +@\x01\x04self\xff\0\0\x83\x01\x04\0$[method]future-incoming-response.get\x01\x84\ +\x01\x01h\x07\x01k\x19\x01@\x01\x03err\x85\x01\0\x86\x01\x04\0\x0fhttp-error-cod\ +e\x01\x87\x01\x03\x01\x15wasi:http/types@0.2.0\x05\x15\x02\x03\0\x0e\x10outgoing\ +-request\x02\x03\0\x0e\x0frequest-options\x02\x03\0\x0e\x18future-incoming-respo\ +nse\x02\x03\0\x0e\x0aerror-code\x01B\x0f\x02\x03\x02\x01\x16\x04\0\x10outgoing-r\ +equest\x03\0\0\x02\x03\x02\x01\x17\x04\0\x0frequest-options\x03\0\x02\x02\x03\x02\ +\x01\x18\x04\0\x18future-incoming-response\x03\0\x04\x02\x03\x02\x01\x19\x04\0\x0a\ +error-code\x03\0\x06\x01i\x01\x01i\x03\x01k\x09\x01i\x05\x01j\x01\x0b\x01\x07\x01\ +@\x02\x07request\x08\x07options\x0a\0\x0c\x04\0\x06handle\x01\x0d\x03\x01\x20was\ +i:http/outgoing-handler@0.2.0\x05\x1a\x01B\x08\x01p}\x04\0\x04bstr\x03\0\0\x01o\x02\ +ww\x04\0\x04b128\x03\0\x02\x01o\x04wwww\x04\0\x04b256\x03\0\x04\x01o\x08wwwwwwww\ +\x04\0\x04b512\x03\0\x06\x03\x01\x11hermes:binary/api\x05\x1b\x02\x03\0\x10\x04b\ +str\x01B\x03\x02\x03\x02\x01\x1c\x04\0\x04bstr\x03\0\0\x04\0\x04cbor\x03\0\x01\x03\ +\x01\x0fhermes:cbor/api\x05\x1d\x02\x03\0\x11\x04cbor\x01B$\x02\x03\x02\x01\x1c\x04\ +\0\x04bstr\x03\0\0\x02\x03\x02\x01\x1e\x04\0\x04cbor\x03\0\x02\x04\0\x0dcardano-\ +block\x03\0\x03\x04\0\x0bcardano-txn\x03\0\x03\x01m\x04\x07mainnet\x07preprod\x07\ +preview\x15local-test-blockchain\x04\0\x15cardano-blockchain-id\x03\0\x06\x01n\x03\ +\x03tip\x04node\x07mithril\x04\0\x09block-src\x03\0\x08\x01o\x02w\x01\x01q\x04\x07\ +genesis\0\0\x05point\x01\x0a\0\x03tip\0\0\x08continue\0\0\x04\0\x04slot\x03\0\x0b\ +\x01m\x02\x18blockchain-not-available\x0cinvalid-slot\x04\0\x0bfetch-error\x03\0\ +\x0d\x01m\x03\x18blockchain-not-available\x15malformed-transaction\x14post-txn-n\ +ot-allowed\x04\0\x09txn-error\x03\0\x0f\x01n\x04\x05block\x0btransaction\x08roll\ +back\x04stop\x04\0\x13unsubscribe-options\x03\0\x11\x01j\x01w\x01\x0e\x01@\x02\x03\ +net\x07\x06whence\x0c\0\x13\x04\0\x10subscribe-blocks\x01\x14\x01@\x02\x03net\x07\ +\x04opts\x12\x01\0\x04\0\x0bunsubscribe\x01\x15\x01@\x01\x03net\x07\x01\0\x04\0\x0d\ +subscribe-txn\x01\x16\x04\0\x12subscribe-rollback\x01\x16\x01j\x01\x04\x01\x0e\x01\ +@\x02\x03net\x07\x06whence\x0c\0\x17\x04\0\x0bfetch-block\x01\x18\x01p\x05\x01@\x01\ +\x05block\x04\0\x19\x04\0\x08get-txns\x01\x1a\x01j\0\x01\x10\x01@\x02\x03net\x07\ +\x03txn\x05\0\x1b\x04\0\x08post-txn\x01\x1c\x03\x01\x12hermes:cardano/api\x05\x1f\ +\x02\x03\0\x07\x07instant\x01B\x1a\x02\x03\x02\x01\x20\x04\0\x07instant\x03\0\0\x01\ +s\x04\0\x0ecron-event-tag\x03\0\x02\x01s\x04\0\x0acron-sched\x03\0\x04\x01r\x02\x04\ +when\x05\x03tag\x03\x04\0\x0bcron-tagged\x03\0\x06\x01o\x02}}\x01q\x03\x03all\0\0\ +\x02at\x01}\0\x05range\x01\x08\0\x04\0\x0ecron-component\x03\0\x09\x01p\x0a\x04\0\ +\x09cron-time\x03\0\x0b\x01@\x02\x05entry\x07\x09retrigger\x7f\0\x7f\x04\0\x03ad\ +d\x01\x0d\x01@\x02\x08duration\x01\x03tag\x03\0\x7f\x04\0\x05delay\x01\x0e\x01k\x03\ +\x01o\x02\x07\x7f\x01p\x10\x01@\x01\x03tag\x0f\0\x11\x04\0\x02ls\x01\x12\x01@\x01\ +\x05entry\x07\0\x7f\x04\0\x02rm\x01\x13\x01@\x05\x03dow\x0c\x05month\x0c\x03day\x0c\ +\x04hour\x0c\x06minute\x0c\0\x05\x04\0\x06mkcron\x01\x14\x03\x01\x0fhermes:cron/\ +api\x05!\x02\x03\0\x10\x04b256\x02\x03\0\x10\x04b512\x01B&\x02\x03\x02\x01\x1c\x04\ +\0\x04bstr\x03\0\0\x02\x03\x02\x01\"\x04\0\x04b256\x03\0\x02\x02\x03\x02\x01#\x04\ +\0\x04b512\x03\0\x04\x01m\x07\x0fprefix-too-long\x17invalid-mnemonic-length\x0ew\ +ord-not-found\x10invalid-mnemonic\x19invalid-derivational-path\x17generate-entro\ +py-failed\x14unsupported-language\x04\0\x05errno\x03\0\x06\x04\0\x19bip32-ed2551\ +9-private-key\x03\0\x03\x04\0\"bip32-ed25519-extended-private-key\x03\0\x05\x04\0\ +\x18bip32-ed25519-public-key\x03\0\x03\x04\0\x17bip32-ed25519-signature\x03\0\x05\ +\x01ps\x04\0\x0fmnemonic-phrase\x03\0\x0c\x01ps\x04\0\x0apassphrase\x03\0\x0e\x01\ +s\x04\0\x04path\x03\0\x10\x01ps\x04\0\x06prefix\x03\0\x12\x04\0\x0dbip32-ed25519\ +\x03\x01\x01k\x0f\x01i\x14\x01@\x02\x08mnemonic\x0d\x0apassphrase\x15\0\x16\x04\0\ +\x1a[constructor]bip32-ed25519\x01\x17\x01h\x14\x01@\x01\x04self\x18\0\x0a\x04\0\ +\x20[method]bip32-ed25519.public-key\x01\x19\x01@\x02\x04self\x18\x04data\x01\0\x0b\ +\x04\0\x1f[method]bip32-ed25519.sign-data\x01\x1a\x01@\x03\x04self\x18\x04data\x01\ +\x03sig\x0b\0\x7f\x04\0\x1f[method]bip32-ed25519.check-sig\x01\x1b\x01@\x02\x04s\ +elf\x18\x04path\x11\0\x16\x04\0\x1c[method]bip32-ed25519.derive\x01\x1c\x01ks\x01\ +j\x01\x0d\x01\x07\x01@\x03\x04size}\x06prefix\x13\x08language\x1d\0\x1e\x04\0\x11\ +generate-mnemonic\x01\x1f\x03\x01\x11hermes:crypto/api\x05$\x01B\x0f\x02\x03\x02\ +\x01\x1c\x04\0\x04bstr\x03\0\0\x01m\x05\x0bkey-too-big\x0chash-too-big\x0csalt-t\ +oo-big\x10personal-too-big\x1ainvalid-digest-byte-length\x04\0\x05errno\x03\0\x02\ +\x01k}\x01j\x01\x01\x01\x03\x01@\x02\x03buf\x01\x06outlen\x04\0\x05\x04\0\x07bla\ +ke2s\x01\x06\x01k\x01\x01@\x05\x03buf\x01\x06outlen\x04\x03key\x01\x04salt\x07\x08\ +personal\x07\0\x05\x04\0\x0ablake2smac\x01\x08\x04\0\x07blake2b\x01\x06\x04\0\x0a\ +blake2bmac\x01\x08\x01@\x03\x03buf\x01\x06outlen\x04\x03key\x07\0\x05\x04\0\x06b\ +lake3\x01\x09\x03\x01\x0fhermes:hash/api\x05%\x01B1\x01p}\x04\0\x07dht-key\x03\0\ +\0\x01p}\x04\0\x09dht-value\x03\0\x02\x01p}\x04\0\x09ipfs-file\x03\0\x04\x01s\x04\ +\0\x09ipfs-path\x03\0\x06\x01p}\x04\0\x0cmessage-data\x03\0\x08\x01p}\x04\0\x0am\ +essage-id\x03\0\x0a\x01s\x04\0\x07peer-id\x03\0\x0c\x01s\x04\0\x0cpubsub-topic\x03\ +\0\x0e\x01o\x02\x01\x03\x01o\x02\x0f\x09\x01q\x02\x03dht\x01\x10\0\x06pubsub\x01\ +\x11\0\x04\0\x0cipfs-content\x03\0\x12\x01k\x0d\x01r\x03\x05topic\x0f\x07message\ +\x09\x09publisher\x14\x04\0\x0epubsub-message\x03\0\x15\x01m\x0f\x0ddht-get-erro\ +r\x0ddht-put-error\x0efile-add-error\x0efile-get-error\x0efile-pin-error\x0binva\ +lid-cid\x0finvalid-dht-key\x11invalid-dht-value\x11invalid-ipfs-path\x0finvalid-\ +peer-id\x16invalid-pubsub-message\x13peer-eviction-error\x14pubsub-publish-error\ +\x16pubsub-subscribe-error\x13service-unavailable\x04\0\x05errno\x03\0\x17\x01j\x01\ +\x7f\x01\x18\x01@\x02\x03key\x01\x05value\x03\0\x19\x04\0\x07dht-put\x01\x1a\x01\ +j\x01\x03\x01\x18\x01@\x01\x03key\x01\0\x1b\x04\0\x07dht-get\x01\x1c\x01@\x01\x07\ +content\x13\0\x19\x04\0\x15ipfs-content-validate\x01\x1d\x01j\x01\x07\x01\x18\x01\ +@\x01\x08contents\x05\0\x1e\x04\0\x08file-add\x01\x1f\x01j\x01\x05\x01\x18\x01@\x01\ +\x04path\x07\0\x20\x04\0\x08file-get\x01!\x01@\x01\x04path\x07\0\x19\x04\0\x08fi\ +le-pin\x01\"\x04\0\x0afile-unpin\x01\"\x01@\x01\x04peer\x0d\0\x19\x04\0\x0apeer-\ +evict\x01#\x01j\x01\x0b\x01\x18\x01@\x02\x05topic\x0f\x07message\x09\0$\x04\0\x0e\ +pubsub-publish\x01%\x01@\x01\x05topic\x0f\0\x19\x04\0\x10pubsub-subscribe\x01&\x03\ +\x01\x0fhermes:ipfs/api\x05&\x01B\x02\x01s\x04\0\x04json\x03\0\0\x03\x01\x0fherm\ +es:json/api\x05'\x02\x03\0\x17\x04json\x01B\x16\x02\x03\x02\x01\x1c\x04\0\x04bst\ +r\x03\0\0\x02\x03\x02\x01\x1e\x04\0\x04cbor\x03\0\x02\x02\x03\x02\x01(\x04\0\x04\ +json\x03\0\x04\x01q\x07\x09kv-string\x01s\0\x06kv-s64\x01x\0\x06kv-u64\x01w\0\x06\ +kv-f64\x01u\0\x07kv-bstr\x01\x01\0\x07kv-cbor\x01\x03\0\x07kv-json\x01\x05\0\x04\ +\0\x09kv-values\x03\0\x06\x01k\x07\x01@\x02\x03keys\x05value\x08\x01\0\x04\0\x06\ +kv-set\x01\x09\x01@\x02\x03keys\x07default\x08\0\x08\x04\0\x0ekv-get-default\x01\ +\x0a\x01@\x01\x03keys\0\x08\x04\0\x06kv-get\x01\x0b\x01@\x02\x03keys\x05value\x08\ +\0\x08\x04\0\x0akv-get-set\x01\x0c\x04\0\x06kv-add\x01\x0c\x01@\x03\x03keys\x04t\ +est\x08\x05value\x08\0\x08\x04\0\x06kv-cas\x01\x0d\x04\0\x0ckv-subscribe\x01\x0b\ +\x04\0\x0ekv-unsubscribe\x01\x0b\x03\x01\x13hermes:kv-store/api\x05)\x01B\x12\x02\ +\x03\x02\x01\x0d\x04\0\x08datetime\x03\0\0\x01s\x04\0\x08timezone\x03\0\x02\x01r\ +\x09\x04yearw\x05month}\x03dow}\x03day}\x02hh}\x02mm}\x02ss}\x02nsy\x02tz\x03\x04\ +\0\x09localtime\x03\0\x04\x01m\x03\x11invalid-localtime\x10unknown-timezone\x11y\ +ear-out-of-range\x04\0\x05errno\x03\0\x06\x01k\x01\x01k\x03\x01j\x01\x05\x01\x07\ +\x01@\x02\x04when\x08\x02tz\x09\0\x0a\x04\0\x0dget-localtime\x01\x0b\x01@\x02\x04\ +time\x05\x02tz\x09\0\x0a\x04\0\x0dalt-localtime\x01\x0c\x01j\x01\x01\x01\x07\x01\ +@\x01\x04time\x05\0\x0d\x04\0\x0cget-datetime\x01\x0e\x03\x01\x14hermes:localtim\ +e/api\x05*\x01B\x09\x02\x03\x02\x01(\x04\0\x04json\x03\0\0\x01m\x05\x05debug\x05\ +trace\x04info\x04warn\x05error\x04\0\x05level\x03\0\x02\x01ks\x01ky\x01k\x01\x01\ +@\x08\x05level\x03\x04file\x04\x08function\x04\x04line\x05\x03col\x05\x03ctx\x04\ +\x03msgs\x04data\x06\x01\0\x04\0\x03log\x01\x07\x03\x01\x12hermes:logging/api\x05\ ++\x01B#\x01r\x02\x04codez\x07messages\x04\0\x0aerror-info\x03\0\0\x01q\x0b\x06sq\ +lite\x01z\0\x13converting-c-string\0\0\x18invalid-in-memory-config\0\0\x19invali\ +d-persistent-config\0\0+missing-database-name-for-persistent-config\0\0\x17faile\ +d-opening-database\0\0\x1cfailed-setting-database-size\0\0\x13unknown-column-typ\ +e\0\0\x18forbidden-pragma-command\0\0\x15returned-null-pointer\0\0\x12converting\ +-numeric\0\0\x04\0\x05errno\x03\0\x02\x01p}\x01q\x06\x04blob\x01\x04\0\x06double\ +\x01u\0\x05int32\x01z\0\x05int64\x01x\0\x04null\0\0\x04text\x01s\0\x04\0\x05valu\ +e\x03\0\x05\x04\0\x06sqlite\x03\x01\x04\0\x09statement\x03\x01\x01h\x07\x01j\0\x01\ +\x03\x01@\x01\x04self\x09\0\x0a\x04\0\x14[method]sqlite.close\x01\x0b\x01k\x01\x01\ +@\x01\x04self\x09\0\x0c\x04\0\x16[method]sqlite.errcode\x01\x0d\x01i\x08\x01j\x01\ +\x0e\x01\x03\x01@\x02\x04self\x09\x03sqls\0\x0f\x04\0\x16[method]sqlite.prepare\x01\ +\x10\x01@\x02\x04self\x09\x03sqls\0\x0a\x04\0\x16[method]sqlite.execute\x01\x11\x01\ +h\x08\x01@\x03\x04self\x12\x05indexy\x05value\x06\0\x0a\x04\0\x16[method]stateme\ +nt.bind\x01\x13\x01@\x01\x04self\x12\0\x0a\x04\0\x16[method]statement.step\x01\x14\ +\x01j\x01\x06\x01\x03\x01@\x02\x04self\x12\x05indexy\0\x15\x04\0\x18[method]stat\ +ement.column\x01\x16\x04\0\x1a[method]statement.finalize\x01\x14\x01i\x07\x01j\x01\ +\x17\x01\x03\x01@\x02\x08readonly\x7f\x06memory\x7f\0\x18\x04\0\x04open\x01\x19\x03\ +\x01\x11hermes:sqlite/api\x05,\x01B\x04\x01y\x04\0\x07payload\x03\0\0\x01@\x01\x01\ +p\x01\0\x7f\x04\0\x04send\x01\x02\x03\x01\x17hermes:http-request/api\x05-\x02\x03\ +\0\x0e\x10incoming-request\x02\x03\0\x0e\x11response-outparam\x01B\x08\x02\x03\x02\ +\x01.\x04\0\x10incoming-request\x03\0\0\x02\x03\x02\x01/\x04\0\x11response-outpa\ +ram\x03\0\x02\x01i\x01\x01i\x03\x01@\x02\x07request\x04\x0cresponse-out\x05\x01\0\ +\x04\0\x06handle\x01\x06\x04\x01\x20wasi:http/incoming-handler@0.2.0\x050\x02\x03\ +\0\x12\x15cardano-blockchain-id\x02\x03\0\x12\x0dcardano-block\x02\x03\0\x12\x09\ +block-src\x01B\x08\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\x02\x03\ +\x02\x012\x04\0\x0dcardano-block\x03\0\x02\x02\x03\x02\x013\x04\0\x09block-src\x03\ +\0\x04\x01@\x03\x0ablockchain\x01\x05block\x03\x06source\x05\x01\0\x04\0\x10on-c\ +ardano-block\x01\x06\x04\x01\x1dhermes:cardano/event-on-block\x054\x02\x03\0\x12\ +\x0bcardano-txn\x01B\x06\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\ +\x02\x03\x02\x015\x04\0\x0bcardano-txn\x03\0\x02\x01@\x04\x0ablockchain\x01\x04s\ +lotw\x09txn-indexy\x03txn\x03\x01\0\x04\0\x0eon-cardano-txn\x01\x04\x04\x01\x1bh\ +ermes:cardano/event-on-txn\x056\x01B\x04\x02\x03\x02\x011\x04\0\x15cardano-block\ +chain-id\x03\0\0\x01@\x02\x0ablockchain\x01\x04slotw\x01\0\x04\0\x13on-cardano-r\ +ollback\x01\x02\x04\x01\x20hermes:cardano/event-on-rollback\x057\x02\x03\0\x13\x0e\ +cron-event-tag\x02\x03\0\x13\x0bcron-tagged\x01B\x06\x02\x03\x02\x018\x04\0\x0ec\ +ron-event-tag\x03\0\0\x02\x03\x02\x019\x04\0\x0bcron-tagged\x03\0\x02\x01@\x02\x05\ +event\x03\x04last\x7f\0\x7f\x04\0\x07on-cron\x01\x04\x04\x01\x11hermes:cron/even\ +t\x05:\x01B\x02\x01@\0\0\x7f\x04\0\x04init\x01\0\x04\x01\x11hermes:init/event\x05\ +;\x02\x03\0\x16\x0epubsub-message\x01B\x04\x02\x03\x02\x01<\x04\0\x0epubsub-mess\ +age\x03\0\0\x01@\x01\x07message\x01\0\x7f\x04\0\x08on-topic\x01\x02\x04\x01\x11h\ +ermes:ipfs/event\x05=\x02\x03\0\x18\x09kv-values\x01B\x04\x02\x03\x02\x01>\x04\0\ +\x09kv-values\x03\0\0\x01@\x02\x03keys\x05value\x01\x01\0\x04\0\x09kv-update\x01\ +\x02\x04\x01\x15hermes:kv-store/event\x05?\x01B\x06\x01r\x02\x04names\x06status\x7f\ +\x04\0\x0btest-result\x03\0\0\x01k\x01\x01@\x02\x04testy\x03run\x7f\0\x02\x04\0\x04\ +test\x01\x03\x04\0\x05bench\x01\x03\x04\x01\x1dhermes:integration-test/event\x05\ +@\x01B\x0c\x02\x03\x02\x01\x1c\x04\0\x04bstr\x03\0\0\x01ps\x01o\x02s\x02\x04\0\x06\ +header\x03\0\x03\x01p\x04\x04\0\x07headers\x03\0\x05\x01r\x03\x04code{\x07header\ +s\x06\x04body\x01\x04\0\x0dhttp-response\x03\0\x07\x01k\x08\x01@\x04\x04body\x01\ +\x07headers\x06\x04paths\x06methods\0\x09\x04\0\x05reply\x01\x0a\x04\x01\x19herm\ +es:http-gateway/event\x05A\x04\x01\x12hermes:wasi/hermes\x04\0\x0b\x0c\x01\0\x06\ +hermes\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.215\ +.0\x10wit-bindgen-rust\x060.29.0"; + +#[inline(never)] +#[doc(hidden)] +#[cfg(target_arch = "wasm32")] +pub fn __link_custom_section_describing_imports() { + wit_bindgen::rt::maybe_link_cabi_realloc(); +} + diff --git a/wasm/wasi/wit/deps/hermes-http-request/api.wit b/wasm/wasi/wit/deps/hermes-http-request/api.wit new file mode 100644 index 0000000000..cd3beb30e7 --- /dev/null +++ b/wasm/wasi/wit/deps/hermes-http-request/api.wit @@ -0,0 +1,13 @@ +/// # Http-request API + +/// Http request interface +interface api { + type payload = u32; + + send: func(p: payload) -> bool; +} + +/// World just for the Hermes Http request extension. +world http-request-api { + import api; +} diff --git a/wasm/wasi/wit/deps/hermes-http-request/world.wit b/wasm/wasi/wit/deps/hermes-http-request/world.wit new file mode 100644 index 0000000000..7acb990344 --- /dev/null +++ b/wasm/wasi/wit/deps/hermes-http-request/world.wit @@ -0,0 +1,5 @@ +package hermes:http-request; + +world all { + import api; +} diff --git a/wasm/wasi/wit/hermes.wit b/wasm/wasi/wit/hermes.wit index c986353e1a..381877aa27 100644 --- a/wasm/wasi/wit/hermes.wit +++ b/wasm/wasi/wit/hermes.wit @@ -27,4 +27,5 @@ world hermes { include hermes:sqlite/all; include hermes:integration-test/all; include hermes:http-gateway/all; + include hermes:http-request/all; } From 5e4f099a827d77b910dc22b723f540505fcfc507 Mon Sep 17 00:00:00 2001 From: cong-or Date: Thu, 3 Jul 2025 09:05:34 +0100 Subject: [PATCH 02/45] test(mechanics): debugging --- hermes/bin/src/cli/run.rs | 12 ++++++++++-- hermes/bin/src/event/queue.rs | 11 +++++++++++ hermes/bin/src/reactor.rs | 11 +++++++++++ .../bin/src/runtime_extensions/hermes/init/event.rs | 3 +++ hermes/bin/src/runtime_extensions/hermes/init/mod.rs | 3 +++ 5 files changed, 38 insertions(+), 2 deletions(-) diff --git a/hermes/bin/src/cli/run.rs b/hermes/bin/src/cli/run.rs index 0ea1302bcf..a36b1e59e3 100644 --- a/hermes/bin/src/cli/run.rs +++ b/hermes/bin/src/cli/run.rs @@ -1,6 +1,6 @@ //! Run cli command -use std::path::PathBuf; +use std::{path::PathBuf, time::Duration}; use clap::Args; use console::Emoji; @@ -55,8 +55,16 @@ impl Run { Emoji::new("🛠️", ""), app.name() ); - reactor::load_app(app)?; + + match reactor::load_app(app) { + Ok(r) => r, + Err(err) => println!("reactor loading err {err}"), + }; + println!("finished loading app"); std::thread::yield_now(); + println!("yielded"); + println!("sleeping for 4 seconds"); + std::thread::sleep(Duration::from_secs(4)); Ok(()) } diff --git a/hermes/bin/src/event/queue.rs b/hermes/bin/src/event/queue.rs index 284acf6cc0..72bfd21dda 100644 --- a/hermes/bin/src/event/queue.rs +++ b/hermes/bin/src/event/queue.rs @@ -40,14 +40,19 @@ struct HermesEventQueue { /// /// # Errors: /// - `AlreadyInitializedError` +#[allow(unreachable_code)] pub(crate) fn init() -> anyhow::Result<()> { + println!("entering init queue"); let (sender, receiver) = std::sync::mpsc::channel(); EVENT_QUEUE_INSTANCE .set(HermesEventQueue { sender }) .map_err(|_| AlreadyInitializedError)?; + println!("event queue instance set"); + thread::spawn(move || { + println!("spawning event thread"); event_execution_loop(receiver); }); Ok(()) @@ -93,6 +98,7 @@ fn targeted_module_event_execution(target_app_name: &ApplicationName, event: &He /// Executes provided Hermes event filtering by target app. fn targeted_app_event_execution(event: &HermesEvent) { + println!("entering app event execution"); match event.target_app() { TargetApp::All => { if let Ok(target_apps) = reactor::get_all_app_names() { @@ -112,6 +118,11 @@ fn targeted_app_event_execution(event: &HermesEvent) { /// Executes Hermes events from the provided receiver . fn event_execution_loop(receiver: Receiver) { for event in receiver { + println!("even target app: {:?}", event.target_app); + println!("even target module: {:?}", event.target_module); + targeted_app_event_execution(&event); } + + println!("finished execution loop!!"); } diff --git a/hermes/bin/src/reactor.rs b/hermes/bin/src/reactor.rs index f9a56a5791..753c025b35 100644 --- a/hermes/bin/src/reactor.rs +++ b/hermes/bin/src/reactor.rs @@ -32,25 +32,36 @@ struct Reactor { /// Initialize Hermes Reactor. /// Setup and runs all necessary services. pub(crate) fn init() -> anyhow::Result<()> { + println!("entering init ok"); event::queue::init()?; + println!("init called ok"); + REACTOR_STATE .set(Reactor { apps: DashMap::new(), }) .map_err(|_| AlreadyInitializedError)?; + println!("reactor state set ok"); + Ok(()) } /// Load Hermes application into the Hermes Reactor. pub(crate) fn load_app(app: Application) -> anyhow::Result<()> { + println!("entering load app"); + let reactor = REACTOR_STATE.get().ok_or(NotInitializedError)?; + println!("got reactor state ok"); + let app_name = app.name().clone(); reactor.apps.insert(app_name.clone(), app); init::emit_init_event(app_name)?; + + println!("emit init event sent!"); Ok(()) } diff --git a/hermes/bin/src/runtime_extensions/hermes/init/event.rs b/hermes/bin/src/runtime_extensions/hermes/init/event.rs index 1173790ac6..cdbcd6698b 100644 --- a/hermes/bin/src/runtime_extensions/hermes/init/event.rs +++ b/hermes/bin/src/runtime_extensions/hermes/init/event.rs @@ -10,7 +10,10 @@ impl HermesEventPayload for InitEvent { "init" } + #[allow(unreachable_code)] fn execute(&self, module: &mut crate::wasm::module::ModuleInstance) -> anyhow::Result<()> { + println!("executing init event"); + let _res = module .instance .hermes_init_event() diff --git a/hermes/bin/src/runtime_extensions/hermes/init/mod.rs b/hermes/bin/src/runtime_extensions/hermes/init/mod.rs index a7f29884fb..e9379b4703 100644 --- a/hermes/bin/src/runtime_extensions/hermes/init/mod.rs +++ b/hermes/bin/src/runtime_extensions/hermes/init/mod.rs @@ -18,6 +18,9 @@ pub(crate) fn emit_init_event(target_app: ApplicationName) -> anyhow::Result<()> TargetApp::List(vec![target_app]), TargetModule::All, ); + + println!("sending init event"); hermes_event::queue::send(init_event)?; + println!("event has been sent!"); Ok(()) } From 4c32844ac40d90906f2140abeb5b7823ba2eff65 Mon Sep 17 00:00:00 2001 From: cong-or Date: Thu, 3 Jul 2025 09:24:34 +0100 Subject: [PATCH 03/45] test(mechanics): debugging --- hermes/bin/src/cli/run.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hermes/bin/src/cli/run.rs b/hermes/bin/src/cli/run.rs index a36b1e59e3..0da11c8db9 100644 --- a/hermes/bin/src/cli/run.rs +++ b/hermes/bin/src/cli/run.rs @@ -31,6 +31,7 @@ pub(crate) struct Run { } impl Run { + #[allow(unreachable_code)] /// Run the hermes application pub(crate) fn exec(self) -> anyhow::Result<()> { for cert_path in self.certificates { @@ -66,6 +67,8 @@ impl Run { println!("sleeping for 4 seconds"); std::thread::sleep(Duration::from_secs(4)); + loop {} + Ok(()) } } From 94905f962c25a0b9785efbead31a8ef953013312 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 4 Jul 2025 09:07:26 +0200 Subject: [PATCH 04/45] Wip --- hermes/schemas/example/hermes_app_metadata.json | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/hermes/schemas/example/hermes_app_metadata.json b/hermes/schemas/example/hermes_app_metadata.json index 15dd1bb4bf..ca57f19c6c 100644 --- a/hermes/schemas/example/hermes_app_metadata.json +++ b/hermes/schemas/example/hermes_app_metadata.json @@ -3,7 +3,6 @@ "name": "Athena - Project Catalyst Voting", "version": "V2.7.3", "description": "Project Catalyst Innovation Platform", - "about": "About Project Catalyst, long form.\nMulti line.", "src": [ "https://github.com/input-output-hk/hermes", "https://github.com/input-output-hk/catalyst-voices" @@ -34,20 +33,5 @@ "name": "IOG Singapore.", "contact": "Contact details.", "payment": "wallet address" - }, - "resources": { - "file-storage": { - "minimum": 100, - "requested": 300, - "maximum": 1024 - }, - "sqlite-db": { - "minimum": 1024, - "requested": 4096, - "maximum": 32768 - } - }, - "permissions": { - "admin": true } } \ No newline at end of file From 7d800d9d4c2b0ba2e3cfe84d541505eea3829eff Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 4 Jul 2025 09:57:14 +0200 Subject: [PATCH 05/45] Send request --- hermes/bin/Cargo.toml | 1 + .../hermes/http_request/host.rs | 66 ++++++++++++++++++- .../hermes/http_request/mod.rs | 9 ++- .../wasi/wit/deps/hermes-http-request/api.wit | 13 +++- 4 files changed, 84 insertions(+), 5 deletions(-) diff --git a/hermes/bin/Cargo.toml b/hermes/bin/Cargo.toml index a03813142b..19b888a150 100644 --- a/hermes/bin/Cargo.toml +++ b/hermes/bin/Cargo.toml @@ -84,6 +84,7 @@ coset = "0.3.8" rust-ipfs = "0.14.1" dirs = "6.0.0" regex = "1.11.0" +reqwest = "0.12.22" [build-dependencies] build-info-build = "0.0.40" diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs index 6fc28065ad..3d672a66a8 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs @@ -5,8 +5,70 @@ use crate::{ runtime_extensions::bindings::hermes::http_request::api::{Host, Payload}, }; +fn http_request(payload: Payload) -> String { + let body_str = String::from_utf8(payload.body).unwrap(); + let request_line = body_str.lines().next().ok_or("Empty HTTP body").unwrap(); + + let parts: Vec<&str> = request_line.split_whitespace().collect(); + if parts.len() < 2 { + tracing::error!("E1"); + } + let path = parts[1]; + + let scheme = if payload.host_uri.starts_with("https") { + "https" + } else { + "http" + }; + let domain = payload + .host_uri + .trim_start_matches("http://") + .trim_start_matches("https://"); + + let url = format!("{}://{}:{}{}", scheme, domain, payload.port, path); + tracing::error!("Full URL: {}", url); + + let client = reqwest::blocking::Client::new(); + let response = if request_line.starts_with("POST") { + let body_content = body_str.split("\r\n\r\n").last().unwrap_or(""); + client + .post(&url) + .body(body_content.to_string()) + .send() + .unwrap() + } else { + client.get(&url).send().unwrap() + }; + + response + .text() + .unwrap_or_else(|_| "Failed to read response".to_string()) +} + impl Host for HermesRuntimeContext { - fn send(&mut self, p: Payload) -> wasmtime::Result { - todo!() + fn send(&mut self, payload: Payload) -> wasmtime::Result { + tracing::error!("Sending payload: {payload:?}"); + + + let res = http_request(payload); + tracing::error!("POST Response: {res}"); + + /* + let get_body = b"\ + GET /get?param1=value1 HTTP/1.1\r\n\ + Host: httpbin.org\r\n\ + \r\n"; + + let get_payload = Payload { + host_uri: "http://httpbin.org".to_string(), + port: 80, + body: get_body.to_vec(), + request_id: Some("req-get".to_string()), + }; + let res = http_request(get_payload); + tracing::error!("GET Response: {res}"); + */ + + Ok(true) } } diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs index 0ae8e7b9d2..9a1fd5fc1d 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs @@ -3,8 +3,8 @@ #![allow(unused)] #![allow(dead_code)] -mod tokio_runtime_task; mod host; +mod tokio_runtime_task; struct State { tokio_rt_handle: tokio_runtime_task::Handle, @@ -19,7 +19,12 @@ static STATE: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { pub(crate) fn new_context(_ctx: &crate::runtime_context::HermesRuntimeContext) {} -type Payload = u32; +pub struct Payload { + pub host_uri: String, + pub port: u16, + pub body: Vec, + pub request_id: Option, +} type Error = u32; diff --git a/wasm/wasi/wit/deps/hermes-http-request/api.wit b/wasm/wasi/wit/deps/hermes-http-request/api.wit index cd3beb30e7..80201e3539 100644 --- a/wasm/wasi/wit/deps/hermes-http-request/api.wit +++ b/wasm/wasi/wit/deps/hermes-http-request/api.wit @@ -2,8 +2,19 @@ /// Http request interface interface api { - type payload = u32; + // HTTP request payload (caller manages full body formatting) + record payload { + /// Host URI (scheme + domain, no path), e.g., "http://example.com" + host-uri: string, + /// Port (e.g., 80 for HTTP, 443 for HTTPS) + port: u16, + /// Raw HTTP request (including method, path, headers, and body) + body: list, + /// Optional request identifier for tracking + request-id: option, + } + /// Send an HTTP request. send: func(p: payload) -> bool; } From d424c983ceba12831d3a56e459b4b9aeffe9452b Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Mon, 7 Jul 2025 15:11:25 +0200 Subject: [PATCH 06/45] wip: decoupled request and response --- .../hermes/http_request/event.rs | 20 +++ .../hermes/http_request/host.rs | 108 +++++------- .../hermes/http_request/mod.rs | 27 +-- .../hermes/http_request/tokio_runtime_task.rs | 127 ++++++++++++-- wasm/wasi/hermes_bindings.rs | 160 +++++++++++++----- .../wit/deps/hermes-http-request/event.wit | 7 + .../wit/deps/hermes-http-request/world.wit | 2 + 7 files changed, 316 insertions(+), 135 deletions(-) create mode 100644 hermes/bin/src/runtime_extensions/hermes/http_request/event.rs create mode 100644 wasm/wasi/wit/deps/hermes-http-request/event.wit diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/event.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/event.rs new file mode 100644 index 0000000000..bb957c50a5 --- /dev/null +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/event.rs @@ -0,0 +1,20 @@ +use crate::event::HermesEventPayload; + +pub(super) struct OnHttpResponseEvent { + pub(super) request_id: String, + pub(super) response: String, +} + +impl HermesEventPayload for OnHttpResponseEvent { + fn event_name(&self) -> &'static str { + "on-http-response" + } + + fn execute(&self, module: &mut crate::wasm::module::ModuleInstance) -> anyhow::Result<()> { + module + .instance + .hermes_http_request_event_on_http_response() + .call_on_http_response(&mut module.store, &self.request_id, &self.response)?; + Ok(()) + } +} diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs index 3d672a66a8..47d4577946 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs @@ -2,72 +2,58 @@ use crate::{ runtime_context::HermesRuntimeContext, - runtime_extensions::bindings::hermes::http_request::api::{Host, Payload}, + runtime_extensions::{ + bindings::hermes::http_request::api::{Host, Payload}, + hermes::http_request::{tokio_runtime_task::{parse_payload, ParsedPayload}, STATE}, + }, }; -fn http_request(payload: Payload) -> String { - let body_str = String::from_utf8(payload.body).unwrap(); - let request_line = body_str.lines().next().ok_or("Empty HTTP body").unwrap(); - - let parts: Vec<&str> = request_line.split_whitespace().collect(); - if parts.len() < 2 { - tracing::error!("E1"); - } - let path = parts[1]; - - let scheme = if payload.host_uri.starts_with("https") { - "https" - } else { - "http" - }; - let domain = payload - .host_uri - .trim_start_matches("http://") - .trim_start_matches("https://"); - - let url = format!("{}://{}:{}{}", scheme, domain, payload.port, path); - tracing::error!("Full URL: {}", url); - - let client = reqwest::blocking::Client::new(); - let response = if request_line.starts_with("POST") { - let body_content = body_str.split("\r\n\r\n").last().unwrap_or(""); - client - .post(&url) - .body(body_content.to_string()) - .send() - .unwrap() - } else { - client.get(&url).send().unwrap() - }; - - response - .text() - .unwrap_or_else(|_| "Failed to read response".to_string()) -} +// fn http_request(payload: Payload) -> String { +// let ParsedPayload { +// body_str, +// request_line, +// url, +// } = parse_payload(payload); + +// let client = reqwest::blocking::Client::new(); +// let response = if request_line.starts_with("POST") { +// let body_content = body_str.split("\r\n\r\n").last().unwrap_or(""); +// client +// .post(&url) +// .body(body_content.to_string()) +// .send() +// .unwrap() +// } else { +// client.get(&url).send().unwrap() +// }; + +// response +// .text() +// .unwrap_or_else(|_| "Failed to read response".to_string()) +// } impl Host for HermesRuntimeContext { fn send(&mut self, payload: Payload) -> wasmtime::Result { - tracing::error!("Sending payload: {payload:?}"); - - - let res = http_request(payload); - tracing::error!("POST Response: {res}"); - - /* - let get_body = b"\ - GET /get?param1=value1 HTTP/1.1\r\n\ - Host: httpbin.org\r\n\ - \r\n"; - - let get_payload = Payload { - host_uri: "http://httpbin.org".to_string(), - port: 80, - body: get_body.to_vec(), - request_id: Some("req-get".to_string()), - }; - let res = http_request(get_payload); - tracing::error!("GET Response: {res}"); - */ + STATE.tokio_rt_handle.send(payload).unwrap(); + + // tracing::error!("Sending payload: {payload:?}"); + + // let res = http_request(payload); + // tracing::error!("POST Response: {res}"); + + // let get_body = b"\ + // GET /get?param1=value1 HTTP/1.1\r\n\ + // Host: httpbin.org\r\n\ + // \r\n"; + // + // let get_payload = Payload { + // host_uri: "http://httpbin.org".to_string(), + // port: 80, + // body: get_body.to_vec(), + // request_id: Some("req-get".to_string()), + // }; + // let res = http_request(get_payload); + // tracing::error!("GET Response: {res}"); Ok(true) } diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs index 9a1fd5fc1d..484eb226b2 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs @@ -3,11 +3,12 @@ #![allow(unused)] #![allow(dead_code)] +mod event; mod host; mod tokio_runtime_task; struct State { - tokio_rt_handle: tokio_runtime_task::Handle, + pub tokio_rt_handle: tokio_runtime_task::TokioTaskHandle, } /// Http Request extension internal state. @@ -19,28 +20,16 @@ static STATE: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { pub(crate) fn new_context(_ctx: &crate::runtime_context::HermesRuntimeContext) {} -pub struct Payload { - pub host_uri: String, - pub port: u16, - pub body: Vec, - pub request_id: Option, -} - type Error = u32; -/// Send an Http Request -pub(super) fn send(payload: Payload) -> Result { - STATE.tokio_rt_handle.send(payload) -} - #[cfg(test)] mod test { - use crate::runtime_extensions::hermes::http_request::send; + // use crate::runtime_extensions::hermes::http_request::send; - #[test] - fn sending_works() { - let result = send(24).unwrap(); + // #[test] + // fn sending_works() { + // let result = send(24).unwrap(); - assert_eq!(result, true); - } + // assert_eq!(result, true); + // } } diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 5bcfd778bb..00cf6bc527 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -1,35 +1,124 @@ +use tokio::sync::{mpsc, oneshot}; use tracing::{error, trace}; +use thiserror::Error; -enum Command { - Send { payload: super::Payload }, +use crate::{event::{HermesEvent, HermesEventPayload, TargetApp, TargetModule}, runtime_extensions::bindings::hermes::http_request::api::Payload}; + +pub enum Command { + Send { payload: Payload, send_result_sender: oneshot::Sender }, } type CommandSender = tokio::sync::mpsc::Sender; type CommandReceiver = tokio::sync::mpsc::Receiver; -pub struct Handle { +pub struct TokioTaskHandle { cmd_tx: CommandSender, } -impl Handle { - pub(super) fn send(&self, payload: super::Payload) -> Result { - self.cmd_tx - .blocking_send(Command::Send { payload }) - .map_err(|_| 0u32)?; +#[derive(Error, Debug)] +pub enum RequestSendingError { + #[error("Failed to send command via channel: {0}")] + ChannelSend(#[from] mpsc::error::SendError), + #[error("Failed to receive command result via channel: {0}")] + ResponseReceive(#[from] oneshot::error::RecvError), +} - // TODO: Proper return type - Ok(true) +impl TokioTaskHandle { + /// Sends a command to the Tokio runtime task. + pub fn send( + &self, payload: Payload, + ) -> Result { + let (send_result_sender, send_result_receiver) = tokio::sync::oneshot::channel(); + self.cmd_tx.blocking_send(Command::Send { payload, send_result_sender })?; + let sending_result = send_result_receiver.blocking_recv()?; + error!(%sending_result, "Got sending result"); + Ok(sending_result) } } -pub fn spawn() -> Handle { +pub fn spawn() -> TokioTaskHandle { let (cmd_tx, cmd_rx) = tokio::sync::mpsc::channel(1); std::thread::spawn(move || { executor(cmd_rx); }); - Handle { cmd_tx } + TokioTaskHandle { cmd_tx } +} + +pub(crate) struct ParsedPayload { + pub(crate) body_str: String, + pub(crate) request_line: String, + pub(crate) url: String, +} + +pub(crate) fn parse_payload(payload: Payload) -> ParsedPayload { + let body_str = String::from_utf8(payload.body).unwrap(); + let request_line = body_str + .lines() + .next() + .ok_or("Empty HTTP body") + .unwrap() + .to_string(); + + let parts: Vec<&str> = request_line.split_whitespace().collect(); + if parts.len() < 2 { + tracing::error!("E1"); + } + let path = parts[1]; + + let scheme = if payload.host_uri.starts_with("https") { + "https" + } else { + "http" + }; + let domain = payload + .host_uri + .trim_start_matches("http://") + .trim_start_matches("https://"); + + let url = format!("{}://{}:{}{}", scheme, domain, payload.port, path); + tracing::error!("Full URL: {}", url); + ParsedPayload { + body_str, + request_line, + url, + } +} + + +fn send_request_in_background(body_str: String, request_line: String, url: String) -> bool { + std::thread::spawn(move || { + let client = reqwest::blocking::Client::new(); // TODO: Reuse client + let response = if request_line.starts_with("POST") { + let body_content = body_str.split("\r\n\r\n").last().unwrap_or(""); + client + .post(&url) + .body(body_content.to_string()) + .send() + .unwrap() + } else { + client.get(&url).send().unwrap() + }; + + let response_text = response + .text() + .unwrap_or_else(|_| "Failed to read response".to_string()); + + let on_http_response_event = super::event::OnHttpResponseEvent { + request_id: "some_id".to_string(), // TODO: From payload, already available on the callsite + response: response_text, + }; + + crate::event::queue::send(HermesEvent::new( + on_http_response_event, + TargetApp::All, + TargetModule::All, + )); + } + ); + + true } fn executor(mut cmd_rx: CommandReceiver) { @@ -51,7 +140,19 @@ fn executor(mut cmd_rx: CommandReceiver) { rt.block_on(async move { while let Some(cmd) = cmd_rx.recv().await { match cmd { - Command::Send { payload: _ } => todo!(), + Command::Send { payload, send_result_sender } => { + let ParsedPayload { + body_str, + request_line, + url, + } = parse_payload(payload); + error!(body_str = %body_str, request_line = %request_line, url = %url, "Parsed payload"); + + let sending_result = send_request_in_background(body_str, + request_line, + url); + let _ = send_result_sender.send(sending_result); + }, } } }); diff --git a/wasm/wasi/hermes_bindings.rs b/wasm/wasi/hermes_bindings.rs index f081b11004..3332cdd719 100644 --- a/wasm/wasi/hermes_bindings.rs +++ b/wasm/wasi/hermes_bindings.rs @@ -2140,21 +2140,56 @@ pub mod hermes { #[cfg(target_arch = "wasm32")] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; use super::super::super::_rt; - pub type Payload = u32; + /// HTTP request payload (caller manages full body formatting) + #[derive(Clone)] + pub struct Payload { + /// Host URI (scheme + domain, no path), e.g., "http://example.com" + pub host_uri: _rt::String, + /// Port (e.g., 80 for HTTP, 443 for HTTPS) + pub port: u16, + /// Raw HTTP request (including method, path, headers, and body) + pub body: _rt::Vec::, + /// Optional request identifier for tracking + pub request_id: Option<_rt::String>, + } + impl ::core::fmt::Debug for Payload { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("Payload").field("host-uri", &self.host_uri).field("port", &self.port).field("body", &self.body).field("request-id", &self.request_id).finish() + } + } #[allow(unused_unsafe, clippy::all)] - pub fn send(p: Payload,) -> bool{ + /// Send an HTTP request. + pub fn send(p: &Payload,) -> bool{ unsafe { + let Payload{ host_uri:host_uri0, port:port0, body:body0, request_id:request_id0, } = p; + let vec1 = host_uri0; + let ptr1 = vec1.as_ptr().cast::(); + let len1 = vec1.len(); + let vec2 = body0; + let ptr2 = vec2.as_ptr().cast::(); + let len2 = vec2.len(); + let (result4_0,result4_1,result4_2,) = match request_id0 { + Some(e) => { + let vec3 = e; + let ptr3 = vec3.as_ptr().cast::(); + let len3 = vec3.len(); + (1i32, ptr3.cast_mut(), len3) + }, + None => { + (0i32, ::core::ptr::null_mut(), 0usize) + }, + }; #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "hermes:http-request/api")] extern "C" { #[link_name = "send"] - fn wit_import(_: i32, ) -> i32; + fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, ) -> i32; } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import(_rt::as_i32(p)); + fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } + let ret = wit_import(ptr1.cast_mut(), len1, _rt::as_i32(port0), ptr2.cast_mut(), len2, result4_0, result4_1, result4_2); _rt::bool_lift(ret as u8) } } @@ -15846,6 +15881,44 @@ pub mod http_gateway { } +} +#[allow(dead_code)] +pub mod http_request { + #[allow(dead_code, clippy::all)] + pub mod event_on_http_response { + #[used] + #[doc(hidden)] + #[cfg(target_arch = "wasm32")] + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_on_http_response_cabi(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) {#[cfg(target_arch="wasm32")] + _rt::run_ctors_once();let len0 = arg1; + let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); + let len1 = arg3; + let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); + T::on_http_response(_rt::string_lift(bytes0), _rt::string_lift(bytes1)); + } + pub trait Guest { + fn on_http_response(request_id: _rt::String,response: _rt::String,); + } + #[doc(hidden)] + + macro_rules! __export_hermes_http_request_event_on_http_response_cabi{ + ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { + + #[export_name = "hermes:http-request/event-on-http-response#on-http-response"] + unsafe extern "C" fn export_on_http_response(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) { + $($path_to_types)*::_export_on_http_response_cabi::<$ty>(arg0, arg1, arg2, arg3) + } + };); + } + #[doc(hidden)] + pub(crate) use __export_hermes_http_request_event_on_http_response_cabi; + +} + } #[allow(dead_code)] pub mod init { @@ -16541,6 +16614,7 @@ macro_rules! __export_hermes_impl { $($path_to_types_root)*::exports::hermes::kv_store::event::__export_hermes_kv_store_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::kv_store::event); $($path_to_types_root)*::exports::hermes::integration_test::event::__export_hermes_integration_test_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::integration_test::event); $($path_to_types_root)*::exports::hermes::http_gateway::event::__export_hermes_http_gateway_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::http_gateway::event); + $($path_to_types_root)*::exports::hermes::http_request::event_on_http_response::__export_hermes_http_request_event_on_http_response_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::http_request::event_on_http_response); ) } #[doc(inline)] @@ -16549,8 +16623,8 @@ pub(crate) use __export_hermes_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.29.0:hermes:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 16171] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xae}\x01A\x02\x01Ai\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 16310] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xb9~\x01A\x02\x01Ak\x01\ B\x0a\x01o\x02ss\x01p\0\x01@\0\0\x01\x04\0\x0fget-environment\x01\x02\x01ps\x01@\ \0\0\x03\x04\0\x0dget-arguments\x01\x04\x01ks\x01@\0\0\x05\x04\0\x0binitial-cwd\x01\ \x06\x03\x01\x1awasi:cli/environment@0.2.0\x05\0\x01B\x03\x01j\0\0\x01@\x01\x06s\ @@ -16852,41 +16926,43 @@ nt.bind\x01\x13\x01@\x01\x04self\x12\0\x0a\x04\0\x16[method]statement.step\x01\x \x01j\x01\x06\x01\x03\x01@\x02\x04self\x12\x05indexy\0\x15\x04\0\x18[method]stat\ ement.column\x01\x16\x04\0\x1a[method]statement.finalize\x01\x14\x01i\x07\x01j\x01\ \x17\x01\x03\x01@\x02\x08readonly\x7f\x06memory\x7f\0\x18\x04\0\x04open\x01\x19\x03\ -\x01\x11hermes:sqlite/api\x05,\x01B\x04\x01y\x04\0\x07payload\x03\0\0\x01@\x01\x01\ -p\x01\0\x7f\x04\0\x04send\x01\x02\x03\x01\x17hermes:http-request/api\x05-\x02\x03\ -\0\x0e\x10incoming-request\x02\x03\0\x0e\x11response-outparam\x01B\x08\x02\x03\x02\ -\x01.\x04\0\x10incoming-request\x03\0\0\x02\x03\x02\x01/\x04\0\x11response-outpa\ -ram\x03\0\x02\x01i\x01\x01i\x03\x01@\x02\x07request\x04\x0cresponse-out\x05\x01\0\ -\x04\0\x06handle\x01\x06\x04\x01\x20wasi:http/incoming-handler@0.2.0\x050\x02\x03\ -\0\x12\x15cardano-blockchain-id\x02\x03\0\x12\x0dcardano-block\x02\x03\0\x12\x09\ -block-src\x01B\x08\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\x02\x03\ -\x02\x012\x04\0\x0dcardano-block\x03\0\x02\x02\x03\x02\x013\x04\0\x09block-src\x03\ -\0\x04\x01@\x03\x0ablockchain\x01\x05block\x03\x06source\x05\x01\0\x04\0\x10on-c\ -ardano-block\x01\x06\x04\x01\x1dhermes:cardano/event-on-block\x054\x02\x03\0\x12\ -\x0bcardano-txn\x01B\x06\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\ -\x02\x03\x02\x015\x04\0\x0bcardano-txn\x03\0\x02\x01@\x04\x0ablockchain\x01\x04s\ -lotw\x09txn-indexy\x03txn\x03\x01\0\x04\0\x0eon-cardano-txn\x01\x04\x04\x01\x1bh\ -ermes:cardano/event-on-txn\x056\x01B\x04\x02\x03\x02\x011\x04\0\x15cardano-block\ -chain-id\x03\0\0\x01@\x02\x0ablockchain\x01\x04slotw\x01\0\x04\0\x13on-cardano-r\ -ollback\x01\x02\x04\x01\x20hermes:cardano/event-on-rollback\x057\x02\x03\0\x13\x0e\ -cron-event-tag\x02\x03\0\x13\x0bcron-tagged\x01B\x06\x02\x03\x02\x018\x04\0\x0ec\ -ron-event-tag\x03\0\0\x02\x03\x02\x019\x04\0\x0bcron-tagged\x03\0\x02\x01@\x02\x05\ -event\x03\x04last\x7f\0\x7f\x04\0\x07on-cron\x01\x04\x04\x01\x11hermes:cron/even\ -t\x05:\x01B\x02\x01@\0\0\x7f\x04\0\x04init\x01\0\x04\x01\x11hermes:init/event\x05\ -;\x02\x03\0\x16\x0epubsub-message\x01B\x04\x02\x03\x02\x01<\x04\0\x0epubsub-mess\ -age\x03\0\0\x01@\x01\x07message\x01\0\x7f\x04\0\x08on-topic\x01\x02\x04\x01\x11h\ -ermes:ipfs/event\x05=\x02\x03\0\x18\x09kv-values\x01B\x04\x02\x03\x02\x01>\x04\0\ -\x09kv-values\x03\0\0\x01@\x02\x03keys\x05value\x01\x01\0\x04\0\x09kv-update\x01\ -\x02\x04\x01\x15hermes:kv-store/event\x05?\x01B\x06\x01r\x02\x04names\x06status\x7f\ -\x04\0\x0btest-result\x03\0\0\x01k\x01\x01@\x02\x04testy\x03run\x7f\0\x02\x04\0\x04\ -test\x01\x03\x04\0\x05bench\x01\x03\x04\x01\x1dhermes:integration-test/event\x05\ -@\x01B\x0c\x02\x03\x02\x01\x1c\x04\0\x04bstr\x03\0\0\x01ps\x01o\x02s\x02\x04\0\x06\ -header\x03\0\x03\x01p\x04\x04\0\x07headers\x03\0\x05\x01r\x03\x04code{\x07header\ -s\x06\x04body\x01\x04\0\x0dhttp-response\x03\0\x07\x01k\x08\x01@\x04\x04body\x01\ -\x07headers\x06\x04paths\x06methods\0\x09\x04\0\x05reply\x01\x0a\x04\x01\x19herm\ -es:http-gateway/event\x05A\x04\x01\x12hermes:wasi/hermes\x04\0\x0b\x0c\x01\0\x06\ -hermes\x03\0\0\0G\x09producers\x01\x0cprocessed-by\x02\x0dwit-component\x070.215\ -.0\x10wit-bindgen-rust\x060.29.0"; +\x01\x11hermes:sqlite/api\x05,\x01B\x06\x01p}\x01ks\x01r\x04\x08host-uris\x04por\ +t{\x04body\0\x0arequest-id\x01\x04\0\x07payload\x03\0\x02\x01@\x01\x01p\x03\0\x7f\ +\x04\0\x04send\x01\x04\x03\x01\x17hermes:http-request/api\x05-\x02\x03\0\x0e\x10\ +incoming-request\x02\x03\0\x0e\x11response-outparam\x01B\x08\x02\x03\x02\x01.\x04\ +\0\x10incoming-request\x03\0\0\x02\x03\x02\x01/\x04\0\x11response-outparam\x03\0\ +\x02\x01i\x01\x01i\x03\x01@\x02\x07request\x04\x0cresponse-out\x05\x01\0\x04\0\x06\ +handle\x01\x06\x04\x01\x20wasi:http/incoming-handler@0.2.0\x050\x02\x03\0\x12\x15\ +cardano-blockchain-id\x02\x03\0\x12\x0dcardano-block\x02\x03\0\x12\x09block-src\x01\ +B\x08\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\x02\x03\x02\x012\x04\ +\0\x0dcardano-block\x03\0\x02\x02\x03\x02\x013\x04\0\x09block-src\x03\0\x04\x01@\ +\x03\x0ablockchain\x01\x05block\x03\x06source\x05\x01\0\x04\0\x10on-cardano-bloc\ +k\x01\x06\x04\x01\x1dhermes:cardano/event-on-block\x054\x02\x03\0\x12\x0bcardano\ +-txn\x01B\x06\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\x02\x03\x02\ +\x015\x04\0\x0bcardano-txn\x03\0\x02\x01@\x04\x0ablockchain\x01\x04slotw\x09txn-\ +indexy\x03txn\x03\x01\0\x04\0\x0eon-cardano-txn\x01\x04\x04\x01\x1bhermes:cardan\ +o/event-on-txn\x056\x01B\x04\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\ +\0\0\x01@\x02\x0ablockchain\x01\x04slotw\x01\0\x04\0\x13on-cardano-rollback\x01\x02\ +\x04\x01\x20hermes:cardano/event-on-rollback\x057\x02\x03\0\x13\x0ecron-event-ta\ +g\x02\x03\0\x13\x0bcron-tagged\x01B\x06\x02\x03\x02\x018\x04\0\x0ecron-event-tag\ +\x03\0\0\x02\x03\x02\x019\x04\0\x0bcron-tagged\x03\0\x02\x01@\x02\x05event\x03\x04\ +last\x7f\0\x7f\x04\0\x07on-cron\x01\x04\x04\x01\x11hermes:cron/event\x05:\x01B\x02\ +\x01@\0\0\x7f\x04\0\x04init\x01\0\x04\x01\x11hermes:init/event\x05;\x02\x03\0\x16\ +\x0epubsub-message\x01B\x04\x02\x03\x02\x01<\x04\0\x0epubsub-message\x03\0\0\x01\ +@\x01\x07message\x01\0\x7f\x04\0\x08on-topic\x01\x02\x04\x01\x11hermes:ipfs/even\ +t\x05=\x02\x03\0\x18\x09kv-values\x01B\x04\x02\x03\x02\x01>\x04\0\x09kv-values\x03\ +\0\0\x01@\x02\x03keys\x05value\x01\x01\0\x04\0\x09kv-update\x01\x02\x04\x01\x15h\ +ermes:kv-store/event\x05?\x01B\x06\x01r\x02\x04names\x06status\x7f\x04\0\x0btest\ +-result\x03\0\0\x01k\x01\x01@\x02\x04testy\x03run\x7f\0\x02\x04\0\x04test\x01\x03\ +\x04\0\x05bench\x01\x03\x04\x01\x1dhermes:integration-test/event\x05@\x01B\x0c\x02\ +\x03\x02\x01\x1c\x04\0\x04bstr\x03\0\0\x01ps\x01o\x02s\x02\x04\0\x06header\x03\0\ +\x03\x01p\x04\x04\0\x07headers\x03\0\x05\x01r\x03\x04code{\x07headers\x06\x04bod\ +y\x01\x04\0\x0dhttp-response\x03\0\x07\x01k\x08\x01@\x04\x04body\x01\x07headers\x06\ +\x04paths\x06methods\0\x09\x04\0\x05reply\x01\x0a\x04\x01\x19hermes:http-gateway\ +/event\x05A\x01B\x02\x01@\x02\x0arequest-ids\x08responses\x01\0\x04\0\x10on-http\ +-response\x01\0\x04\x01*hermes:http-request/event-on-http-response\x05B\x04\x01\x12\ +hermes:wasi/hermes\x04\0\x0b\x0c\x01\0\x06hermes\x03\0\0\0G\x09producers\x01\x0c\ +processed-by\x02\x0dwit-component\x070.215.0\x10wit-bindgen-rust\x060.29.0"; #[inline(never)] #[doc(hidden)] diff --git a/wasm/wasi/wit/deps/hermes-http-request/event.wit b/wasm/wasi/wit/deps/hermes-http-request/event.wit new file mode 100644 index 0000000000..a40fc323be --- /dev/null +++ b/wasm/wasi/wit/deps/hermes-http-request/event.wit @@ -0,0 +1,7 @@ +interface event-on-http-response { + on-http-response: func(request-id: string, response: string); +} + +world http-request-events { + export event-on-http-response; +} \ No newline at end of file diff --git a/wasm/wasi/wit/deps/hermes-http-request/world.wit b/wasm/wasi/wit/deps/hermes-http-request/world.wit index 7acb990344..b7194440d5 100644 --- a/wasm/wasi/wit/deps/hermes-http-request/world.wit +++ b/wasm/wasi/wit/deps/hermes-http-request/world.wit @@ -2,4 +2,6 @@ package hermes:http-request; world all { import api; + + export event-on-http-response; } From 584af270bd0f373078f0e54bafa53df48a90deb6 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Mon, 7 Jul 2025 15:15:40 +0200 Subject: [PATCH 07/45] Use proper req id --- .../hermes/http_request/host.rs | 43 ------------------- .../hermes/http_request/tokio_runtime_task.rs | 11 +++-- 2 files changed, 7 insertions(+), 47 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs index 47d4577946..1bd2cb5144 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs @@ -8,53 +8,10 @@ use crate::{ }, }; -// fn http_request(payload: Payload) -> String { -// let ParsedPayload { -// body_str, -// request_line, -// url, -// } = parse_payload(payload); - -// let client = reqwest::blocking::Client::new(); -// let response = if request_line.starts_with("POST") { -// let body_content = body_str.split("\r\n\r\n").last().unwrap_or(""); -// client -// .post(&url) -// .body(body_content.to_string()) -// .send() -// .unwrap() -// } else { -// client.get(&url).send().unwrap() -// }; - -// response -// .text() -// .unwrap_or_else(|_| "Failed to read response".to_string()) -// } - impl Host for HermesRuntimeContext { fn send(&mut self, payload: Payload) -> wasmtime::Result { STATE.tokio_rt_handle.send(payload).unwrap(); - // tracing::error!("Sending payload: {payload:?}"); - - // let res = http_request(payload); - // tracing::error!("POST Response: {res}"); - - // let get_body = b"\ - // GET /get?param1=value1 HTTP/1.1\r\n\ - // Host: httpbin.org\r\n\ - // \r\n"; - // - // let get_payload = Payload { - // host_uri: "http://httpbin.org".to_string(), - // port: 80, - // body: get_body.to_vec(), - // request_id: Some("req-get".to_string()), - // }; - // let res = http_request(get_payload); - // tracing::error!("GET Response: {res}"); - Ok(true) } } diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 00cf6bc527..cb03956399 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -50,6 +50,7 @@ pub(crate) struct ParsedPayload { pub(crate) body_str: String, pub(crate) request_line: String, pub(crate) url: String, + pub(crate) request_id: String, } pub(crate) fn parse_payload(payload: Payload) -> ParsedPayload { @@ -83,11 +84,12 @@ pub(crate) fn parse_payload(payload: Payload) -> ParsedPayload { body_str, request_line, url, + request_id: payload.request_id.clone().unwrap(), } } -fn send_request_in_background(body_str: String, request_line: String, url: String) -> bool { +fn send_request_in_background(request_id: String, body_str: String, request_line: String, url: String) -> bool { std::thread::spawn(move || { let client = reqwest::blocking::Client::new(); // TODO: Reuse client let response = if request_line.starts_with("POST") { @@ -106,7 +108,7 @@ fn send_request_in_background(body_str: String, request_line: String, url: Strin .unwrap_or_else(|_| "Failed to read response".to_string()); let on_http_response_event = super::event::OnHttpResponseEvent { - request_id: "some_id".to_string(), // TODO: From payload, already available on the callsite + request_id, response: response_text, }; @@ -145,10 +147,11 @@ fn executor(mut cmd_rx: CommandReceiver) { body_str, request_line, url, + request_id, } = parse_payload(payload); - error!(body_str = %body_str, request_line = %request_line, url = %url, "Parsed payload"); + error!(body_str = %body_str, request_line = %request_line, url = %url, request_id = %request_id, "Parsed payload"); - let sending_result = send_request_in_background(body_str, + let sending_result = send_request_in_background(request_id, body_str, request_line, url); let _ = send_result_sender.send(sending_result); From 4004eb027feb40fe20accbee98c99270a72e9f3d Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Wed, 9 Jul 2025 10:08:31 +0200 Subject: [PATCH 08/45] Introduce `ErrorCode` --- .../hermes/http_request/host.rs | 13 +- .../hermes/http_request/tokio_runtime_task.rs | 29 +-- wasm/wasi/hermes_bindings.rs | 169 +++++++++++++----- .../wasi/wit/deps/hermes-http-request/api.wit | 20 ++- 4 files changed, 169 insertions(+), 62 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs index 1bd2cb5144..985ca6ef63 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs @@ -3,15 +3,18 @@ use crate::{ runtime_context::HermesRuntimeContext, runtime_extensions::{ - bindings::hermes::http_request::api::{Host, Payload}, - hermes::http_request::{tokio_runtime_task::{parse_payload, ParsedPayload}, STATE}, + bindings::hermes::http_request::api::{ErrorCode, Host, Payload}, + hermes::http_request::{ + tokio_runtime_task::{parse_payload, ParsedPayload}, + STATE, + }, }, }; impl Host for HermesRuntimeContext { - fn send(&mut self, payload: Payload) -> wasmtime::Result { - STATE.tokio_rt_handle.send(payload).unwrap(); + fn send(&mut self, payload: Payload) -> wasmtime::Result> { + let result = STATE.tokio_rt_handle.send(payload)?; - Ok(true) + Ok(Ok(result)) } } diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index cb03956399..6f0f7d85de 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -2,10 +2,10 @@ use tokio::sync::{mpsc, oneshot}; use tracing::{error, trace}; use thiserror::Error; -use crate::{event::{HermesEvent, HermesEventPayload, TargetApp, TargetModule}, runtime_extensions::bindings::hermes::http_request::api::Payload}; +use crate::{event::{HermesEvent, HermesEventPayload, TargetApp, TargetModule}, runtime_extensions::bindings::hermes::http_request::api::{Payload, ErrorCode}}; pub enum Command { - Send { payload: Payload, send_result_sender: oneshot::Sender }, + Send { payload: Payload, sender: oneshot::Sender }, } type CommandSender = tokio::sync::mpsc::Sender; @@ -24,16 +24,24 @@ pub enum RequestSendingError { ResponseReceive(#[from] oneshot::error::RecvError), } +impl From for ErrorCode { + fn from(value: RequestSendingError) -> Self { + match value { + // We map all "internal" errors to `ErrorCode::Internal` to not expose implementation details to the user. Detailed information will be available in logs. + RequestSendingError::ChannelSend(_)|RequestSendingError::ResponseReceive(_) => ErrorCode::Internal, + } + } +} + impl TokioTaskHandle { /// Sends a command to the Tokio runtime task. pub fn send( &self, payload: Payload, - ) -> Result { - let (send_result_sender, send_result_receiver) = tokio::sync::oneshot::channel(); - self.cmd_tx.blocking_send(Command::Send { payload, send_result_sender })?; - let sending_result = send_result_receiver.blocking_recv()?; - error!(%sending_result, "Got sending result"); - Ok(sending_result) + ) -> Result<(), RequestSendingError> { + let (sender, receiver) = tokio::sync::oneshot::channel(); + self.cmd_tx.blocking_send(Command::Send { payload, sender })?; + receiver.blocking_recv()?; + Ok(()) } } @@ -90,6 +98,7 @@ pub(crate) fn parse_payload(payload: Payload) -> ParsedPayload { fn send_request_in_background(request_id: String, body_str: String, request_line: String, url: String) -> bool { + // TODO[RC]: Make sure there are no stray threads left running std::thread::spawn(move || { let client = reqwest::blocking::Client::new(); // TODO: Reuse client let response = if request_line.starts_with("POST") { @@ -142,7 +151,7 @@ fn executor(mut cmd_rx: CommandReceiver) { rt.block_on(async move { while let Some(cmd) = cmd_rx.recv().await { match cmd { - Command::Send { payload, send_result_sender } => { + Command::Send { payload, sender } => { let ParsedPayload { body_str, request_line, @@ -154,7 +163,7 @@ fn executor(mut cmd_rx: CommandReceiver) { let sending_result = send_request_in_background(request_id, body_str, request_line, url); - let _ = send_result_sender.send(sending_result); + let _ = sender.send(sending_result); }, } } diff --git a/wasm/wasi/hermes_bindings.rs b/wasm/wasi/hermes_bindings.rs index 3332cdd719..a6295a663e 100644 --- a/wasm/wasi/hermes_bindings.rs +++ b/wasm/wasi/hermes_bindings.rs @@ -2140,10 +2140,62 @@ pub mod hermes { #[cfg(target_arch = "wasm32")] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; use super::super::super::_rt; + /// Error codes. + #[repr(u8)] + #[derive(Clone, Copy, Eq, PartialEq)] + pub enum ErrorCode { + /// Internal error when trying to send the request + Internal, + } + impl ErrorCode{ + pub fn name(&self) -> &'static str { + match self { + ErrorCode::Internal => "internal", + } + } + pub fn message(&self) -> &'static str { + match self { + ErrorCode::Internal => "Internal error when trying to send the request", + } + } + } + impl ::core::fmt::Debug for ErrorCode{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + f.debug_struct("ErrorCode") + .field("code", &(*self as i32)) + .field("name", &self.name()) + .field("message", &self.message()) + .finish() + } + } + impl ::core::fmt::Display for ErrorCode{ + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + write!(f, "{} (error {})", self.name(), *self as i32) + } + } + + impl std::error::Error for ErrorCode {} + + impl ErrorCode{ + #[doc(hidden)] + pub unsafe fn _lift(val: u8) -> ErrorCode{ + if !cfg!(debug_assertions) { + return ::core::mem::transmute(val); + } + + match val { + 0 => ErrorCode::Internal, + + _ => panic!("invalid enum discriminant"), + } + } + } + /// HTTP request payload (caller manages full body formatting) #[derive(Clone)] pub struct Payload { /// Host URI (scheme + domain, no path), e.g., "http://example.com" + /// TODO[RC]: Invalid when unspecified pub host_uri: _rt::String, /// Port (e.g., 80 for HTTP, 443 for HTTPS) pub port: u16, @@ -2159,8 +2211,19 @@ pub mod hermes { } #[allow(unused_unsafe, clippy::all)] /// Send an HTTP request. - pub fn send(p: &Payload,) -> bool{ + /// + /// **Parameters** + /// + /// `p` : The payload of a request to be sent. + /// + /// **Returns** + /// + /// `true` if the request was sent successfully, `false` otherwise. + pub fn send(p: &Payload,) -> Result<(),ErrorCode>{ unsafe { + #[repr(align(1))] + struct RetArea([::core::mem::MaybeUninit::; 2]); + let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); let Payload{ host_uri:host_uri0, port:port0, body:body0, request_id:request_id0, } = p; let vec1 = host_uri0; let ptr1 = vec1.as_ptr().cast::(); @@ -2179,18 +2242,33 @@ pub mod hermes { None => { (0i32, ::core::ptr::null_mut(), 0usize) }, - }; + };let ptr5 = ret_area.0.as_mut_ptr().cast::(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "hermes:http-request/api")] extern "C" { #[link_name = "send"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, ) -> i32; + fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); } #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1.cast_mut(), len1, _rt::as_i32(port0), ptr2.cast_mut(), len2, result4_0, result4_1, result4_2); - _rt::bool_lift(ret as u8) + fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } + wit_import(ptr1.cast_mut(), len1, _rt::as_i32(port0), ptr2.cast_mut(), len2, result4_0, result4_1, result4_2, ptr5); + let l6 = i32::from(*ptr5.add(0).cast::()); + match l6 { + 0 => { + let e = (); + Ok(e) + } + 1 => { + let e = { + let l7 = i32::from(*ptr5.add(1).cast::()); + + ErrorCode::_lift(l7 as u8) + }; + Err(e) + } + _ => _rt::invalid_enum_discriminant(), + } } } @@ -16623,8 +16701,8 @@ pub(crate) use __export_hermes_impl as export; #[cfg(target_arch = "wasm32")] #[link_section = "component-type:wit-bindgen:0.29.0:hermes:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 16310] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xb9~\x01A\x02\x01Ak\x01\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 16343] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xda~\x01A\x02\x01Ak\x01\ B\x0a\x01o\x02ss\x01p\0\x01@\0\0\x01\x04\0\x0fget-environment\x01\x02\x01ps\x01@\ \0\0\x03\x04\0\x0dget-arguments\x01\x04\x01ks\x01@\0\0\x05\x04\0\x0binitial-cwd\x01\ \x06\x03\x01\x1awasi:cli/environment@0.2.0\x05\0\x01B\x03\x01j\0\0\x01@\x01\x06s\ @@ -16926,43 +17004,44 @@ nt.bind\x01\x13\x01@\x01\x04self\x12\0\x0a\x04\0\x16[method]statement.step\x01\x \x01j\x01\x06\x01\x03\x01@\x02\x04self\x12\x05indexy\0\x15\x04\0\x18[method]stat\ ement.column\x01\x16\x04\0\x1a[method]statement.finalize\x01\x14\x01i\x07\x01j\x01\ \x17\x01\x03\x01@\x02\x08readonly\x7f\x06memory\x7f\0\x18\x04\0\x04open\x01\x19\x03\ -\x01\x11hermes:sqlite/api\x05,\x01B\x06\x01p}\x01ks\x01r\x04\x08host-uris\x04por\ -t{\x04body\0\x0arequest-id\x01\x04\0\x07payload\x03\0\x02\x01@\x01\x01p\x03\0\x7f\ -\x04\0\x04send\x01\x04\x03\x01\x17hermes:http-request/api\x05-\x02\x03\0\x0e\x10\ -incoming-request\x02\x03\0\x0e\x11response-outparam\x01B\x08\x02\x03\x02\x01.\x04\ -\0\x10incoming-request\x03\0\0\x02\x03\x02\x01/\x04\0\x11response-outparam\x03\0\ -\x02\x01i\x01\x01i\x03\x01@\x02\x07request\x04\x0cresponse-out\x05\x01\0\x04\0\x06\ -handle\x01\x06\x04\x01\x20wasi:http/incoming-handler@0.2.0\x050\x02\x03\0\x12\x15\ -cardano-blockchain-id\x02\x03\0\x12\x0dcardano-block\x02\x03\0\x12\x09block-src\x01\ -B\x08\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\x02\x03\x02\x012\x04\ -\0\x0dcardano-block\x03\0\x02\x02\x03\x02\x013\x04\0\x09block-src\x03\0\x04\x01@\ -\x03\x0ablockchain\x01\x05block\x03\x06source\x05\x01\0\x04\0\x10on-cardano-bloc\ -k\x01\x06\x04\x01\x1dhermes:cardano/event-on-block\x054\x02\x03\0\x12\x0bcardano\ --txn\x01B\x06\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\x02\x03\x02\ -\x015\x04\0\x0bcardano-txn\x03\0\x02\x01@\x04\x0ablockchain\x01\x04slotw\x09txn-\ -indexy\x03txn\x03\x01\0\x04\0\x0eon-cardano-txn\x01\x04\x04\x01\x1bhermes:cardan\ -o/event-on-txn\x056\x01B\x04\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\ -\0\0\x01@\x02\x0ablockchain\x01\x04slotw\x01\0\x04\0\x13on-cardano-rollback\x01\x02\ -\x04\x01\x20hermes:cardano/event-on-rollback\x057\x02\x03\0\x13\x0ecron-event-ta\ -g\x02\x03\0\x13\x0bcron-tagged\x01B\x06\x02\x03\x02\x018\x04\0\x0ecron-event-tag\ -\x03\0\0\x02\x03\x02\x019\x04\0\x0bcron-tagged\x03\0\x02\x01@\x02\x05event\x03\x04\ -last\x7f\0\x7f\x04\0\x07on-cron\x01\x04\x04\x01\x11hermes:cron/event\x05:\x01B\x02\ -\x01@\0\0\x7f\x04\0\x04init\x01\0\x04\x01\x11hermes:init/event\x05;\x02\x03\0\x16\ -\x0epubsub-message\x01B\x04\x02\x03\x02\x01<\x04\0\x0epubsub-message\x03\0\0\x01\ -@\x01\x07message\x01\0\x7f\x04\0\x08on-topic\x01\x02\x04\x01\x11hermes:ipfs/even\ -t\x05=\x02\x03\0\x18\x09kv-values\x01B\x04\x02\x03\x02\x01>\x04\0\x09kv-values\x03\ -\0\0\x01@\x02\x03keys\x05value\x01\x01\0\x04\0\x09kv-update\x01\x02\x04\x01\x15h\ -ermes:kv-store/event\x05?\x01B\x06\x01r\x02\x04names\x06status\x7f\x04\0\x0btest\ --result\x03\0\0\x01k\x01\x01@\x02\x04testy\x03run\x7f\0\x02\x04\0\x04test\x01\x03\ -\x04\0\x05bench\x01\x03\x04\x01\x1dhermes:integration-test/event\x05@\x01B\x0c\x02\ -\x03\x02\x01\x1c\x04\0\x04bstr\x03\0\0\x01ps\x01o\x02s\x02\x04\0\x06header\x03\0\ -\x03\x01p\x04\x04\0\x07headers\x03\0\x05\x01r\x03\x04code{\x07headers\x06\x04bod\ -y\x01\x04\0\x0dhttp-response\x03\0\x07\x01k\x08\x01@\x04\x04body\x01\x07headers\x06\ -\x04paths\x06methods\0\x09\x04\0\x05reply\x01\x0a\x04\x01\x19hermes:http-gateway\ -/event\x05A\x01B\x02\x01@\x02\x0arequest-ids\x08responses\x01\0\x04\0\x10on-http\ --response\x01\0\x04\x01*hermes:http-request/event-on-http-response\x05B\x04\x01\x12\ -hermes:wasi/hermes\x04\0\x0b\x0c\x01\0\x06hermes\x03\0\0\0G\x09producers\x01\x0c\ -processed-by\x02\x0dwit-component\x070.215.0\x10wit-bindgen-rust\x060.29.0"; +\x01\x11hermes:sqlite/api\x05,\x01B\x09\x01m\x01\x08internal\x04\0\x0aerror-code\ +\x03\0\0\x01p}\x01ks\x01r\x04\x08host-uris\x04port{\x04body\x02\x0arequest-id\x03\ +\x04\0\x07payload\x03\0\x04\x01j\0\x01\x01\x01@\x01\x01p\x05\0\x06\x04\0\x04send\ +\x01\x07\x03\x01\x17hermes:http-request/api\x05-\x02\x03\0\x0e\x10incoming-reque\ +st\x02\x03\0\x0e\x11response-outparam\x01B\x08\x02\x03\x02\x01.\x04\0\x10incomin\ +g-request\x03\0\0\x02\x03\x02\x01/\x04\0\x11response-outparam\x03\0\x02\x01i\x01\ +\x01i\x03\x01@\x02\x07request\x04\x0cresponse-out\x05\x01\0\x04\0\x06handle\x01\x06\ +\x04\x01\x20wasi:http/incoming-handler@0.2.0\x050\x02\x03\0\x12\x15cardano-block\ +chain-id\x02\x03\0\x12\x0dcardano-block\x02\x03\0\x12\x09block-src\x01B\x08\x02\x03\ +\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\x02\x03\x02\x012\x04\0\x0dcarda\ +no-block\x03\0\x02\x02\x03\x02\x013\x04\0\x09block-src\x03\0\x04\x01@\x03\x0ablo\ +ckchain\x01\x05block\x03\x06source\x05\x01\0\x04\0\x10on-cardano-block\x01\x06\x04\ +\x01\x1dhermes:cardano/event-on-block\x054\x02\x03\0\x12\x0bcardano-txn\x01B\x06\ +\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\x02\x03\x02\x015\x04\0\x0b\ +cardano-txn\x03\0\x02\x01@\x04\x0ablockchain\x01\x04slotw\x09txn-indexy\x03txn\x03\ +\x01\0\x04\0\x0eon-cardano-txn\x01\x04\x04\x01\x1bhermes:cardano/event-on-txn\x05\ +6\x01B\x04\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\x01@\x02\x0ab\ +lockchain\x01\x04slotw\x01\0\x04\0\x13on-cardano-rollback\x01\x02\x04\x01\x20her\ +mes:cardano/event-on-rollback\x057\x02\x03\0\x13\x0ecron-event-tag\x02\x03\0\x13\ +\x0bcron-tagged\x01B\x06\x02\x03\x02\x018\x04\0\x0ecron-event-tag\x03\0\0\x02\x03\ +\x02\x019\x04\0\x0bcron-tagged\x03\0\x02\x01@\x02\x05event\x03\x04last\x7f\0\x7f\ +\x04\0\x07on-cron\x01\x04\x04\x01\x11hermes:cron/event\x05:\x01B\x02\x01@\0\0\x7f\ +\x04\0\x04init\x01\0\x04\x01\x11hermes:init/event\x05;\x02\x03\0\x16\x0epubsub-m\ +essage\x01B\x04\x02\x03\x02\x01<\x04\0\x0epubsub-message\x03\0\0\x01@\x01\x07mes\ +sage\x01\0\x7f\x04\0\x08on-topic\x01\x02\x04\x01\x11hermes:ipfs/event\x05=\x02\x03\ +\0\x18\x09kv-values\x01B\x04\x02\x03\x02\x01>\x04\0\x09kv-values\x03\0\0\x01@\x02\ +\x03keys\x05value\x01\x01\0\x04\0\x09kv-update\x01\x02\x04\x01\x15hermes:kv-stor\ +e/event\x05?\x01B\x06\x01r\x02\x04names\x06status\x7f\x04\0\x0btest-result\x03\0\ +\0\x01k\x01\x01@\x02\x04testy\x03run\x7f\0\x02\x04\0\x04test\x01\x03\x04\0\x05be\ +nch\x01\x03\x04\x01\x1dhermes:integration-test/event\x05@\x01B\x0c\x02\x03\x02\x01\ +\x1c\x04\0\x04bstr\x03\0\0\x01ps\x01o\x02s\x02\x04\0\x06header\x03\0\x03\x01p\x04\ +\x04\0\x07headers\x03\0\x05\x01r\x03\x04code{\x07headers\x06\x04body\x01\x04\0\x0d\ +http-response\x03\0\x07\x01k\x08\x01@\x04\x04body\x01\x07headers\x06\x04paths\x06\ +methods\0\x09\x04\0\x05reply\x01\x0a\x04\x01\x19hermes:http-gateway/event\x05A\x01\ +B\x02\x01@\x02\x0arequest-ids\x08responses\x01\0\x04\0\x10on-http-response\x01\0\ +\x04\x01*hermes:http-request/event-on-http-response\x05B\x04\x01\x12hermes:wasi/\ +hermes\x04\0\x0b\x0c\x01\0\x06hermes\x03\0\0\0G\x09producers\x01\x0cprocessed-by\ +\x02\x0dwit-component\x070.215.0\x10wit-bindgen-rust\x060.29.0"; #[inline(never)] #[doc(hidden)] diff --git a/wasm/wasi/wit/deps/hermes-http-request/api.wit b/wasm/wasi/wit/deps/hermes-http-request/api.wit index 80201e3539..e8b37a3cbf 100644 --- a/wasm/wasi/wit/deps/hermes-http-request/api.wit +++ b/wasm/wasi/wit/deps/hermes-http-request/api.wit @@ -2,9 +2,16 @@ /// Http request interface interface api { - // HTTP request payload (caller manages full body formatting) + /// Error codes. + enum error-code { + /// Internal error when trying to send the request + internal, + } + + /// HTTP request payload (caller manages full body formatting) record payload { /// Host URI (scheme + domain, no path), e.g., "http://example.com" + /// TODO[RC]: Invalid when unspecified host-uri: string, /// Port (e.g., 80 for HTTP, 443 for HTTPS) port: u16, @@ -15,7 +22,16 @@ interface api { } /// Send an HTTP request. - send: func(p: payload) -> bool; + /// + /// **Parameters** + /// + /// `p` : The payload of a request to be sent. + /// + /// **Returns** + /// + /// `true` if the request was sent successfully, `false` otherwise. + /// + send: func(p: payload) -> result<_, error-code>; } /// World just for the Hermes Http request extension. From e5a99cc99f8647a7060f00bdc13f90030634fe9b Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Wed, 9 Jul 2025 10:08:55 +0200 Subject: [PATCH 09/45] Remove stray file --- wasm/wasi/hermes_bindings.rs | 17052 --------------------------------- 1 file changed, 17052 deletions(-) delete mode 100644 wasm/wasi/hermes_bindings.rs diff --git a/wasm/wasi/hermes_bindings.rs b/wasm/wasi/hermes_bindings.rs deleted file mode 100644 index a6295a663e..0000000000 --- a/wasm/wasi/hermes_bindings.rs +++ /dev/null @@ -1,17052 +0,0 @@ -// Generated by `wit-bindgen` 0.29.0. DO NOT EDIT! -// Options used: -#[allow(dead_code)] -pub mod hermes { - #[allow(dead_code)] - pub mod binary { - #[allow(dead_code, clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - /// Binary String (bstr) is a list of bytes. - /// This type is used to indicate the data is an arbitrary array of bytes. - pub type Bstr = _rt::Vec::; - /// 256 bit value - pub type B256 = (u64,u64,u64,u64,); - /// 512 bit value - pub type B512 = (u64,u64,u64,u64,u64,u64,u64,u64,); - - } - - } - #[allow(dead_code)] - pub mod cardano { - #[allow(dead_code, clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - pub type Bstr = super::super::super::hermes::binary::api::Bstr; - pub type Cbor = super::super::super::hermes::cbor::api::Cbor; - /// Cardano Blocks are CBOR Data - pub type CardanoBlock = Cbor; - /// Cardano Transactions are CBOR Data - pub type CardanoTxn = Cbor; - /// The ID of the blockchain to interact with. - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum CardanoBlockchainId { - Mainnet, - /// Cardano Mainnet - Preprod, - /// Cardano Preprod Network - Preview, - /// Cardano Preview Network - LocalTestBlockchain, - } - impl ::core::fmt::Debug for CardanoBlockchainId { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - CardanoBlockchainId::Mainnet => { - f.debug_tuple("CardanoBlockchainId::Mainnet").finish() - } - CardanoBlockchainId::Preprod => { - f.debug_tuple("CardanoBlockchainId::Preprod").finish() - } - CardanoBlockchainId::Preview => { - f.debug_tuple("CardanoBlockchainId::Preview").finish() - } - CardanoBlockchainId::LocalTestBlockchain => { - f.debug_tuple("CardanoBlockchainId::LocalTestBlockchain").finish() - } - } - } - } - - impl CardanoBlockchainId{ - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> CardanoBlockchainId{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => CardanoBlockchainId::Mainnet, - 1 => CardanoBlockchainId::Preprod, - 2 => CardanoBlockchainId::Preview, - 3 => CardanoBlockchainId::LocalTestBlockchain, - - _ => panic!("invalid enum discriminant"), - } - } - } - - wit_bindgen::rt::bitflags::bitflags! { - /// Source information about where the block came from, and if we are at tip or not. - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] - pub struct BlockSrc: u8 { - const TIP = 1 << 0; - const NODE = 1 << 1; - const MITHRIL = 1 << 2; - } - } - /// The Slot number to interact with - #[derive(Clone)] - pub enum Slot { - Genesis, - /// The very start of the blockchain. - Point((u64,Bstr,)), - /// A particular slot number. - Tip, - /// The TIP of the blockchain. - Continue, - } - impl ::core::fmt::Debug for Slot { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - Slot::Genesis => { - f.debug_tuple("Slot::Genesis").finish() - } - Slot::Point(e) => { - f.debug_tuple("Slot::Point").field(e).finish() - } - Slot::Tip => { - f.debug_tuple("Slot::Tip").finish() - } - Slot::Continue => { - f.debug_tuple("Slot::Continue").finish() - } - } - } - } - /// Errors that can happen fetching/subscribing to blocks - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum FetchError { - BlockchainNotAvailable, - /// The blockchain requested is not available. - InvalidSlot, - } - impl FetchError{ - pub fn name(&self) -> &'static str { - match self { - FetchError::BlockchainNotAvailable => "blockchain-not-available", - FetchError::InvalidSlot => "invalid-slot", - } - } - pub fn message(&self) -> &'static str { - match self { - FetchError::BlockchainNotAvailable => "", - FetchError::InvalidSlot => "The blockchain requested is not available.", - } - } - } - impl ::core::fmt::Debug for FetchError{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("FetchError") - .field("code", &(*self as i32)) - .field("name", &self.name()) - .field("message", &self.message()) - .finish() - } - } - impl ::core::fmt::Display for FetchError{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{} (error {})", self.name(), *self as i32) - } - } - - impl std::error::Error for FetchError {} - - impl FetchError{ - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> FetchError{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => FetchError::BlockchainNotAvailable, - 1 => FetchError::InvalidSlot, - - _ => panic!("invalid enum discriminant"), - } - } - } - - /// Errors that can occur when posting transactions. - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum TxnError { - BlockchainNotAvailable, - /// The blockchain requested is not available. - MalformedTransaction, - /// The transaction is not well formed, and can not be posted. - PostTxnNotAllowed, - } - impl TxnError{ - pub fn name(&self) -> &'static str { - match self { - TxnError::BlockchainNotAvailable => "blockchain-not-available", - TxnError::MalformedTransaction => "malformed-transaction", - TxnError::PostTxnNotAllowed => "post-txn-not-allowed", - } - } - pub fn message(&self) -> &'static str { - match self { - TxnError::BlockchainNotAvailable => "", - TxnError::MalformedTransaction => "The blockchain requested is not available.", - TxnError::PostTxnNotAllowed => "The transaction is not well formed, and can not be posted.", - } - } - } - impl ::core::fmt::Debug for TxnError{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("TxnError") - .field("code", &(*self as i32)) - .field("name", &self.name()) - .field("message", &self.message()) - .finish() - } - } - impl ::core::fmt::Display for TxnError{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{} (error {})", self.name(), *self as i32) - } - } - - impl std::error::Error for TxnError {} - - impl TxnError{ - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> TxnError{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => TxnError::BlockchainNotAvailable, - 1 => TxnError::MalformedTransaction, - 2 => TxnError::PostTxnNotAllowed, - - _ => panic!("invalid enum discriminant"), - } - } - } - - wit_bindgen::rt::bitflags::bitflags! { - /// Options used to unsubscribe from the blockchain data flow. - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] - pub struct UnsubscribeOptions: u8 { - const BLOCK = 1 << 0; - /// Stop receiving block data - const TRANSACTION = 1 << 1; - /// Stop receiving txn data - const ROLLBACK = 1 << 2; - /// Stop receiving rollback data - const STOP = 1 << 3; - } - } - #[allow(unused_unsafe, clippy::all)] - /// Subscribe to the Blockchain block data. - /// - /// **Parameters** - /// - /// - `net` : The blockchain network to fetch block from, and subscribe to. - /// - `whence`: Where to start fetching blocks from. - /// - /// **Returns** - /// - /// - `ok(u64)` : The slot we are synching from now. - /// - `error(fetch-error)` : If an error occured. - /// - /// **Notes** - /// - /// If the blockchain is not yet syncing, it will start, from the requested slot. - /// If the blockchain is not yet syncing, and `whence` == `continue` then the blockchain will - /// not be synced from, the calling module will only be subscribed for block events. - /// - /// If the blockchain is already syncing, the sync will stop and restart, unless `whence` == `continue`. - /// When `whence` == `continue` the blockchain will keep syncing from where it is at, and this module - /// will be subscribed to block updates. - /// - /// `whence` == `stop` will prevent the blockchain syncing, and the caller will be unsubscribed. - pub fn subscribe_blocks(net: CardanoBlockchainId,whence: &Slot,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let (result2_0,result2_1,result2_2,result2_3,) = match whence { - Slot::Genesis=> { - (0i32, 0i64, ::core::ptr::null_mut(), 0usize) - } - Slot::Point(e) => { - let (t0_0, t0_1, ) = e; - let vec1 = t0_1; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - - (1i32, _rt::as_i64(t0_0), ptr1.cast_mut(), len1) - }, - Slot::Tip=> { - (2i32, 0i64, ::core::ptr::null_mut(), 0usize) - } - Slot::Continue=> { - (3i32, 0i64, ::core::ptr::null_mut(), 0usize) - } - }; - let ptr3 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:cardano/api")] - extern "C" { - #[link_name = "subscribe-blocks"] - fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(net.clone() as i32, result2_0, result2_1, result2_2, result2_3, ptr3); - let l4 = i32::from(*ptr3.add(0).cast::()); - match l4 { - 0 => { - let e = { - let l5 = *ptr3.add(8).cast::(); - - l5 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*ptr3.add(8).cast::()); - - FetchError::_lift(l6 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Unsubscribe from the blockchain events listed. - /// - /// **Parameters** - /// - /// - `opts` : The events to unsubscribe from (and optionally stop the blockchain follower). - /// - /// **Notes** - /// - /// This only unsubscribes from the events. - /// The option `stop` MUST be set to actually stop fetching data from the blockchain once started. - /// - /// `stop` can be set without unsubscribing, and this will interrupt the flow of blockchain data. - /// After `stop`, `subscribe-blocks(?, continue)` would cause blockchain sync to continue from - /// the last block received. This would result in the last block being sent as an event twice, - /// once before the `stop` and once after the `continue`. - pub fn unsubscribe(net: CardanoBlockchainId,opts: UnsubscribeOptions,){ - unsafe { - let flags0 = opts; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:cardano/api")] - extern "C" { - #[link_name = "unsubscribe"] - fn wit_import(_: i32, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ){ unreachable!() } - wit_import(net.clone() as i32, (flags0.bits() >> 0) as i32); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Subscribe to transaction data events, does not alter the blockchain sync in anyway. - /// - /// **Parameters** - /// - /// - `net` : The blockchain network to subscribe to txn events from. - pub fn subscribe_txn(net: CardanoBlockchainId,){ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:cardano/api")] - extern "C" { - #[link_name = "subscribe-txn"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(net.clone() as i32); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Subscribe to blockchain rollback events, does not alter the blockchain sync in anyway. - /// - /// **Parameters** - /// - /// - `net` : The blockchain network to subscribe to txn events from. - /// - /// **Notes** - /// - /// After a rollback event, the blockchain sync will AUTOMATICALLY start sending block - /// data from the rollback point. No action is required to actually follow the rollback, unless the - /// default behavior is not desired. - pub fn subscribe_rollback(net: CardanoBlockchainId,){ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:cardano/api")] - extern "C" { - #[link_name = "subscribe-rollback"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(net.clone() as i32); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Fetch a block from the requested blockchain at the requested slot. - /// - /// **Parameters** - /// - /// - `net` : The blockchain network to get a block from. - /// - `whence` : Which block to get. - /// - /// **Returns** - /// - /// - `cardano-block` : The block requested. - /// - `fetch-error` : An error if the block can not be fetched. - /// - /// **Notes** - /// - /// Fetching a block does not require the blockchain to be subscribed, or for blocks to be - /// being followed and generating events. - /// It also will not alter the automatic fetching of blocks in any way, and happens in parallel - /// to automated block fetch. - pub fn fetch_block(net: CardanoBlockchainId,whence: &Slot,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let (result2_0,result2_1,result2_2,result2_3,) = match whence { - Slot::Genesis=> { - (0i32, 0i64, ::core::ptr::null_mut(), 0usize) - } - Slot::Point(e) => { - let (t0_0, t0_1, ) = e; - let vec1 = t0_1; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - - (1i32, _rt::as_i64(t0_0), ptr1.cast_mut(), len1) - }, - Slot::Tip=> { - (2i32, 0i64, ::core::ptr::null_mut(), 0usize) - } - Slot::Continue=> { - (3i32, 0i64, ::core::ptr::null_mut(), 0usize) - } - }; - let ptr3 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:cardano/api")] - extern "C" { - #[link_name = "fetch-block"] - fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(net.clone() as i32, result2_0, result2_1, result2_2, result2_3, ptr3); - let l4 = i32::from(*ptr3.add(0).cast::()); - match l4 { - 0 => { - let e = { - let l5 = *ptr3.add(4).cast::<*mut u8>(); - let l6 = *ptr3.add(8).cast::(); - let len7 = l6; - - _rt::Vec::from_raw_parts(l5.cast(), len7, len7) - }; - Ok(e) - } - 1 => { - let e = { - let l8 = i32::from(*ptr3.add(4).cast::()); - - FetchError::_lift(l8 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get transactions from a block. - /// - /// This can be used to easily extract all transactions from a complete block. - /// - /// **Parameters** - /// - /// - `block` : The blockchain data to extract transactions from. - /// - /// **Returns** - /// - /// - a list of all transactions in the block, in the order they appear in the block. - /// - /// **Notes** - /// - /// This function exists to support `fetch-block`. - /// Transactions from subscribed block events, should be processed as transaction events. - pub fn get_txns(block: &CardanoBlock,) -> _rt::Vec::{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let vec0 = block; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:cardano/api")] - extern "C" { - #[link_name = "get-txns"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = *ptr1.add(0).cast::<*mut u8>(); - let l3 = *ptr1.add(4).cast::(); - let base7 = l2; - let len7 = l3; - let mut result7 = _rt::Vec::with_capacity(len7); - for i in 0..len7 { - let base = base7.add(i * 8); - let e7 = { - let l4 = *base.add(0).cast::<*mut u8>(); - let l5 = *base.add(4).cast::(); - let len6 = l5; - - _rt::Vec::from_raw_parts(l4.cast(), len6, len6) - }; - result7.push(e7); - } - _rt::cabi_dealloc(base7, len7 * 8, 4); - result7 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Post a transactions to the blockchain. - /// - /// This can be used to post a pre-formed transaction to the required blockchain. - /// - /// **Parameters** - /// - /// - `net` : The blockchain to post the transaction to. - /// - `txn` : The transaction data, ready to submit. - /// - /// **Returns** - /// - /// - An error if the transaction can not be posted. - /// - /// **Notes** - /// - /// This is proposed functionality, and is not yet active. - /// All calls to this function will return `post-txn-not-allowed` error. - pub fn post_txn(net: CardanoBlockchainId,txn: &CardanoTxn,) -> Result<(),TxnError>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = txn; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:cardano/api")] - extern "C" { - #[link_name = "post-txn"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(net.clone() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr1.add(1).cast::()); - - TxnError::_lift(l3 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - - } - - } - #[allow(dead_code)] - pub mod cbor { - #[allow(dead_code, clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - pub type Bstr = super::super::super::hermes::binary::api::Bstr; - /// CBOR is a binary cbor data type. - /// This type is used to indicate the binary array MUST be CBOR data. - pub type Cbor = Bstr; - - } - - } - #[allow(dead_code)] - pub mod cron { - #[allow(dead_code, clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - pub type Instant = super::super::super::wasi::clocks::monotonic_clock::Instant; - /// A Tag used to mark a delivered cron event. - pub type CronEventTag = _rt::String; - /// A cron schedule in crontab format. - pub type CronSched = _rt::String; - /// A tagged crontab entry - /// It is valid for multiple crontab entries at the same time to have different tags. - /// It is valid for crontab entries at different times to have the same tag. - /// BUT there can only ever be 1 crontab entry at a specified time with a specified tag. - /// ie, `when` + `tag` is uniquely identifying of every crontab entry. - /// See: [crontab.5 man page](https://www.man7.org/linux/man-pages/man5/crontab.5.html) for details on cron schedule format. - #[derive(Clone)] - pub struct CronTagged { - /// The crontab entry in standard cron format. - /// The Time is ALWAYS relative to UTC and does not account for local time. - /// If Localtime adjustment is required it must be handled by the module. - pub when: CronSched, - /// The tag associated with the crontab entry. - pub tag: CronEventTag, - } - impl ::core::fmt::Debug for CronTagged { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("CronTagged").field("when", &self.when).field("tag", &self.tag).finish() - } - } - /// A discreet time entry used to help convert numeric times into crontab entries. - #[derive(Clone, Copy)] - pub enum CronComponent { - /// Maps to `*` in a cron schedule (ie, match all) - All, - /// Match an absolute time/date - At(u8), - /// Match an inclusive list of time/date values. - Range((u8,u8,)), - } - impl ::core::fmt::Debug for CronComponent { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - CronComponent::All => { - f.debug_tuple("CronComponent::All").finish() - } - CronComponent::At(e) => { - f.debug_tuple("CronComponent::At").field(e).finish() - } - CronComponent::Range(e) => { - f.debug_tuple("CronComponent::Range").field(e).finish() - } - } - } - } - /// A list of cron time components - pub type CronTime = _rt::Vec::; - #[allow(unused_unsafe, clippy::all)] - /// # Schedule Recurrent CRON event - /// - /// Cron events will be delivered to the `on-cron` event handler. - /// - /// ## Parameters - /// - /// - `entry`: The crontab entry to add. - /// - `when`: When the event triggers. Standard crontab format. - /// - `tag`: A tag which will accompany the triggered event. - /// - `retrigger`: - /// - `true`: The event will re-trigger every time the crontab entry matches until cancelled. - /// - `false`: The event will automatically cancel after it is generated once. - /// - /// ## Returns - /// - /// - `true`: Crontab added successfully. (Or the crontab event already exists) - /// - `false`: Crontab failed to be added. - /// - /// ## Note: - /// - /// If the crontab entry already exists, the retrigger flag can be changed by calling - /// this function. This could be useful where a retriggering crontab event is desired - /// to be stopped, but ONLY after it has triggered once more. - pub fn add(entry: &CronTagged,retrigger: bool,) -> bool{ - unsafe { - let CronTagged{ when:when0, tag:tag0, } = entry; - let vec1 = when0; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let vec2 = tag0; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:cron/api")] - extern "C" { - #[link_name = "add"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1.cast_mut(), len1, ptr2.cast_mut(), len2, match &retrigger { true => 1, false => 0 }); - _rt::bool_lift(ret as u8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// # Schedule A Single cron event after a fixed delay. - /// - /// Allows for easy timed wait events to be delivered without - /// requiring datetime calculations or formatting cron entries. - /// - /// ## Parameters - /// - /// - `duration`: How many nanoseconds to delay. The delay will be AT LEAST this long. - /// - `tag`: A tag which will accompany the triggered event. - /// - /// ## Returns - /// - /// - `true`: Crontab added successfully. - /// - `false`: Crontab failed to be added. - /// - /// ## Note: - /// - /// This is a convenience function which will automatically calculate the crontab - /// entry needed to trigger the event after the requested `duration`. - /// It is added as a non-retriggering event. - /// Listing the crontabs after this call will list the delay in addition to all other - /// crontab entries. - pub fn delay(duration: Instant,tag: &CronEventTag,) -> bool{ - unsafe { - let vec0 = tag; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:cron/api")] - extern "C" { - #[link_name = "delay"] - fn wit_import(_: i64, _: *mut u8, _: usize, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: *mut u8, _: usize, ) -> i32{ unreachable!() } - let ret = wit_import(_rt::as_i64(duration), ptr0.cast_mut(), len0); - _rt::bool_lift(ret as u8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// # List currently active cron schedule. - /// - /// Allows for management of scheduled cron events. - /// - /// ## Parameters - /// - /// - `tag`: Optional, the tag to limit the list to. If `none` then all crons listed. - /// - /// ## Returns - /// - /// - A list of tuples containing the scheduled crontabs and their tags, along with the current retrigger flag. - /// The list is sorted from most crontab that will trigger soonest to latest. - /// Crontabs are only listed once, in the case where a crontab may be scheduled - /// may times before a later one. - /// - `0` - `cron-tagged` - The Tagged crontab event. - /// - `1` - `bool` - The state of the retrigger flag. - pub fn ls(tag: Option<&CronEventTag>,) -> _rt::Vec::<(CronTagged,bool,)>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let (result1_0,result1_1,result1_2,) = match tag { - Some(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - - (1i32, ptr0.cast_mut(), len0) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:cron/api")] - extern "C" { - #[link_name = "ls"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(result1_0, result1_1, result1_2, ptr2); - let l3 = *ptr2.add(0).cast::<*mut u8>(); - let l4 = *ptr2.add(4).cast::(); - let base12 = l3; - let len12 = l4; - let mut result12 = _rt::Vec::with_capacity(len12); - for i in 0..len12 { - let base = base12.add(i * 20); - let e12 = { - let l5 = *base.add(0).cast::<*mut u8>(); - let l6 = *base.add(4).cast::(); - let len7 = l6; - let bytes7 = _rt::Vec::from_raw_parts(l5.cast(), len7, len7); - let l8 = *base.add(8).cast::<*mut u8>(); - let l9 = *base.add(12).cast::(); - let len10 = l9; - let bytes10 = _rt::Vec::from_raw_parts(l8.cast(), len10, len10); - let l11 = i32::from(*base.add(16).cast::()); - - (CronTagged{ - when: _rt::string_lift(bytes7), - tag: _rt::string_lift(bytes10), - }, _rt::bool_lift(l11 as u8)) - }; - result12.push(e12); - } - _rt::cabi_dealloc(base12, len12 * 20, 4); - result12 - } - } - #[allow(unused_unsafe, clippy::all)] - /// # Remove the requested crontab. - /// - /// Allows for management of scheduled cron events. - /// - /// ## Parameters - /// - /// - `when`: The crontab entry to add. Standard crontab format. - /// - `tag`: A tag which will accompany the triggered event. - /// - /// ## Returns - /// - /// - `true`: The requested crontab was deleted and will not trigger. - /// - `false`: The requested crontab does not exist. - pub fn rm(entry: &CronTagged,) -> bool{ - unsafe { - let CronTagged{ when:when0, tag:tag0, } = entry; - let vec1 = when0; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let vec2 = tag0; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:cron/api")] - extern "C" { - #[link_name = "rm"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, ) -> i32{ unreachable!() } - let ret = wit_import(ptr1.cast_mut(), len1, ptr2.cast_mut(), len2); - _rt::bool_lift(ret as u8) - } - } - #[allow(unused_unsafe, clippy::all)] - /// # Make a crontab entry from individual time values. - /// - /// Crates the properly formatted cron entry - /// from numeric cron time components. - /// Convenience function to make building cron strings simpler when they are - /// calculated from data. - /// - /// ## Parameters - /// - /// - `dow` - DayOfWeek (0-7, 0 or 7 = Sunday) - /// - `month` - Month of the year (1-12, 1 = January) - /// - `day` - Day in the month (1-31) - /// - `hour` - Hour in the day (0-23) - /// - `minute` - Minute in the hour (0-59) - /// - /// ## Returns - /// - /// - A matching `cron-sched` ready for use in the cron functions above. - /// - /// ## Note: - /// No checking is done to determine if the requested date is valid. - /// If a particular component is out of its allowable range it will be silently - /// clamped within the allowable range of each parameter. - /// Redundant entries will be removed. - /// - For example specifying a `month` as `3` and `2-4` will - /// remove the individual month and only produce the range. - pub fn mkcron(dow: &CronTime,month: &CronTime,day: &CronTime,hour: &CronTime,minute: &CronTime,) -> CronSched{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let vec1 = dow; - let len1 = vec1.len(); - let layout1 = _rt::alloc::Layout::from_size_align_unchecked(vec1.len() * 3, 1); - let result1 = if layout1.size() != 0 { - let ptr = _rt::alloc::alloc(layout1).cast::(); - if ptr.is_null() - { - _rt::alloc::handle_alloc_error(layout1); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec1.into_iter().enumerate() { - let base = result1.add(i * 3); - { - match e { - CronComponent::All=> { - { - *base.add(0).cast::() = (0i32) as u8; - } - } - CronComponent::At(e) => { - *base.add(0).cast::() = (1i32) as u8; - *base.add(1).cast::() = (_rt::as_i32(e)) as u8; - }, - CronComponent::Range(e) => { - *base.add(0).cast::() = (2i32) as u8; - let (t0_0, t0_1, ) = e; - *base.add(1).cast::() = (_rt::as_i32(t0_0)) as u8; - *base.add(2).cast::() = (_rt::as_i32(t0_1)) as u8; - }, - } - } - } - let vec3 = month; - let len3 = vec3.len(); - let layout3 = _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 3, 1); - let result3 = if layout3.size() != 0 { - let ptr = _rt::alloc::alloc(layout3).cast::(); - if ptr.is_null() - { - _rt::alloc::handle_alloc_error(layout3); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec3.into_iter().enumerate() { - let base = result3.add(i * 3); - { - match e { - CronComponent::All=> { - { - *base.add(0).cast::() = (0i32) as u8; - } - } - CronComponent::At(e) => { - *base.add(0).cast::() = (1i32) as u8; - *base.add(1).cast::() = (_rt::as_i32(e)) as u8; - }, - CronComponent::Range(e) => { - *base.add(0).cast::() = (2i32) as u8; - let (t2_0, t2_1, ) = e; - *base.add(1).cast::() = (_rt::as_i32(t2_0)) as u8; - *base.add(2).cast::() = (_rt::as_i32(t2_1)) as u8; - }, - } - } - } - let vec5 = day; - let len5 = vec5.len(); - let layout5 = _rt::alloc::Layout::from_size_align_unchecked(vec5.len() * 3, 1); - let result5 = if layout5.size() != 0 { - let ptr = _rt::alloc::alloc(layout5).cast::(); - if ptr.is_null() - { - _rt::alloc::handle_alloc_error(layout5); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec5.into_iter().enumerate() { - let base = result5.add(i * 3); - { - match e { - CronComponent::All=> { - { - *base.add(0).cast::() = (0i32) as u8; - } - } - CronComponent::At(e) => { - *base.add(0).cast::() = (1i32) as u8; - *base.add(1).cast::() = (_rt::as_i32(e)) as u8; - }, - CronComponent::Range(e) => { - *base.add(0).cast::() = (2i32) as u8; - let (t4_0, t4_1, ) = e; - *base.add(1).cast::() = (_rt::as_i32(t4_0)) as u8; - *base.add(2).cast::() = (_rt::as_i32(t4_1)) as u8; - }, - } - } - } - let vec7 = hour; - let len7 = vec7.len(); - let layout7 = _rt::alloc::Layout::from_size_align_unchecked(vec7.len() * 3, 1); - let result7 = if layout7.size() != 0 { - let ptr = _rt::alloc::alloc(layout7).cast::(); - if ptr.is_null() - { - _rt::alloc::handle_alloc_error(layout7); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec7.into_iter().enumerate() { - let base = result7.add(i * 3); - { - match e { - CronComponent::All=> { - { - *base.add(0).cast::() = (0i32) as u8; - } - } - CronComponent::At(e) => { - *base.add(0).cast::() = (1i32) as u8; - *base.add(1).cast::() = (_rt::as_i32(e)) as u8; - }, - CronComponent::Range(e) => { - *base.add(0).cast::() = (2i32) as u8; - let (t6_0, t6_1, ) = e; - *base.add(1).cast::() = (_rt::as_i32(t6_0)) as u8; - *base.add(2).cast::() = (_rt::as_i32(t6_1)) as u8; - }, - } - } - } - let vec9 = minute; - let len9 = vec9.len(); - let layout9 = _rt::alloc::Layout::from_size_align_unchecked(vec9.len() * 3, 1); - let result9 = if layout9.size() != 0 { - let ptr = _rt::alloc::alloc(layout9).cast::(); - if ptr.is_null() - { - _rt::alloc::handle_alloc_error(layout9); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec9.into_iter().enumerate() { - let base = result9.add(i * 3); - { - match e { - CronComponent::All=> { - { - *base.add(0).cast::() = (0i32) as u8; - } - } - CronComponent::At(e) => { - *base.add(0).cast::() = (1i32) as u8; - *base.add(1).cast::() = (_rt::as_i32(e)) as u8; - }, - CronComponent::Range(e) => { - *base.add(0).cast::() = (2i32) as u8; - let (t8_0, t8_1, ) = e; - *base.add(1).cast::() = (_rt::as_i32(t8_0)) as u8; - *base.add(2).cast::() = (_rt::as_i32(t8_1)) as u8; - }, - } - } - } - let ptr10 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:cron/api")] - extern "C" { - #[link_name = "mkcron"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(result1, len1, result3, len3, result5, len5, result7, len7, result9, len9, ptr10); - let l11 = *ptr10.add(0).cast::<*mut u8>(); - let l12 = *ptr10.add(4).cast::(); - let len13 = l12; - let bytes13 = _rt::Vec::from_raw_parts(l11.cast(), len13, len13); - if layout1.size() != 0 { - _rt::alloc::dealloc(result1.cast(), layout1); - } - if layout3.size() != 0 { - _rt::alloc::dealloc(result3.cast(), layout3); - } - if layout5.size() != 0 { - _rt::alloc::dealloc(result5.cast(), layout5); - } - if layout7.size() != 0 { - _rt::alloc::dealloc(result7.cast(), layout7); - } - if layout9.size() != 0 { - _rt::alloc::dealloc(result9.cast(), layout9); - } - _rt::string_lift(bytes13) - } - } - - } - - } - #[allow(dead_code)] - pub mod crypto { - #[allow(dead_code, clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - pub type Bstr = super::super::super::hermes::binary::api::Bstr; - pub type B256 = super::super::super::hermes::binary::api::B256; - pub type B512 = super::super::super::hermes::binary::api::B512; - /// Errors that can occurs. - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum Errno { - PrefixTooLong, - /// The prefix is longer than the maximum allowed length, max is 3. - InvalidMnemonicLength, - /// The mnemonic length is not a multiple of 3 or not in the range of 12 - 24. - WordNotFound, - /// A word in the mnemonic is not found in the word list. - InvalidMnemonic, - /// The mnemonic is invalid. - InvalidDerivationalPath, - /// The derivational path is invalid. - GenerateEntropyFailed, - /// Failed to generate entropy. - UnsupportedLanguage, - } - impl Errno{ - pub fn name(&self) -> &'static str { - match self { - Errno::PrefixTooLong => "prefix-too-long", - Errno::InvalidMnemonicLength => "invalid-mnemonic-length", - Errno::WordNotFound => "word-not-found", - Errno::InvalidMnemonic => "invalid-mnemonic", - Errno::InvalidDerivationalPath => "invalid-derivational-path", - Errno::GenerateEntropyFailed => "generate-entropy-failed", - Errno::UnsupportedLanguage => "unsupported-language", - } - } - pub fn message(&self) -> &'static str { - match self { - Errno::PrefixTooLong => "", - Errno::InvalidMnemonicLength => "The prefix is longer than the maximum allowed length, max is 3.", - Errno::WordNotFound => "The mnemonic length is not a multiple of 3 or not in the range of 12 - 24.", - Errno::InvalidMnemonic => "A word in the mnemonic is not found in the word list.", - Errno::InvalidDerivationalPath => "The mnemonic is invalid.", - Errno::GenerateEntropyFailed => "The derivational path is invalid.", - Errno::UnsupportedLanguage => "Failed to generate entropy.", - } - } - } - impl ::core::fmt::Debug for Errno{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Errno") - .field("code", &(*self as i32)) - .field("name", &self.name()) - .field("message", &self.message()) - .finish() - } - } - impl ::core::fmt::Display for Errno{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{} (error {})", self.name(), *self as i32) - } - } - - impl std::error::Error for Errno {} - - impl Errno{ - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> Errno{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => Errno::PrefixTooLong, - 1 => Errno::InvalidMnemonicLength, - 2 => Errno::WordNotFound, - 3 => Errno::InvalidMnemonic, - 4 => Errno::InvalidDerivationalPath, - 5 => Errno::GenerateEntropyFailed, - 6 => Errno::UnsupportedLanguage, - - _ => panic!("invalid enum discriminant"), - } - } - } - - /// bip32-ed25519 Public Key - pub type Bip32Ed25519PublicKey = B256; - /// bip32-ed25519 Signature - pub type Bip32Ed25519Signature = B512; - /// Mnemonic - pub type MnemonicPhrase = _rt::Vec::<_rt::String>; - /// Passphrase - pub type Passphrase = _rt::Vec::<_rt::String>; - /// Derivation path - pub type Path = _rt::String; - pub type Prefix = _rt::Vec::<_rt::String>; - - #[derive(Debug)] - #[repr(transparent)] - pub struct Bip32Ed25519{ - handle: _rt::Resource, - } - - impl Bip32Ed25519{ - #[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 Bip32Ed25519{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "hermes:crypto/api")] - extern "C" { - #[link_name = "[resource-drop]bip32-ed25519"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - #[allow(unused_unsafe, clippy::all)] - /// # Generate BIP39 Mnemonic Function - /// - /// Generate a new BIP39 mnemonic phrase with the given - /// size, prefix and language. - /// - /// ## Parameters - /// - /// `size` : The size of the mnemonic. Must be a multiple of 3 and in the range of 12 - 24. - /// `prefix` : The prefix for the mnemonic. Must be a list of 1 - 3 words. - /// `language` : Optional. The language to use for the mnemonic. - /// If not provided, the default language is used. - /// - /// ## Returns - /// - /// - Either a list of mnemonic words. - /// - Or an error if the mnemonic could not be generated: - /// - `prefix-too-long` : The prefix is longer than the maximum allowed length, max is 3. - /// - `invalid-mnemonic-length` : The mnemonic length is not a multiple of 3 or not in the range of 12 - 24. - /// - `word-not-found` : A word in the mnemonic is not found in the word list. - /// - `generate-entropy-failed` : Failed to generate entropy. - pub fn generate_mnemonic(size: u8,prefix: &Prefix,language: Option<&str>,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec1 = prefix; - let len1 = vec1.len(); - let layout1 = _rt::alloc::Layout::from_size_align_unchecked(vec1.len() * 8, 4); - let result1 = if layout1.size() != 0 { - let ptr = _rt::alloc::alloc(layout1).cast::(); - if ptr.is_null() - { - _rt::alloc::handle_alloc_error(layout1); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec1.into_iter().enumerate() { - let base = result1.add(i * 8); - { - let vec0 = e; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - *base.add(4).cast::() = len0; - *base.add(0).cast::<*mut u8>() = ptr0.cast_mut(); - } - } - let (result3_0,result3_1,result3_2,) = match language { - Some(e) => { - let vec2 = e; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - - (1i32, ptr2.cast_mut(), len2) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let ptr4 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:crypto/api")] - extern "C" { - #[link_name = "generate-mnemonic"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(_rt::as_i32(&size), result1, len1, result3_0, result3_1, result3_2, ptr4); - let l5 = i32::from(*ptr4.add(0).cast::()); - if layout1.size() != 0 { - _rt::alloc::dealloc(result1.cast(), layout1); - } - match l5 { - 0 => { - let e = { - let l6 = *ptr4.add(4).cast::<*mut u8>(); - let l7 = *ptr4.add(8).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); - - result11 - }; - Ok(e) - } - 1 => { - let e = { - let l12 = i32::from(*ptr4.add(4).cast::()); - - Errno::_lift(l12 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - impl Bip32Ed25519 { - #[allow(unused_unsafe, clippy::all)] - /// Create a new BIP32-Ed25519 Crypto resource - /// - /// **Parameters** - /// - /// - `mnemonic-phrase` : BIP39 mnemonic. - /// - `passphrase` : Optional BIP39 passphrase. - pub fn new(mnemonic: &MnemonicPhrase,passphrase: Option<&Passphrase>,) -> Self{ - unsafe { - let mut cleanup_list = _rt::Vec::new(); - let vec1 = mnemonic; - let len1 = vec1.len(); - let layout1 = _rt::alloc::Layout::from_size_align_unchecked(vec1.len() * 8, 4); - let result1 = if layout1.size() != 0 { - let ptr = _rt::alloc::alloc(layout1).cast::(); - if ptr.is_null() - { - _rt::alloc::handle_alloc_error(layout1); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec1.into_iter().enumerate() { - let base = result1.add(i * 8); - { - let vec0 = e; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - *base.add(4).cast::() = len0; - *base.add(0).cast::<*mut u8>() = ptr0.cast_mut(); - } - } - let (result4_0,result4_1,result4_2,) = match passphrase { - Some(e) => { - let vec3 = e; - let len3 = vec3.len(); - let layout3 = _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 4); - let result3 = if layout3.size() != 0 { - let ptr = _rt::alloc::alloc(layout3).cast::(); - if ptr.is_null() - { - _rt::alloc::handle_alloc_error(layout3); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec3.into_iter().enumerate() { - let base = result3.add(i * 8); - { - let vec2 = e; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - *base.add(4).cast::() = len2; - *base.add(0).cast::<*mut u8>() = ptr2.cast_mut(); - } - } - cleanup_list.extend_from_slice(&[(result3, layout3),]); - - (1i32, result3, len3) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:crypto/api")] - extern "C" { - #[link_name = "[constructor]bip32-ed25519"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } - let ret = wit_import(result1, len1, result4_0, result4_1, result4_2); - if layout1.size() != 0 { - _rt::alloc::dealloc(result1.cast(), layout1); - } - for (ptr, layout) in cleanup_list { - - if layout.size() != 0 { - - _rt::alloc::dealloc(ptr.cast(), layout); - - } - - } - Bip32Ed25519::from_handle(ret as u32) - } - } - } - impl Bip32Ed25519 { - #[allow(unused_unsafe, clippy::all)] - /// Get the public key for this private key. - pub fn public_key(&self,) -> Bip32Ed25519PublicKey{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 32]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 32]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:crypto/api")] - extern "C" { - #[link_name = "[method]bip32-ed25519.public-key"] - 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 = *ptr0.add(0).cast::(); - let l2 = *ptr0.add(8).cast::(); - let l3 = *ptr0.add(16).cast::(); - let l4 = *ptr0.add(24).cast::(); - (l1 as u64, l2 as u64, l3 as u64, l4 as u64) - } - } - } - impl Bip32Ed25519 { - #[allow(unused_unsafe, clippy::all)] - /// Sign data with the Private key, and return it. - /// - /// **Parameters** - /// - /// - `data` : The data to sign. - pub fn sign_data(&self,data: &Bstr,) -> Bip32Ed25519Signature{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 64]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 64]); - let vec0 = data; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:crypto/api")] - extern "C" { - #[link_name = "[method]bip32-ed25519.sign-data"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = *ptr1.add(0).cast::(); - let l3 = *ptr1.add(8).cast::(); - let l4 = *ptr1.add(16).cast::(); - let l5 = *ptr1.add(24).cast::(); - let l6 = *ptr1.add(32).cast::(); - let l7 = *ptr1.add(40).cast::(); - let l8 = *ptr1.add(48).cast::(); - let l9 = *ptr1.add(56).cast::(); - (l2 as u64, l3 as u64, l4 as u64, l5 as u64, l6 as u64, l7 as u64, l8 as u64, l9 as u64) - } - } - } - impl Bip32Ed25519 { - #[allow(unused_unsafe, clippy::all)] - /// Check a signature on a set of data. - /// - /// **Parameters** - /// - /// - `data` : The data to check. - /// - `sig` : The signature to check. - /// - /// **Returns** - /// - /// - `true` : Signature checked OK. - /// - `false` : Signature check failed. - pub fn check_sig(&self,data: &Bstr,sig: Bip32Ed25519Signature,) -> bool{ - unsafe { - let vec0 = data; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let (t1_0, t1_1, t1_2, t1_3, t1_4, t1_5, t1_6, t1_7, ) = sig; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:crypto/api")] - extern "C" { - #[link_name = "[method]bip32-ed25519.check-sig"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64, _: i64, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, ptr0.cast_mut(), len0, _rt::as_i64(t1_0), _rt::as_i64(t1_1), _rt::as_i64(t1_2), _rt::as_i64(t1_3), _rt::as_i64(t1_4), _rt::as_i64(t1_5), _rt::as_i64(t1_6), _rt::as_i64(t1_7)); - _rt::bool_lift(ret as u8) - } - } - } - impl Bip32Ed25519 { - #[allow(unused_unsafe, clippy::all)] - /// Derive a new private key from the current private key. - /// - /// **Parameters** - /// - /// - `path` : Derivation path. - /// - /// Note: uses BIP32 HD key derivation. - pub fn derive(&self,path: &Path,) -> Bip32Ed25519{ - unsafe { - let vec0 = path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:crypto/api")] - extern "C" { - #[link_name = "[method]bip32-ed25519.derive"] - fn wit_import(_: i32, _: *mut u8, _: usize, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, ptr0.cast_mut(), len0); - Bip32Ed25519::from_handle(ret as u32) - } - } - } - - } - - } - #[allow(dead_code)] - pub mod hash { - #[allow(dead_code, clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - pub type Bstr = super::super::super::hermes::binary::api::Bstr; - /// Errors that can occur during hashing. - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum Errno { - KeyTooBig, - /// The key exceeds the supported size of the hash function. - HashTooBig, - /// The hash size requested is larger than supported by the hash function. - SaltTooBig, - /// The salt exceeds the supported size of the hash function. - PersonalTooBig, - /// The personal exceeds the supported size of the hash function. - InvalidDigestByteLength, - } - impl Errno{ - pub fn name(&self) -> &'static str { - match self { - Errno::KeyTooBig => "key-too-big", - Errno::HashTooBig => "hash-too-big", - Errno::SaltTooBig => "salt-too-big", - Errno::PersonalTooBig => "personal-too-big", - Errno::InvalidDigestByteLength => "invalid-digest-byte-length", - } - } - pub fn message(&self) -> &'static str { - match self { - Errno::KeyTooBig => "", - Errno::HashTooBig => "The key exceeds the supported size of the hash function.", - Errno::SaltTooBig => "The hash size requested is larger than supported by the hash function.", - Errno::PersonalTooBig => "The salt exceeds the supported size of the hash function.", - Errno::InvalidDigestByteLength => "The personal exceeds the supported size of the hash function.", - } - } - } - impl ::core::fmt::Debug for Errno{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Errno") - .field("code", &(*self as i32)) - .field("name", &self.name()) - .field("message", &self.message()) - .finish() - } - } - impl ::core::fmt::Display for Errno{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{} (error {})", self.name(), *self as i32) - } - } - - impl std::error::Error for Errno {} - - impl Errno{ - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> Errno{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => Errno::KeyTooBig, - 1 => Errno::HashTooBig, - 2 => Errno::SaltTooBig, - 3 => Errno::PersonalTooBig, - 4 => Errno::InvalidDigestByteLength, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[allow(unused_unsafe, clippy::all)] - /// # BLAKE2s Hash Function - /// - /// Hash a binary buffer with BLAKE2s. - /// - /// ## Parameters - /// - /// - `buf`: The binary data buffer to hash. - /// - `outlen`: Optional. The size of the digest. - /// If the outlen is not defined, it defaults to 32. - /// - /// ## Returns - /// - /// - Either a buffer the size requested, with the hash. - /// - Or an error: - /// - `hash_too_big` if `outlen` is specified and is > 32 bytes. - /// - `invalid_digest_byte_length` if `outlen` is specified and is = 0. - pub fn blake2s(buf: &Bstr,outlen: Option,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = buf; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let (result1_0,result1_1,) = match outlen { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - };let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:hash/api")] - extern "C" { - #[link_name = "blake2s"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, result1_0, result1_1, ptr2); - let l3 = i32::from(*ptr2.add(0).cast::()); - match l3 { - 0 => { - let e = { - let l4 = *ptr2.add(4).cast::<*mut u8>(); - let l5 = *ptr2.add(8).cast::(); - let len6 = l5; - - _rt::Vec::from_raw_parts(l4.cast(), len6, len6) - }; - Ok(e) - } - 1 => { - let e = { - let l7 = i32::from(*ptr2.add(4).cast::()); - - Errno::_lift(l7 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// # BLAKE2sMac Hash Function - /// - /// Hash a binary buffer with BLAKE2s with MAC (Message Authentication Code) mode. - /// - /// ## Parameters - /// - /// - `buf`: The binary data buffer to hash. - /// - `outlen`: Optional. The size of the digest. - /// If the outlen is not defined, it defaults to 32. - /// - `key`: The key to use with the hash. - /// With MAC mode, key is needed to be defined - /// Should not be > 32 bytes. - /// - `salt`: Optional. Salt uses to increase the randomness and - /// uniqueness of the hash output - /// Should not be > 8 bytes. - /// If not defined, salt is not used. - /// - `personal`: Optional. Personal allows to - /// add customization to the hash function behavior. - /// Should not be > 8 bytes. - /// If not defined, personal is not used. - /// - /// ## Returns - /// - /// - Either a buffer the size requested, with the hash. - /// - Or an error: - /// - `key_too_big` if `key` is > 32 bytes. - /// - `hash_too_big` if `outlen` is specified and is > 32 bytes. - /// - `salt_too_big` if `salt` is specified and is > 8 bytes. - /// - `personal_too_big` if `personal` is specified and is > 8 bytes. - /// - /// ## Note: - /// - /// `key` length is checked before `outlen` so if both sizes are invalid, only - /// `key_too_big` will be returned. - /// If `salt` length exceeds 8 bytes, `salt_too_big` will be returned. - /// if `personal` length exceeds 8 bytes, `personal_too_big` will be returned. - pub fn blake2smac(buf: &Bstr,outlen: Option,key: &Bstr,salt: Option<&Bstr>,personal: Option<&Bstr>,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = buf; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let (result1_0,result1_1,) = match outlen { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - };let vec2 = key; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - let (result4_0,result4_1,result4_2,) = match salt { - Some(e) => { - let vec3 = e; - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - - (1i32, ptr3.cast_mut(), len3) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let (result6_0,result6_1,result6_2,) = match personal { - Some(e) => { - let vec5 = e; - let ptr5 = vec5.as_ptr().cast::(); - let len5 = vec5.len(); - - (1i32, ptr5.cast_mut(), len5) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let ptr7 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:hash/api")] - extern "C" { - #[link_name = "blake2smac"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, result1_0, result1_1, ptr2.cast_mut(), len2, result4_0, result4_1, result4_2, result6_0, result6_1, result6_2, ptr7); - let l8 = i32::from(*ptr7.add(0).cast::()); - match l8 { - 0 => { - let e = { - let l9 = *ptr7.add(4).cast::<*mut u8>(); - let l10 = *ptr7.add(8).cast::(); - let len11 = l10; - - _rt::Vec::from_raw_parts(l9.cast(), len11, len11) - }; - Ok(e) - } - 1 => { - let e = { - let l12 = i32::from(*ptr7.add(4).cast::()); - - Errno::_lift(l12 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// # BLAKE2b Hash Function - /// - /// Hash a binary buffer with BLAKE2b. - /// - /// ## Parameters - /// - /// - `buf`: The binary data buffer to hash. - /// - `outlen`: Optional. The size of the digest. - /// If the outlen is not defined, it defaults to 64. - /// - /// ## Returns - /// - /// - Either a buffer the size requested, with the hash. - /// - Or an error: - /// - `hash_too_big` if `outlen` is specified and is > 64 bytes. - /// - `invalid_digest_byte_length` if `outlen` is specified and is = 0. - pub fn blake2b(buf: &Bstr,outlen: Option,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = buf; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let (result1_0,result1_1,) = match outlen { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - };let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:hash/api")] - extern "C" { - #[link_name = "blake2b"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, result1_0, result1_1, ptr2); - let l3 = i32::from(*ptr2.add(0).cast::()); - match l3 { - 0 => { - let e = { - let l4 = *ptr2.add(4).cast::<*mut u8>(); - let l5 = *ptr2.add(8).cast::(); - let len6 = l5; - - _rt::Vec::from_raw_parts(l4.cast(), len6, len6) - }; - Ok(e) - } - 1 => { - let e = { - let l7 = i32::from(*ptr2.add(4).cast::()); - - Errno::_lift(l7 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// # BLAKE2bMac Hash Function - /// - /// Hash a binary buffer with BLAKE2b with MAC (Message Authentication Code) mode. - /// - /// ## Parameters - /// - /// - `buf`: The binary data buffer to hash. - /// - `outlen`: Optional. The size of the digest. - /// If the outlen is not defined, it defaults to 64. - /// - `key`: The key to use with the hash. - /// With MAC mode, key is needed to be defined - /// Should not be > 64 bytes. - /// - `salt`: Optional. Salt uses to increase the randomness and - /// uniqueness of the hash output - /// Should not be > 16 bytes. - /// If not defined, salt is not used. - /// - `personal`: Optional. Personal allows to - /// add customization to the hash function behavior. - /// Should not be > 16 bytes. - /// If not defined, personal is not used. - /// - /// ## Returns - /// - /// - Either a buffer the size requested, with the hash. - /// - Or an error: - /// - `key_too_big` if `key` is specified and is > 64 bytes. - /// - `hash_too_big` if `outlen` is specified and is > 64 bytes. - /// - `salt_too_big` if `salt` is specified and is > 16 bytes. - /// - `personal_too_big` if `personal` is specified and is > 16 bytes. - /// - /// ## Note: - /// - /// `key` length is checked before `outlen` so if both sizes are invalid, only - /// `key_too_big` will be returned. - /// If `salt` length exceeds 16 bytes, `salt_too_big` will be returned. - /// if `personal` length exceeds 16 bytes, `personal_too_big` will be returned. - pub fn blake2bmac(buf: &Bstr,outlen: Option,key: &Bstr,salt: Option<&Bstr>,personal: Option<&Bstr>,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = buf; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let (result1_0,result1_1,) = match outlen { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - };let vec2 = key; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - let (result4_0,result4_1,result4_2,) = match salt { - Some(e) => { - let vec3 = e; - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - - (1i32, ptr3.cast_mut(), len3) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let (result6_0,result6_1,result6_2,) = match personal { - Some(e) => { - let vec5 = e; - let ptr5 = vec5.as_ptr().cast::(); - let len5 = vec5.len(); - - (1i32, ptr5.cast_mut(), len5) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let ptr7 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:hash/api")] - extern "C" { - #[link_name = "blake2bmac"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, result1_0, result1_1, ptr2.cast_mut(), len2, result4_0, result4_1, result4_2, result6_0, result6_1, result6_2, ptr7); - let l8 = i32::from(*ptr7.add(0).cast::()); - match l8 { - 0 => { - let e = { - let l9 = *ptr7.add(4).cast::<*mut u8>(); - let l10 = *ptr7.add(8).cast::(); - let len11 = l10; - - _rt::Vec::from_raw_parts(l9.cast(), len11, len11) - }; - Ok(e) - } - 1 => { - let e = { - let l12 = i32::from(*ptr7.add(4).cast::()); - - Errno::_lift(l12 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// # BLAKE3 Hash Function - /// - /// Hash a binary buffer with BLAKE3. - /// - /// ## Parameters - /// - /// - `buf`: The binary data buffer to hash. - /// - `outlen`: Optional. The size of the digest. - /// If the outlen is not defined, it defaults to 32. - /// - `key`: Optional. The key to use with the hash. - /// If not defined, the hash is not keyed. - /// Should not be > 32 bytes. - /// - /// ## Returns - /// - /// - Either a buffer the size requested, with the hash. - /// - Or an error: - /// - `key_too_big` if `key` is specified and is > 32 bytes. - /// - `hash_too_big` if `outlen` is specified and is > 32 bytes. - /// - /// ## Note: - /// - /// `key` length is checked before `outlen` so if both sizes are invalid, only - /// `key_too_big` will be returned. - pub fn blake3(buf: &Bstr,outlen: Option,key: Option<&Bstr>,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = buf; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let (result1_0,result1_1,) = match outlen { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - };let (result3_0,result3_1,result3_2,) = match key { - Some(e) => { - let vec2 = e; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - - (1i32, ptr2.cast_mut(), len2) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let ptr4 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:hash/api")] - extern "C" { - #[link_name = "blake3"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, result1_0, result1_1, result3_0, result3_1, result3_2, ptr4); - let l5 = i32::from(*ptr4.add(0).cast::()); - match l5 { - 0 => { - let e = { - let l6 = *ptr4.add(4).cast::<*mut u8>(); - let l7 = *ptr4.add(8).cast::(); - let len8 = l7; - - _rt::Vec::from_raw_parts(l6.cast(), len8, len8) - }; - Ok(e) - } - 1 => { - let e = { - let l9 = i32::from(*ptr4.add(4).cast::()); - - Errno::_lift(l9 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - - } - - } - #[allow(dead_code)] - pub mod http_request { - #[allow(dead_code, clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - /// Error codes. - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum ErrorCode { - /// Internal error when trying to send the request - Internal, - } - impl ErrorCode{ - pub fn name(&self) -> &'static str { - match self { - ErrorCode::Internal => "internal", - } - } - pub fn message(&self) -> &'static str { - match self { - ErrorCode::Internal => "Internal error when trying to send the request", - } - } - } - impl ::core::fmt::Debug for ErrorCode{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ErrorCode") - .field("code", &(*self as i32)) - .field("name", &self.name()) - .field("message", &self.message()) - .finish() - } - } - impl ::core::fmt::Display for ErrorCode{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{} (error {})", self.name(), *self as i32) - } - } - - impl std::error::Error for ErrorCode {} - - impl ErrorCode{ - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> ErrorCode{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => ErrorCode::Internal, - - _ => panic!("invalid enum discriminant"), - } - } - } - - /// HTTP request payload (caller manages full body formatting) - #[derive(Clone)] - pub struct Payload { - /// Host URI (scheme + domain, no path), e.g., "http://example.com" - /// TODO[RC]: Invalid when unspecified - pub host_uri: _rt::String, - /// Port (e.g., 80 for HTTP, 443 for HTTPS) - pub port: u16, - /// Raw HTTP request (including method, path, headers, and body) - pub body: _rt::Vec::, - /// Optional request identifier for tracking - pub request_id: Option<_rt::String>, - } - impl ::core::fmt::Debug for Payload { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Payload").field("host-uri", &self.host_uri).field("port", &self.port).field("body", &self.body).field("request-id", &self.request_id).finish() - } - } - #[allow(unused_unsafe, clippy::all)] - /// Send an HTTP request. - /// - /// **Parameters** - /// - /// `p` : The payload of a request to be sent. - /// - /// **Returns** - /// - /// `true` if the request was sent successfully, `false` otherwise. - pub fn send(p: &Payload,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let Payload{ host_uri:host_uri0, port:port0, body:body0, request_id:request_id0, } = p; - let vec1 = host_uri0; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let vec2 = body0; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - let (result4_0,result4_1,result4_2,) = match request_id0 { - Some(e) => { - let vec3 = e; - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - - (1i32, ptr3.cast_mut(), len3) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let ptr5 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:http-request/api")] - extern "C" { - #[link_name = "send"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr1.cast_mut(), len1, _rt::as_i32(port0), ptr2.cast_mut(), len2, result4_0, result4_1, result4_2, ptr5); - let l6 = i32::from(*ptr5.add(0).cast::()); - match l6 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l7 = i32::from(*ptr5.add(1).cast::()); - - ErrorCode::_lift(l7 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - - } - - } - #[allow(dead_code)] - pub mod ipfs { - #[allow(dead_code, clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - /// A DHT key. - pub type DhtKey = _rt::Vec::; - /// A DHT value. - pub type DhtValue = _rt::Vec::; - /// The binary contents of an IPFS file. - pub type IpfsFile = _rt::Vec::; - /// A path to an IPFS file. - pub type IpfsPath = _rt::String; - /// PubSub Message Data - pub type MessageData = _rt::Vec::; - /// PubSub Message ID - pub type MessageId = _rt::Vec::; - /// The ID of a peer. - pub type PeerId = _rt::String; - /// A PubSub topic. - pub type PubsubTopic = _rt::String; - /// This is content that can be validated. - #[derive(Clone)] - pub enum IpfsContent { - /// DHT value - Dht((DhtKey,DhtValue,)), - Pubsub((PubsubTopic,MessageData,)), - } - impl ::core::fmt::Debug for IpfsContent { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - IpfsContent::Dht(e) => { - f.debug_tuple("IpfsContent::Dht").field(e).finish() - } - IpfsContent::Pubsub(e) => { - f.debug_tuple("IpfsContent::Pubsub").field(e).finish() - } - } - } - } - /// A PubSub message from a topic subscription. - #[derive(Clone)] - pub struct PubsubMessage { - /// The topic that the message was received on. - pub topic: PubsubTopic, - /// The contents of the message. - pub message: MessageData, - /// Optional Peer ID that published the message. - pub publisher: Option, - } - impl ::core::fmt::Debug for PubsubMessage { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("PubsubMessage").field("topic", &self.topic).field("message", &self.message).field("publisher", &self.publisher).finish() - } - } - /// Errors that occur in IPFS networking. - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum Errno { - /// Unable to get DHT value. - DhtGetError, - /// Unable to put DHT value. - DhtPutError, - /// Unable to publish file to IPFS. - FileAddError, - /// Unable to get file from IPFS. - FileGetError, - /// Unable to pin file. - FilePinError, - /// Invalid CID. - InvalidCid, - /// Invalid DHT key. - InvalidDhtKey, - /// Invalid DHT value. - InvalidDhtValue, - /// Unable to parse a valid IPFS path. - InvalidIpfsPath, - /// Invalid Peer ID. - InvalidPeerId, - /// Invalid PubSub message. - InvalidPubsubMessage, - /// Unable to evict peer. - PeerEvictionError, - /// Unable to publish to IPFS topic. - PubsubPublishError, - /// Unable to subscribe to IPFS topic. - PubsubSubscribeError, - /// IPFS service is unavailable. - ServiceUnavailable, - } - impl Errno{ - pub fn name(&self) -> &'static str { - match self { - Errno::DhtGetError => "dht-get-error", - Errno::DhtPutError => "dht-put-error", - Errno::FileAddError => "file-add-error", - Errno::FileGetError => "file-get-error", - Errno::FilePinError => "file-pin-error", - Errno::InvalidCid => "invalid-cid", - Errno::InvalidDhtKey => "invalid-dht-key", - Errno::InvalidDhtValue => "invalid-dht-value", - Errno::InvalidIpfsPath => "invalid-ipfs-path", - Errno::InvalidPeerId => "invalid-peer-id", - Errno::InvalidPubsubMessage => "invalid-pubsub-message", - Errno::PeerEvictionError => "peer-eviction-error", - Errno::PubsubPublishError => "pubsub-publish-error", - Errno::PubsubSubscribeError => "pubsub-subscribe-error", - Errno::ServiceUnavailable => "service-unavailable", - } - } - pub fn message(&self) -> &'static str { - match self { - Errno::DhtGetError => "Unable to get DHT value.", - Errno::DhtPutError => "Unable to put DHT value.", - Errno::FileAddError => "Unable to publish file to IPFS.", - Errno::FileGetError => "Unable to get file from IPFS.", - Errno::FilePinError => "Unable to pin file.", - Errno::InvalidCid => "Invalid CID.", - Errno::InvalidDhtKey => "Invalid DHT key.", - Errno::InvalidDhtValue => "Invalid DHT value.", - Errno::InvalidIpfsPath => "Unable to parse a valid IPFS path.", - Errno::InvalidPeerId => "Invalid Peer ID.", - Errno::InvalidPubsubMessage => "Invalid PubSub message.", - Errno::PeerEvictionError => "Unable to evict peer.", - Errno::PubsubPublishError => "Unable to publish to IPFS topic.", - Errno::PubsubSubscribeError => "Unable to subscribe to IPFS topic.", - Errno::ServiceUnavailable => "IPFS service is unavailable.", - } - } - } - impl ::core::fmt::Debug for Errno{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Errno") - .field("code", &(*self as i32)) - .field("name", &self.name()) - .field("message", &self.message()) - .finish() - } - } - impl ::core::fmt::Display for Errno{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{} (error {})", self.name(), *self as i32) - } - } - - impl std::error::Error for Errno {} - - impl Errno{ - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> Errno{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => Errno::DhtGetError, - 1 => Errno::DhtPutError, - 2 => Errno::FileAddError, - 3 => Errno::FileGetError, - 4 => Errno::FilePinError, - 5 => Errno::InvalidCid, - 6 => Errno::InvalidDhtKey, - 7 => Errno::InvalidDhtValue, - 8 => Errno::InvalidIpfsPath, - 9 => Errno::InvalidPeerId, - 10 => Errno::InvalidPubsubMessage, - 11 => Errno::PeerEvictionError, - 12 => Errno::PubsubPublishError, - 13 => Errno::PubsubSubscribeError, - 14 => Errno::ServiceUnavailable, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[allow(unused_unsafe, clippy::all)] - /// Puts a DHT key-value into IPFS. - pub fn dht_put(key: &DhtKey,value: &DhtValue,) -> Result{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = key; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let vec1 = value; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:ipfs/api")] - extern "C" { - #[link_name = "dht-put"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1.cast_mut(), len1, ptr2); - let l3 = i32::from(*ptr2.add(0).cast::()); - match l3 { - 0 => { - let e = { - let l4 = i32::from(*ptr2.add(1).cast::()); - - _rt::bool_lift(l4 as u8) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*ptr2.add(1).cast::()); - - Errno::_lift(l5 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Gets a DHT key-value from IPFS. - pub fn dht_get(key: &DhtKey,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = key; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:ipfs/api")] - extern "C" { - #[link_name = "dht-get"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = { - let l3 = *ptr1.add(4).cast::<*mut u8>(); - let l4 = *ptr1.add(8).cast::(); - let len5 = l4; - - _rt::Vec::from_raw_parts(l3.cast(), len5, len5) - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*ptr1.add(4).cast::()); - - Errno::_lift(l6 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Validates IPFS content from DHT or PubSub. - pub fn ipfs_content_validate(content: &IpfsContent,) -> Result{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let (result6_0,result6_1,result6_2,result6_3,result6_4,) = match content { - IpfsContent::Dht(e) => { - let (t0_0, t0_1, ) = e; - let vec1 = t0_0; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let vec2 = t0_1; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - - (0i32, ptr1.cast_mut(), len1, ptr2.cast_mut(), len2) - }, - IpfsContent::Pubsub(e) => { - let (t3_0, t3_1, ) = e; - let vec4 = t3_0; - let ptr4 = vec4.as_ptr().cast::(); - let len4 = vec4.len(); - let vec5 = t3_1; - let ptr5 = vec5.as_ptr().cast::(); - let len5 = vec5.len(); - - (1i32, ptr4.cast_mut(), len4, ptr5.cast_mut(), len5) - }, - }; - let ptr7 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:ipfs/api")] - extern "C" { - #[link_name = "ipfs-content-validate"] - 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(result6_0, result6_1, result6_2, result6_3, result6_4, ptr7); - let l8 = i32::from(*ptr7.add(0).cast::()); - match l8 { - 0 => { - let e = { - let l9 = i32::from(*ptr7.add(1).cast::()); - - _rt::bool_lift(l9 as u8) - }; - Ok(e) - } - 1 => { - let e = { - let l10 = i32::from(*ptr7.add(1).cast::()); - - Errno::_lift(l10 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Uploads a file to IPFS. - pub fn file_add(contents: &IpfsFile,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = contents; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:ipfs/api")] - extern "C" { - #[link_name = "file-add"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = { - let l3 = *ptr1.add(4).cast::<*mut u8>(); - let l4 = *ptr1.add(8).cast::(); - let len5 = l4; - let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); - - _rt::string_lift(bytes5) - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*ptr1.add(4).cast::()); - - Errno::_lift(l6 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Retrieves a file from IPFS. - pub fn file_get(path: &IpfsPath,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:ipfs/api")] - extern "C" { - #[link_name = "file-get"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = { - let l3 = *ptr1.add(4).cast::<*mut u8>(); - let l4 = *ptr1.add(8).cast::(); - let len5 = l4; - - _rt::Vec::from_raw_parts(l3.cast(), len5, len5) - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*ptr1.add(4).cast::()); - - Errno::_lift(l6 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Pins an IPFS file by path. - pub fn file_pin(path: &IpfsPath,) -> Result{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:ipfs/api")] - extern "C" { - #[link_name = "file-pin"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr1.add(1).cast::()); - - _rt::bool_lift(l3 as u8) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*ptr1.add(1).cast::()); - - Errno::_lift(l4 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Un-pins an IPFS file by path. - pub fn file_unpin(path: &IpfsPath,) -> Result{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:ipfs/api")] - extern "C" { - #[link_name = "file-unpin"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr1.add(1).cast::()); - - _rt::bool_lift(l3 as u8) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*ptr1.add(1).cast::()); - - Errno::_lift(l4 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Evict peer from network. - pub fn peer_evict(peer: &PeerId,) -> Result{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = peer; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:ipfs/api")] - extern "C" { - #[link_name = "peer-evict"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr1.add(1).cast::()); - - _rt::bool_lift(l3 as u8) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*ptr1.add(1).cast::()); - - Errno::_lift(l4 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Publish a message to a topic. - pub fn pubsub_publish(topic: &PubsubTopic,message: &MessageData,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = topic; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let vec1 = message; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:ipfs/api")] - extern "C" { - #[link_name = "pubsub-publish"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1.cast_mut(), len1, ptr2); - let l3 = i32::from(*ptr2.add(0).cast::()); - match l3 { - 0 => { - let e = { - let l4 = *ptr2.add(4).cast::<*mut u8>(); - let l5 = *ptr2.add(8).cast::(); - let len6 = l5; - - _rt::Vec::from_raw_parts(l4.cast(), len6, len6) - }; - Ok(e) - } - 1 => { - let e = { - let l7 = i32::from(*ptr2.add(4).cast::()); - - Errno::_lift(l7 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Subscribes to a PubSub topic. - pub fn pubsub_subscribe(topic: &PubsubTopic,) -> Result{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = topic; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:ipfs/api")] - extern "C" { - #[link_name = "pubsub-subscribe"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = { - let l3 = i32::from(*ptr1.add(1).cast::()); - - _rt::bool_lift(l3 as u8) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*ptr1.add(1).cast::()); - - Errno::_lift(l4 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - - } - - } - #[allow(dead_code)] - pub mod json { - #[allow(dead_code, clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - /// JSON is just a string. - /// This type is used to indicate the string MUST be properly formatted JSON. - pub type Json = _rt::String; - - } - - } - #[allow(dead_code)] - pub mod kv_store { - #[allow(dead_code, clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - pub type Bstr = super::super::super::hermes::binary::api::Bstr; - pub type Cbor = super::super::super::hermes::cbor::api::Cbor; - pub type Json = super::super::super::hermes::json::api::Json; - /// A time and date in seconds plus nanoseconds. - #[derive(Clone)] - pub enum KvValues { - KvString(_rt::String), - /// A String - KvS64(i64), - /// Just use the largest signed integer type supported - KvU64(u64), - /// Just use the largest integer type supported - KvF64(f64), - /// Just use the largest float type supported - KvBstr(Bstr), - /// A byte string - KvCbor(Cbor), - /// CBOR data - KvJson(Json), - } - impl ::core::fmt::Debug for KvValues { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - KvValues::KvString(e) => { - f.debug_tuple("KvValues::KvString").field(e).finish() - } - KvValues::KvS64(e) => { - f.debug_tuple("KvValues::KvS64").field(e).finish() - } - KvValues::KvU64(e) => { - f.debug_tuple("KvValues::KvU64").field(e).finish() - } - KvValues::KvF64(e) => { - f.debug_tuple("KvValues::KvF64").field(e).finish() - } - KvValues::KvBstr(e) => { - f.debug_tuple("KvValues::KvBstr").field(e).finish() - } - KvValues::KvCbor(e) => { - f.debug_tuple("KvValues::KvCbor").field(e).finish() - } - KvValues::KvJson(e) => { - f.debug_tuple("KvValues::KvJson").field(e).finish() - } - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Set a value in the local key-value store - /// Setting None will cause the Key to be deleted from the KV store. - pub fn kv_set(key: &str,value: Option<&KvValues>,){ - unsafe { - let vec0 = key; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let (result6_0,result6_1,result6_2,result6_3,) = match value { - Some(e) => { - let (result5_0,result5_1,result5_2,) = match e { - KvValues::KvString(e) => { - let vec1 = e; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - - (0i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr1.cast_mut()); - t - }, len1) - }, - KvValues::KvS64(e) => (1i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), - KvValues::KvU64(e) => (2i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), - KvValues::KvF64(e) => (3i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), - KvValues::KvBstr(e) => { - let vec2 = e; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - - (4i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr2.cast_mut()); - t - }, len2) - }, - KvValues::KvCbor(e) => { - let vec3 = e; - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - - (5i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr3.cast_mut()); - t - }, len3) - }, - KvValues::KvJson(e) => { - let vec4 = e; - let ptr4 = vec4.as_ptr().cast::(); - let len4 = vec4.len(); - - (6i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr4.cast_mut()); - t - }, len4) - }, - }; - - (1i32, result5_0, result5_1, result5_2) - }, - None => { - (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:kv-store/api")] - extern "C" { - #[link_name = "kv-set"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, result6_0, result6_1, result6_2, result6_3); - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get a value from the local key-value store - /// Returns the default if not set. - pub fn kv_get_default(key: &str,default: Option<&KvValues>,) -> Option{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); - let vec0 = key; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let (result6_0,result6_1,result6_2,result6_3,) = match default { - Some(e) => { - let (result5_0,result5_1,result5_2,) = match e { - KvValues::KvString(e) => { - let vec1 = e; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - - (0i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr1.cast_mut()); - t - }, len1) - }, - KvValues::KvS64(e) => (1i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), - KvValues::KvU64(e) => (2i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), - KvValues::KvF64(e) => (3i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), - KvValues::KvBstr(e) => { - let vec2 = e; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - - (4i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr2.cast_mut()); - t - }, len2) - }, - KvValues::KvCbor(e) => { - let vec3 = e; - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - - (5i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr3.cast_mut()); - t - }, len3) - }, - KvValues::KvJson(e) => { - let vec4 = e; - let ptr4 = vec4.as_ptr().cast::(); - let len4 = vec4.len(); - - (6i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr4.cast_mut()); - t - }, len4) - }, - }; - - (1i32, result5_0, result5_1, result5_2) - }, - None => { - (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) - }, - };let ptr7 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:kv-store/api")] - extern "C" { - #[link_name = "kv-get-default"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, result6_0, result6_1, result6_2, result6_3, ptr7); - let l8 = i32::from(*ptr7.add(0).cast::()); - match l8 { - 0 => None, - 1 => { - let e = { - let l9 = i32::from(*ptr7.add(8).cast::()); - let v25 = match l9 { - 0 => { - let e25 = { - let l10 = *ptr7.add(16).cast::<*mut u8>(); - let l11 = *ptr7.add(20).cast::(); - let len12 = l11; - let bytes12 = _rt::Vec::from_raw_parts(l10.cast(), len12, len12); - - _rt::string_lift(bytes12) - }; - KvValues::KvString(e25) - } - 1 => { - let e25 = { - let l13 = *ptr7.add(16).cast::(); - - l13 - }; - KvValues::KvS64(e25) - } - 2 => { - let e25 = { - let l14 = *ptr7.add(16).cast::(); - - l14 as u64 - }; - KvValues::KvU64(e25) - } - 3 => { - let e25 = { - let l15 = *ptr7.add(16).cast::(); - - l15 - }; - KvValues::KvF64(e25) - } - 4 => { - let e25 = { - let l16 = *ptr7.add(16).cast::<*mut u8>(); - let l17 = *ptr7.add(20).cast::(); - let len18 = l17; - - _rt::Vec::from_raw_parts(l16.cast(), len18, len18) - }; - KvValues::KvBstr(e25) - } - 5 => { - let e25 = { - let l19 = *ptr7.add(16).cast::<*mut u8>(); - let l20 = *ptr7.add(20).cast::(); - let len21 = l20; - - _rt::Vec::from_raw_parts(l19.cast(), len21, len21) - }; - KvValues::KvCbor(e25) - } - n => { - debug_assert_eq!(n, 6, "invalid enum discriminant"); - let e25 = { - let l22 = *ptr7.add(16).cast::<*mut u8>(); - let l23 = *ptr7.add(20).cast::(); - let len24 = l23; - let bytes24 = _rt::Vec::from_raw_parts(l22.cast(), len24, len24); - - _rt::string_lift(bytes24) - }; - KvValues::KvJson(e25) - } - }; - - v25 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get a value from the local key-value store - /// Returns None if the Key does not exist in the KV Store. - /// This is a convenience function, and is equivalent to `kv-get-default(key, none)` - pub fn kv_get(key: &str,) -> Option{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); - let vec0 = key; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:kv-store/api")] - extern "C" { - #[link_name = "kv-get"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => None, - 1 => { - let e = { - let l3 = i32::from(*ptr1.add(8).cast::()); - let v19 = match l3 { - 0 => { - let e19 = { - let l4 = *ptr1.add(16).cast::<*mut u8>(); - let l5 = *ptr1.add(20).cast::(); - let len6 = l5; - let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); - - _rt::string_lift(bytes6) - }; - KvValues::KvString(e19) - } - 1 => { - let e19 = { - let l7 = *ptr1.add(16).cast::(); - - l7 - }; - KvValues::KvS64(e19) - } - 2 => { - let e19 = { - let l8 = *ptr1.add(16).cast::(); - - l8 as u64 - }; - KvValues::KvU64(e19) - } - 3 => { - let e19 = { - let l9 = *ptr1.add(16).cast::(); - - l9 - }; - KvValues::KvF64(e19) - } - 4 => { - let e19 = { - let l10 = *ptr1.add(16).cast::<*mut u8>(); - let l11 = *ptr1.add(20).cast::(); - let len12 = l11; - - _rt::Vec::from_raw_parts(l10.cast(), len12, len12) - }; - KvValues::KvBstr(e19) - } - 5 => { - let e19 = { - let l13 = *ptr1.add(16).cast::<*mut u8>(); - let l14 = *ptr1.add(20).cast::(); - let len15 = l14; - - _rt::Vec::from_raw_parts(l13.cast(), len15, len15) - }; - KvValues::KvCbor(e19) - } - n => { - debug_assert_eq!(n, 6, "invalid enum discriminant"); - let e19 = { - let l16 = *ptr1.add(16).cast::<*mut u8>(); - let l17 = *ptr1.add(20).cast::(); - let len18 = l17; - let bytes18 = _rt::Vec::from_raw_parts(l16.cast(), len18, len18); - - _rt::string_lift(bytes18) - }; - KvValues::KvJson(e19) - } - }; - - v19 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get a value, and then set it (Atomic) - /// Setting None will cause the Key to be deleted from the KV store. - pub fn kv_get_set(key: &str,value: Option<&KvValues>,) -> Option{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); - let vec0 = key; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let (result6_0,result6_1,result6_2,result6_3,) = match value { - Some(e) => { - let (result5_0,result5_1,result5_2,) = match e { - KvValues::KvString(e) => { - let vec1 = e; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - - (0i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr1.cast_mut()); - t - }, len1) - }, - KvValues::KvS64(e) => (1i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), - KvValues::KvU64(e) => (2i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), - KvValues::KvF64(e) => (3i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), - KvValues::KvBstr(e) => { - let vec2 = e; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - - (4i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr2.cast_mut()); - t - }, len2) - }, - KvValues::KvCbor(e) => { - let vec3 = e; - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - - (5i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr3.cast_mut()); - t - }, len3) - }, - KvValues::KvJson(e) => { - let vec4 = e; - let ptr4 = vec4.as_ptr().cast::(); - let len4 = vec4.len(); - - (6i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr4.cast_mut()); - t - }, len4) - }, - }; - - (1i32, result5_0, result5_1, result5_2) - }, - None => { - (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) - }, - };let ptr7 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:kv-store/api")] - extern "C" { - #[link_name = "kv-get-set"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, result6_0, result6_1, result6_2, result6_3, ptr7); - let l8 = i32::from(*ptr7.add(0).cast::()); - match l8 { - 0 => None, - 1 => { - let e = { - let l9 = i32::from(*ptr7.add(8).cast::()); - let v25 = match l9 { - 0 => { - let e25 = { - let l10 = *ptr7.add(16).cast::<*mut u8>(); - let l11 = *ptr7.add(20).cast::(); - let len12 = l11; - let bytes12 = _rt::Vec::from_raw_parts(l10.cast(), len12, len12); - - _rt::string_lift(bytes12) - }; - KvValues::KvString(e25) - } - 1 => { - let e25 = { - let l13 = *ptr7.add(16).cast::(); - - l13 - }; - KvValues::KvS64(e25) - } - 2 => { - let e25 = { - let l14 = *ptr7.add(16).cast::(); - - l14 as u64 - }; - KvValues::KvU64(e25) - } - 3 => { - let e25 = { - let l15 = *ptr7.add(16).cast::(); - - l15 - }; - KvValues::KvF64(e25) - } - 4 => { - let e25 = { - let l16 = *ptr7.add(16).cast::<*mut u8>(); - let l17 = *ptr7.add(20).cast::(); - let len18 = l17; - - _rt::Vec::from_raw_parts(l16.cast(), len18, len18) - }; - KvValues::KvBstr(e25) - } - 5 => { - let e25 = { - let l19 = *ptr7.add(16).cast::<*mut u8>(); - let l20 = *ptr7.add(20).cast::(); - let len21 = l20; - - _rt::Vec::from_raw_parts(l19.cast(), len21, len21) - }; - KvValues::KvCbor(e25) - } - n => { - debug_assert_eq!(n, 6, "invalid enum discriminant"); - let e25 = { - let l22 = *ptr7.add(16).cast::<*mut u8>(); - let l23 = *ptr7.add(20).cast::(); - let len24 = l23; - let bytes24 = _rt::Vec::from_raw_parts(l22.cast(), len24, len24); - - _rt::string_lift(bytes24) - }; - KvValues::KvJson(e25) - } - }; - - v25 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get a value, and then add to it (Atomic) - /// Adding to a string will concatenate the string. - /// String concatenation will only occur up to the maximum possible size of a string value.\ - /// Concatenation beyond the maximum size will result in truncation. - /// Adding to a numeric will have the expected behavior (rounded to nearest if necessary). - /// The original type does not change, so: `f64 + u64 = f64`. `s64 + f64 = s64` - /// If the value overflows or under-flows it will saturate at the limit. - /// This behavior allows us to decrement values by using the signed version, so `u64(10) + s64(-5) = u64(5))` - /// If a string is added to a numeric, nothing happens. - /// If a numeric is added to a string, it is converted to a string first, and then concatenated - /// Note: There will be no spaces added. So "My string" + u32(77) = "My string77" - pub fn kv_add(key: &str,value: Option<&KvValues>,) -> Option{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); - let vec0 = key; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let (result6_0,result6_1,result6_2,result6_3,) = match value { - Some(e) => { - let (result5_0,result5_1,result5_2,) = match e { - KvValues::KvString(e) => { - let vec1 = e; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - - (0i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr1.cast_mut()); - t - }, len1) - }, - KvValues::KvS64(e) => (1i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), - KvValues::KvU64(e) => (2i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), - KvValues::KvF64(e) => (3i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), - KvValues::KvBstr(e) => { - let vec2 = e; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - - (4i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr2.cast_mut()); - t - }, len2) - }, - KvValues::KvCbor(e) => { - let vec3 = e; - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - - (5i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr3.cast_mut()); - t - }, len3) - }, - KvValues::KvJson(e) => { - let vec4 = e; - let ptr4 = vec4.as_ptr().cast::(); - let len4 = vec4.len(); - - (6i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr4.cast_mut()); - t - }, len4) - }, - }; - - (1i32, result5_0, result5_1, result5_2) - }, - None => { - (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) - }, - };let ptr7 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:kv-store/api")] - extern "C" { - #[link_name = "kv-add"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, result6_0, result6_1, result6_2, result6_3, ptr7); - let l8 = i32::from(*ptr7.add(0).cast::()); - match l8 { - 0 => None, - 1 => { - let e = { - let l9 = i32::from(*ptr7.add(8).cast::()); - let v25 = match l9 { - 0 => { - let e25 = { - let l10 = *ptr7.add(16).cast::<*mut u8>(); - let l11 = *ptr7.add(20).cast::(); - let len12 = l11; - let bytes12 = _rt::Vec::from_raw_parts(l10.cast(), len12, len12); - - _rt::string_lift(bytes12) - }; - KvValues::KvString(e25) - } - 1 => { - let e25 = { - let l13 = *ptr7.add(16).cast::(); - - l13 - }; - KvValues::KvS64(e25) - } - 2 => { - let e25 = { - let l14 = *ptr7.add(16).cast::(); - - l14 as u64 - }; - KvValues::KvU64(e25) - } - 3 => { - let e25 = { - let l15 = *ptr7.add(16).cast::(); - - l15 - }; - KvValues::KvF64(e25) - } - 4 => { - let e25 = { - let l16 = *ptr7.add(16).cast::<*mut u8>(); - let l17 = *ptr7.add(20).cast::(); - let len18 = l17; - - _rt::Vec::from_raw_parts(l16.cast(), len18, len18) - }; - KvValues::KvBstr(e25) - } - 5 => { - let e25 = { - let l19 = *ptr7.add(16).cast::<*mut u8>(); - let l20 = *ptr7.add(20).cast::(); - let len21 = l20; - - _rt::Vec::from_raw_parts(l19.cast(), len21, len21) - }; - KvValues::KvCbor(e25) - } - n => { - debug_assert_eq!(n, 6, "invalid enum discriminant"); - let e25 = { - let l22 = *ptr7.add(16).cast::<*mut u8>(); - let l23 = *ptr7.add(20).cast::(); - let len24 = l23; - let bytes24 = _rt::Vec::from_raw_parts(l22.cast(), len24, len24); - - _rt::string_lift(bytes24) - }; - KvValues::KvJson(e25) - } - }; - - v25 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Check if the Key equals a test value (exact match) and if it does, store the new value. - /// In all cases, the current value is returned. - /// If the types are NOT the same, the comparison will fail, even if the values are equivalent. - /// For example: `u64(7) != s64(7)`, `f64(-1) != s64(-1)`. - pub fn kv_cas(key: &str,test: Option<&KvValues>,value: Option<&KvValues>,) -> Option{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); - let vec0 = key; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let (result6_0,result6_1,result6_2,result6_3,) = match test { - Some(e) => { - let (result5_0,result5_1,result5_2,) = match e { - KvValues::KvString(e) => { - let vec1 = e; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - - (0i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr1.cast_mut()); - t - }, len1) - }, - KvValues::KvS64(e) => (1i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), - KvValues::KvU64(e) => (2i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), - KvValues::KvF64(e) => (3i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), - KvValues::KvBstr(e) => { - let vec2 = e; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - - (4i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr2.cast_mut()); - t - }, len2) - }, - KvValues::KvCbor(e) => { - let vec3 = e; - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - - (5i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr3.cast_mut()); - t - }, len3) - }, - KvValues::KvJson(e) => { - let vec4 = e; - let ptr4 = vec4.as_ptr().cast::(); - let len4 = vec4.len(); - - (6i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr4.cast_mut()); - t - }, len4) - }, - }; - - (1i32, result5_0, result5_1, result5_2) - }, - None => { - (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) - }, - };let (result12_0,result12_1,result12_2,result12_3,) = match value { - Some(e) => { - let (result11_0,result11_1,result11_2,) = match e { - KvValues::KvString(e) => { - let vec7 = e; - let ptr7 = vec7.as_ptr().cast::(); - let len7 = vec7.len(); - - (0i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr7.cast_mut()); - t - }, len7) - }, - KvValues::KvS64(e) => (1i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), - KvValues::KvU64(e) => (2i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), - KvValues::KvF64(e) => (3i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), - KvValues::KvBstr(e) => { - let vec8 = e; - let ptr8 = vec8.as_ptr().cast::(); - let len8 = vec8.len(); - - (4i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr8.cast_mut()); - t - }, len8) - }, - KvValues::KvCbor(e) => { - let vec9 = e; - let ptr9 = vec9.as_ptr().cast::(); - let len9 = vec9.len(); - - (5i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr9.cast_mut()); - t - }, len9) - }, - KvValues::KvJson(e) => { - let vec10 = e; - let ptr10 = vec10.as_ptr().cast::(); - let len10 = vec10.len(); - - (6i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr10.cast_mut()); - t - }, len10) - }, - }; - - (1i32, result11_0, result11_1, result11_2) - }, - None => { - (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) - }, - };let ptr13 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:kv-store/api")] - extern "C" { - #[link_name = "kv-cas"] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, result6_0, result6_1, result6_2, result6_3, result12_0, result12_1, result12_2, result12_3, ptr13); - let l14 = i32::from(*ptr13.add(0).cast::()); - match l14 { - 0 => None, - 1 => { - let e = { - let l15 = i32::from(*ptr13.add(8).cast::()); - let v31 = match l15 { - 0 => { - let e31 = { - let l16 = *ptr13.add(16).cast::<*mut u8>(); - let l17 = *ptr13.add(20).cast::(); - let len18 = l17; - let bytes18 = _rt::Vec::from_raw_parts(l16.cast(), len18, len18); - - _rt::string_lift(bytes18) - }; - KvValues::KvString(e31) - } - 1 => { - let e31 = { - let l19 = *ptr13.add(16).cast::(); - - l19 - }; - KvValues::KvS64(e31) - } - 2 => { - let e31 = { - let l20 = *ptr13.add(16).cast::(); - - l20 as u64 - }; - KvValues::KvU64(e31) - } - 3 => { - let e31 = { - let l21 = *ptr13.add(16).cast::(); - - l21 - }; - KvValues::KvF64(e31) - } - 4 => { - let e31 = { - let l22 = *ptr13.add(16).cast::<*mut u8>(); - let l23 = *ptr13.add(20).cast::(); - let len24 = l23; - - _rt::Vec::from_raw_parts(l22.cast(), len24, len24) - }; - KvValues::KvBstr(e31) - } - 5 => { - let e31 = { - let l25 = *ptr13.add(16).cast::<*mut u8>(); - let l26 = *ptr13.add(20).cast::(); - let len27 = l26; - - _rt::Vec::from_raw_parts(l25.cast(), len27, len27) - }; - KvValues::KvCbor(e31) - } - n => { - debug_assert_eq!(n, 6, "invalid enum discriminant"); - let e31 = { - let l28 = *ptr13.add(16).cast::<*mut u8>(); - let l29 = *ptr13.add(20).cast::(); - let len30 = l29; - let bytes30 = _rt::Vec::from_raw_parts(l28.cast(), len30, len30); - - _rt::string_lift(bytes30) - }; - KvValues::KvJson(e31) - } - }; - - v31 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Subscribe to any updates made to a particular Key. - /// After this call, this module will receive Key Update events when a key is written. - /// It returns the current value of the Key and None if it is not set. - pub fn kv_subscribe(key: &str,) -> Option{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); - let vec0 = key; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:kv-store/api")] - extern "C" { - #[link_name = "kv-subscribe"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => None, - 1 => { - let e = { - let l3 = i32::from(*ptr1.add(8).cast::()); - let v19 = match l3 { - 0 => { - let e19 = { - let l4 = *ptr1.add(16).cast::<*mut u8>(); - let l5 = *ptr1.add(20).cast::(); - let len6 = l5; - let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); - - _rt::string_lift(bytes6) - }; - KvValues::KvString(e19) - } - 1 => { - let e19 = { - let l7 = *ptr1.add(16).cast::(); - - l7 - }; - KvValues::KvS64(e19) - } - 2 => { - let e19 = { - let l8 = *ptr1.add(16).cast::(); - - l8 as u64 - }; - KvValues::KvU64(e19) - } - 3 => { - let e19 = { - let l9 = *ptr1.add(16).cast::(); - - l9 - }; - KvValues::KvF64(e19) - } - 4 => { - let e19 = { - let l10 = *ptr1.add(16).cast::<*mut u8>(); - let l11 = *ptr1.add(20).cast::(); - let len12 = l11; - - _rt::Vec::from_raw_parts(l10.cast(), len12, len12) - }; - KvValues::KvBstr(e19) - } - 5 => { - let e19 = { - let l13 = *ptr1.add(16).cast::<*mut u8>(); - let l14 = *ptr1.add(20).cast::(); - let len15 = l14; - - _rt::Vec::from_raw_parts(l13.cast(), len15, len15) - }; - KvValues::KvCbor(e19) - } - n => { - debug_assert_eq!(n, 6, "invalid enum discriminant"); - let e19 = { - let l16 = *ptr1.add(16).cast::<*mut u8>(); - let l17 = *ptr1.add(20).cast::(); - let len18 = l17; - let bytes18 = _rt::Vec::from_raw_parts(l16.cast(), len18, len18); - - _rt::string_lift(bytes18) - }; - KvValues::KvJson(e19) - } - }; - - v19 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Unsubscribe to any updates made to a particular Key. - /// After this call, this module will no longer receive Key Update events when a key is written. - /// It returns the current value of the Key and None if it is not set. - pub fn kv_unsubscribe(key: &str,) -> Option{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); - let vec0 = key; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:kv-store/api")] - extern "C" { - #[link_name = "kv-unsubscribe"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => None, - 1 => { - let e = { - let l3 = i32::from(*ptr1.add(8).cast::()); - let v19 = match l3 { - 0 => { - let e19 = { - let l4 = *ptr1.add(16).cast::<*mut u8>(); - let l5 = *ptr1.add(20).cast::(); - let len6 = l5; - let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); - - _rt::string_lift(bytes6) - }; - KvValues::KvString(e19) - } - 1 => { - let e19 = { - let l7 = *ptr1.add(16).cast::(); - - l7 - }; - KvValues::KvS64(e19) - } - 2 => { - let e19 = { - let l8 = *ptr1.add(16).cast::(); - - l8 as u64 - }; - KvValues::KvU64(e19) - } - 3 => { - let e19 = { - let l9 = *ptr1.add(16).cast::(); - - l9 - }; - KvValues::KvF64(e19) - } - 4 => { - let e19 = { - let l10 = *ptr1.add(16).cast::<*mut u8>(); - let l11 = *ptr1.add(20).cast::(); - let len12 = l11; - - _rt::Vec::from_raw_parts(l10.cast(), len12, len12) - }; - KvValues::KvBstr(e19) - } - 5 => { - let e19 = { - let l13 = *ptr1.add(16).cast::<*mut u8>(); - let l14 = *ptr1.add(20).cast::(); - let len15 = l14; - - _rt::Vec::from_raw_parts(l13.cast(), len15, len15) - }; - KvValues::KvCbor(e19) - } - n => { - debug_assert_eq!(n, 6, "invalid enum discriminant"); - let e19 = { - let l16 = *ptr1.add(16).cast::<*mut u8>(); - let l17 = *ptr1.add(20).cast::(); - let len18 = l17; - let bytes18 = _rt::Vec::from_raw_parts(l16.cast(), len18, len18); - - _rt::string_lift(bytes18) - }; - KvValues::KvJson(e19) - } - }; - - v19 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - - } - - } - #[allow(dead_code)] - pub mod localtime { - #[allow(dead_code, clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - pub type Datetime = super::super::super::wasi::clocks::wall_clock::Datetime; - /// The timezone we are localized for. - pub type Timezone = _rt::String; - /// Time in localtime format. - #[derive(Clone)] - pub struct Localtime { - pub year: u64, - /// Year - pub month: u8, - /// Month (0-11) - pub dow: u8, - /// Day of week (0-6) - pub day: u8, - /// Day (1-31) - pub hh: u8, - /// Hour (0-23) - pub mm: u8, - /// Minute (0-59) - pub ss: u8, - /// Second (0-59) - pub ns: u32, - /// Nanoseconds - pub tz: Timezone, - } - impl ::core::fmt::Debug for Localtime { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Localtime").field("year", &self.year).field("month", &self.month).field("dow", &self.dow).field("day", &self.day).field("hh", &self.hh).field("mm", &self.mm).field("ss", &self.ss).field("ns", &self.ns).field("tz", &self.tz).finish() - } - } - /// Errors that can occur converting times - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum Errno { - InvalidLocaltime, - UnknownTimezone, - YearOutOfRange, - } - impl Errno{ - pub fn name(&self) -> &'static str { - match self { - Errno::InvalidLocaltime => "invalid-localtime", - Errno::UnknownTimezone => "unknown-timezone", - Errno::YearOutOfRange => "year-out-of-range", - } - } - pub fn message(&self) -> &'static str { - match self { - Errno::InvalidLocaltime => "", - Errno::UnknownTimezone => "", - Errno::YearOutOfRange => "", - } - } - } - impl ::core::fmt::Debug for Errno{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Errno") - .field("code", &(*self as i32)) - .field("name", &self.name()) - .field("message", &self.message()) - .finish() - } - } - impl ::core::fmt::Display for Errno{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{} (error {})", self.name(), *self as i32) - } - } - - impl std::error::Error for Errno {} - - impl Errno{ - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> Errno{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => Errno::InvalidLocaltime, - 1 => Errno::UnknownTimezone, - 2 => Errno::YearOutOfRange, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[allow(unused_unsafe, clippy::all)] - /// Get localtime from a datetime or now. - /// - /// **Parameters** - /// - /// `when` : The datetime we want to convert (Optional, if not set it will convert `now`). - /// `tz` : The timezone to use. (Optional, if not set uses the local machines configured local timezone.) - /// - /// **Returns** - /// - /// `localtime` : the converted time. - /// `errno` : An error indicating why conversion failed. - pub fn get_localtime(when: Option,tz: Option<&Timezone>,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 40]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); - let (result1_0,result1_1,result1_2,) = match when { - Some(e) => { - let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds0, nanoseconds:nanoseconds0, } = e; - - (1i32, _rt::as_i64(seconds0), _rt::as_i32(nanoseconds0)) - }, - None => { - (0i32, 0i64, 0i32) - }, - };let (result3_0,result3_1,result3_2,) = match tz { - Some(e) => { - let vec2 = e; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - - (1i32, ptr2.cast_mut(), len2) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let ptr4 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:localtime/api")] - extern "C" { - #[link_name = "get-localtime"] - fn wit_import(_: i32, _: i64, _: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(result1_0, result1_1, result1_2, result3_0, result3_1, result3_2, ptr4); - let l5 = i32::from(*ptr4.add(0).cast::()); - match l5 { - 0 => { - let e = { - let l6 = *ptr4.add(8).cast::(); - let l7 = i32::from(*ptr4.add(16).cast::()); - let l8 = i32::from(*ptr4.add(17).cast::()); - let l9 = i32::from(*ptr4.add(18).cast::()); - let l10 = i32::from(*ptr4.add(19).cast::()); - let l11 = i32::from(*ptr4.add(20).cast::()); - let l12 = i32::from(*ptr4.add(21).cast::()); - let l13 = *ptr4.add(24).cast::(); - let l14 = *ptr4.add(28).cast::<*mut u8>(); - let l15 = *ptr4.add(32).cast::(); - let len16 = l15; - let bytes16 = _rt::Vec::from_raw_parts(l14.cast(), len16, len16); - - Localtime{ - year: l6 as u64, - month: l7 as u8, - dow: l8 as u8, - day: l9 as u8, - hh: l10 as u8, - mm: l11 as u8, - ss: l12 as u8, - ns: l13 as u32, - tz: _rt::string_lift(bytes16), - } - }; - Ok(e) - } - 1 => { - let e = { - let l17 = i32::from(*ptr4.add(8).cast::()); - - Errno::_lift(l17 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get a new localtime from a localtime, by recalculating time for a new timezone. - /// - /// **Parameters** - /// - /// `time` : The localtime to convert. - /// `tz` : The timezone to use. (Optional, if not set uses the local machines configured local timezone.) - /// - /// **Returns** - /// - /// `localtime` : the converted time. - /// `errno` : An error indicating why conversion failed. - pub fn alt_localtime(time: &Localtime,tz: Option<&Timezone>,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 40]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); - let Localtime{ year:year0, month:month0, dow:dow0, day:day0, hh:hh0, mm:mm0, ss:ss0, ns:ns0, tz:tz0, } = time; - let vec1 = tz0; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let (result3_0,result3_1,result3_2,) = match tz { - Some(e) => { - let vec2 = e; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - - (1i32, ptr2.cast_mut(), len2) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let ptr4 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:localtime/api")] - extern "C" { - #[link_name = "alt-localtime"] - fn wit_import(_: i64, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(_rt::as_i64(year0), _rt::as_i32(month0), _rt::as_i32(dow0), _rt::as_i32(day0), _rt::as_i32(hh0), _rt::as_i32(mm0), _rt::as_i32(ss0), _rt::as_i32(ns0), ptr1.cast_mut(), len1, result3_0, result3_1, result3_2, ptr4); - let l5 = i32::from(*ptr4.add(0).cast::()); - match l5 { - 0 => { - let e = { - let l6 = *ptr4.add(8).cast::(); - let l7 = i32::from(*ptr4.add(16).cast::()); - let l8 = i32::from(*ptr4.add(17).cast::()); - let l9 = i32::from(*ptr4.add(18).cast::()); - let l10 = i32::from(*ptr4.add(19).cast::()); - let l11 = i32::from(*ptr4.add(20).cast::()); - let l12 = i32::from(*ptr4.add(21).cast::()); - let l13 = *ptr4.add(24).cast::(); - let l14 = *ptr4.add(28).cast::<*mut u8>(); - let l15 = *ptr4.add(32).cast::(); - let len16 = l15; - let bytes16 = _rt::Vec::from_raw_parts(l14.cast(), len16, len16); - - Localtime{ - year: l6 as u64, - month: l7 as u8, - dow: l8 as u8, - day: l9 as u8, - hh: l10 as u8, - mm: l11 as u8, - ss: l12 as u8, - ns: l13 as u32, - tz: _rt::string_lift(bytes16), - } - }; - Ok(e) - } - 1 => { - let e = { - let l17 = i32::from(*ptr4.add(8).cast::()); - - Errno::_lift(l17 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get a datetime from a localtime. - /// - /// **Parameters** - /// - /// `time` : The localtime to convert. - /// - /// **Returns** - /// - /// `datetime` : the converted time. - /// `errno` : An error indicating why conversion failed. - pub fn get_datetime(time: &Localtime,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); - let Localtime{ year:year0, month:month0, dow:dow0, day:day0, hh:hh0, mm:mm0, ss:ss0, ns:ns0, tz:tz0, } = time; - let vec1 = tz0; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:localtime/api")] - extern "C" { - #[link_name = "get-datetime"] - fn wit_import(_: i64, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(_rt::as_i64(year0), _rt::as_i32(month0), _rt::as_i32(dow0), _rt::as_i32(day0), _rt::as_i32(hh0), _rt::as_i32(mm0), _rt::as_i32(ss0), _rt::as_i32(ns0), ptr1.cast_mut(), len1, ptr2); - let l3 = i32::from(*ptr2.add(0).cast::()); - match l3 { - 0 => { - let e = { - let l4 = *ptr2.add(8).cast::(); - let l5 = *ptr2.add(16).cast::(); - - super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l4 as u64, - nanoseconds: l5 as u32, - } - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*ptr2.add(8).cast::()); - - Errno::_lift(l6 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - - } - - } - #[allow(dead_code)] - pub mod logging { - #[allow(dead_code, clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - pub type Json = super::super::super::hermes::json::api::Json; - /// The supported logging levels - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum Level { - /// Debug Log Level - Debug, - /// Tracing Log level - Trace, - /// General Informational Log Level - Info, - /// Warning about something that might be a problem. - Warn, - /// A very serious error - Error, - } - impl ::core::fmt::Debug for Level { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - Level::Debug => { - f.debug_tuple("Level::Debug").finish() - } - Level::Trace => { - f.debug_tuple("Level::Trace").finish() - } - Level::Info => { - f.debug_tuple("Level::Info").finish() - } - Level::Warn => { - f.debug_tuple("Level::Warn").finish() - } - Level::Error => { - f.debug_tuple("Level::Error").finish() - } - } - } - } - - impl Level{ - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> Level{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => Level::Debug, - 1 => Level::Trace, - 2 => Level::Info, - 3 => Level::Warn, - 4 => Level::Error, - - _ => panic!("invalid enum discriminant"), - } - } - } - - #[allow(unused_unsafe, clippy::all)] - /// Generate a Log - /// - /// The Hermes API will add extra information to the log, such as the instance of the webasm - /// module being logged. - /// The Webasm module does not need to concern itself with this kind of information, and should - /// log as if it is the only instance. - /// It also should not log any webasm shared context, except where it is relevant to the log message itself. - /// The log level will be forced to INFO level. - /// - /// **Parameters** - /// - /// - `level` : The log level this message is for. - /// - `file` : The name of the src file being logged from. (Optional) - /// - `function` : The function within the file being logged from. (Optional) - /// - `line` : The line of code the log was generated from. (Optional) - /// - `col` : The column of code the log was generated from. (Optional) - /// - `ctx` : The logging context. (Should have no newlines or formatting). - /// - `msg` : A Single line message to be logged. (Should have no newlines or formatting). - /// - `data` : A Free form json payload that will be logged with the msg. This must be valid JSON. - /// - /// *Notes* - /// - /// The `data` parameter may contain a record of the format: - /// ```json - /// { - /// "bt" : [ , ] - /// } - /// ``` - /// The logger will interpret this as a backtrace where each entry in the array is one line of the backtrace. - /// The format of the backtrace lines is up to the webasm module generating the log. - /// The individual backtrace entries may contain line breaks if the backtrace entry is - /// multiline. - /// * Multiline backtrace entries should be de-dented, relative to the first line. - /// * This is to allow the display to properly format multiline entries. - /// This format is designed to keep the broadest flexibility for multiple languages capabilities. - /// The backtrace must be sorted with most recent lines of the backtrace occurring first in the array. - /// Backtrace must be contained in a single `log` call. Multiple log calls will be considered independent logs. - pub fn log(level: Level,file: Option<&str>,function: Option<&str>,line: Option,col: Option,ctx: Option<&str>,msg: &str,data: Option<&Json>,){ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 76]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 76]); - let ptr0 = ret_area.0.as_mut_ptr().cast::();*ptr0.add(0).cast::() = (level.clone() as i32) as u8; - match file { - Some(e) => { - *ptr0.add(4).cast::() = (1i32) as u8; - let vec1 = e; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - *ptr0.add(12).cast::() = len1; - *ptr0.add(8).cast::<*mut u8>() = ptr1.cast_mut(); - }, - None => { - { - *ptr0.add(4).cast::() = (0i32) as u8; - } - }, - };match function { - Some(e) => { - *ptr0.add(16).cast::() = (1i32) as u8; - let vec2 = e; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - *ptr0.add(24).cast::() = len2; - *ptr0.add(20).cast::<*mut u8>() = ptr2.cast_mut(); - }, - None => { - { - *ptr0.add(16).cast::() = (0i32) as u8; - } - }, - };match line { - Some(e) => { - *ptr0.add(28).cast::() = (1i32) as u8; - *ptr0.add(32).cast::() = _rt::as_i32(e); - }, - None => { - { - *ptr0.add(28).cast::() = (0i32) as u8; - } - }, - };match col { - Some(e) => { - *ptr0.add(36).cast::() = (1i32) as u8; - *ptr0.add(40).cast::() = _rt::as_i32(e); - }, - None => { - { - *ptr0.add(36).cast::() = (0i32) as u8; - } - }, - };match ctx { - Some(e) => { - *ptr0.add(44).cast::() = (1i32) as u8; - let vec3 = e; - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - *ptr0.add(52).cast::() = len3; - *ptr0.add(48).cast::<*mut u8>() = ptr3.cast_mut(); - }, - None => { - { - *ptr0.add(44).cast::() = (0i32) as u8; - } - }, - };let vec4 = msg; - let ptr4 = vec4.as_ptr().cast::(); - let len4 = vec4.len(); - *ptr0.add(60).cast::() = len4; - *ptr0.add(56).cast::<*mut u8>() = ptr4.cast_mut(); - match data { - Some(e) => { - *ptr0.add(64).cast::() = (1i32) as u8; - let vec5 = e; - let ptr5 = vec5.as_ptr().cast::(); - let len5 = vec5.len(); - *ptr0.add(72).cast::() = len5; - *ptr0.add(68).cast::<*mut u8>() = ptr5.cast_mut(); - }, - None => { - { - *ptr0.add(64).cast::() = (0i32) as u8; - } - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:logging/api")] - extern "C" { - #[link_name = "log"] - fn wit_import(_: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, ){ unreachable!() } - wit_import(ptr0); - } - } - - } - - } - #[allow(dead_code)] - pub mod sqlite { - #[allow(dead_code, clippy::all)] - pub mod api { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - /// Represents an error with a code and a message. - #[derive(Clone)] - pub struct ErrorInfo { - /// The numeric result code of the error. - pub code: i32, - /// The error message associated with the error code. - pub message: _rt::String, - } - impl ::core::fmt::Debug for ErrorInfo { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ErrorInfo").field("code", &self.code).field("message", &self.message).finish() - } - } - /// Errors that indicate that something has gone wrong. - #[derive(Clone, Copy)] - pub enum Errno { - /// An error caused from internal SQLite engine. - Sqlite(i32), - /// An error caused during the conversion of a CString. - ConvertingCString, - /// The in-memory configuration provided is invalid. - InvalidInMemoryConfig, - /// The persistent configuration provided is invalid. - InvalidPersistentConfig, - /// The database name is missing in the persistent configuration. - MissingDatabaseNameForPersistentConfig, - /// Failed to open the database. - FailedOpeningDatabase, - /// Failed to set the database size limit. - FailedSettingDatabaseSize, - /// Unknown column type is retrieved. - UnknownColumnType, - /// `PRAGMA` commands are not allowed to execute inside Hermes. - ForbiddenPragmaCommand, - /// Unhandled null pointer is returned while interacting with the database. - ReturnedNullPointer, - /// The numeric value is truncated or improperly converted during the execution. - ConvertingNumeric, - } - impl ::core::fmt::Debug for Errno { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - Errno::Sqlite(e) => { - f.debug_tuple("Errno::Sqlite").field(e).finish() - } - Errno::ConvertingCString => { - f.debug_tuple("Errno::ConvertingCString").finish() - } - Errno::InvalidInMemoryConfig => { - f.debug_tuple("Errno::InvalidInMemoryConfig").finish() - } - Errno::InvalidPersistentConfig => { - f.debug_tuple("Errno::InvalidPersistentConfig").finish() - } - Errno::MissingDatabaseNameForPersistentConfig => { - f.debug_tuple("Errno::MissingDatabaseNameForPersistentConfig").finish() - } - Errno::FailedOpeningDatabase => { - f.debug_tuple("Errno::FailedOpeningDatabase").finish() - } - Errno::FailedSettingDatabaseSize => { - f.debug_tuple("Errno::FailedSettingDatabaseSize").finish() - } - Errno::UnknownColumnType => { - f.debug_tuple("Errno::UnknownColumnType").finish() - } - Errno::ForbiddenPragmaCommand => { - f.debug_tuple("Errno::ForbiddenPragmaCommand").finish() - } - Errno::ReturnedNullPointer => { - f.debug_tuple("Errno::ReturnedNullPointer").finish() - } - Errno::ConvertingNumeric => { - f.debug_tuple("Errno::ConvertingNumeric").finish() - } - } - } - } - impl ::core::fmt::Display for Errno { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for Errno {} - /// The value of a column in a specific data format. - #[derive(Clone)] - pub enum Value { - /// A blob or a UTF-8 text in bytes. - Blob(_rt::Vec::), - /// Real number. - Double(f64), - /// 32-bit integer. - Int32(i32), - /// 64-bit integer. - Int64(i64), - /// Null value. - Null, - /// UTF-8 text. - Text(_rt::String), - } - impl ::core::fmt::Debug for Value { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - Value::Blob(e) => { - f.debug_tuple("Value::Blob").field(e).finish() - } - Value::Double(e) => { - f.debug_tuple("Value::Double").field(e).finish() - } - Value::Int32(e) => { - f.debug_tuple("Value::Int32").field(e).finish() - } - Value::Int64(e) => { - f.debug_tuple("Value::Int64").field(e).finish() - } - Value::Null => { - f.debug_tuple("Value::Null").finish() - } - Value::Text(e) => { - f.debug_tuple("Value::Text").field(e).finish() - } - } - } - } - /// The database connection object. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Sqlite{ - handle: _rt::Resource, - } - - impl Sqlite{ - #[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 Sqlite{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "hermes:sqlite/api")] - extern "C" { - #[link_name = "[resource-drop]sqlite"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// The prepared statement object. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Statement{ - handle: _rt::Resource, - } - - impl Statement{ - #[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 Statement{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "hermes:sqlite/api")] - extern "C" { - #[link_name = "[resource-drop]statement"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Sqlite { - #[allow(unused_unsafe, clippy::all)] - /// Closes a database connection, destructor for `sqlite3`. - /// - /// Ideally, applications should finalize all prepared statements associated with the `sqlite3` object prior to attempting to close the object. - /// If the database connection is associated with unfinalized prepared statements, - /// then the function will leave the database connection open and return the `busy` error code. - /// - /// If an `sqlite3` object is destroyed while a transaction is open, the transaction is automatically rolled back. - pub fn close(&self,) -> Result<(),Errno>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:sqlite/api")] - extern "C" { - #[link_name = "[method]sqlite.close"] - 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 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*ptr0.add(4).cast::()); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *ptr0.add(8).cast::(); - - l3 - }; - Errno::Sqlite(e4) - } - 1 => { - Errno::ConvertingCString - } - 2 => { - Errno::InvalidInMemoryConfig - } - 3 => { - Errno::InvalidPersistentConfig - } - 4 => { - Errno::MissingDatabaseNameForPersistentConfig - } - 5 => { - Errno::FailedOpeningDatabase - } - 6 => { - Errno::FailedSettingDatabaseSize - } - 7 => { - Errno::UnknownColumnType - } - 8 => { - Errno::ForbiddenPragmaCommand - } - 9 => { - Errno::ReturnedNullPointer - } - n => { - debug_assert_eq!(n, 10, "invalid enum discriminant"); - Errno::ConvertingNumeric - } - }; - - v4 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Sqlite { - #[allow(unused_unsafe, clippy::all)] - /// Retrieves the numeric result code for the most recent failed SQLite operation on a database connection. - /// - /// # Returns - /// - /// The error object containing numeric code and detail message for the most recent failed SQLite operation. If there is no recent failed, none is returned. - pub fn errcode(&self,) -> Option{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:sqlite/api")] - extern "C" { - #[link_name = "[method]sqlite.errcode"] - 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 = *ptr0.add(4).cast::(); - let l3 = *ptr0.add(8).cast::<*mut u8>(); - let l4 = *ptr0.add(12).cast::(); - let len5 = l4; - let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); - - ErrorInfo{ - code: l2, - message: _rt::string_lift(bytes5), - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Sqlite { - #[allow(unused_unsafe, clippy::all)] - /// Compiles SQL text into byte-code that will do the work of querying or updating the database. - /// - /// ## Parameters - /// - /// - `db`: Database handle. - /// - `sql`: SQL statement, UTF-8 encoded. - /// - /// ## Returns - /// - /// A compiled prepared statement that can be executed using `sqlite3_step()`. - /// If there is an error or the input text contains no SQL (if the input is an empty string or a comment) then an error code is returned. - pub fn prepare(&self,sql: &str,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = sql; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:sqlite/api")] - extern "C" { - #[link_name = "[method]sqlite.prepare"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = { - let l3 = *ptr1.add(4).cast::(); - - Statement::from_handle(l3 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*ptr1.add(4).cast::()); - let v6 = match l4 { - 0 => { - let e6 = { - let l5 = *ptr1.add(8).cast::(); - - l5 - }; - Errno::Sqlite(e6) - } - 1 => { - Errno::ConvertingCString - } - 2 => { - Errno::InvalidInMemoryConfig - } - 3 => { - Errno::InvalidPersistentConfig - } - 4 => { - Errno::MissingDatabaseNameForPersistentConfig - } - 5 => { - Errno::FailedOpeningDatabase - } - 6 => { - Errno::FailedSettingDatabaseSize - } - 7 => { - Errno::UnknownColumnType - } - 8 => { - Errno::ForbiddenPragmaCommand - } - 9 => { - Errno::ReturnedNullPointer - } - n => { - debug_assert_eq!(n, 10, "invalid enum discriminant"); - Errno::ConvertingNumeric - } - }; - - v6 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Sqlite { - #[allow(unused_unsafe, clippy::all)] - /// Executes an SQL query directly without preparing it into a statement and returns the result. - /// - /// ## Parameters - /// - /// - `sql`: SQL statement, UTF-8 encoded. - pub fn execute(&self,sql: &str,) -> Result<(),Errno>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = sql; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:sqlite/api")] - extern "C" { - #[link_name = "[method]sqlite.execute"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr1.add(4).cast::()); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *ptr1.add(8).cast::(); - - l4 - }; - Errno::Sqlite(e5) - } - 1 => { - Errno::ConvertingCString - } - 2 => { - Errno::InvalidInMemoryConfig - } - 3 => { - Errno::InvalidPersistentConfig - } - 4 => { - Errno::MissingDatabaseNameForPersistentConfig - } - 5 => { - Errno::FailedOpeningDatabase - } - 6 => { - Errno::FailedSettingDatabaseSize - } - 7 => { - Errno::UnknownColumnType - } - 8 => { - Errno::ForbiddenPragmaCommand - } - 9 => { - Errno::ReturnedNullPointer - } - n => { - debug_assert_eq!(n, 10, "invalid enum discriminant"); - Errno::ConvertingNumeric - } - }; - - v5 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Statement { - #[allow(unused_unsafe, clippy::all)] - /// Stores application data into parameters of the original SQL. - /// - /// ## Parameters - /// - /// - `index`: The index of the SQL parameter to be set. - /// - `value`: The value to bind to the parameter. - pub fn bind(&self,index: u32,value: &Value,) -> Result<(),Errno>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let (result2_0,result2_1,result2_2,) = match value { - Value::Blob(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - - (0i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr0.cast_mut()); - t - }, len0) - }, - Value::Double(e) => (1i32, ::core::mem::MaybeUninit::new((_rt::as_f64(e)).to_bits() as i64 as u64), 0usize), - Value::Int32(e) => (2i32, ::core::mem::MaybeUninit::new(i64::from(_rt::as_i32(e)) as u64), 0usize), - Value::Int64(e) => (3i32, ::core::mem::MaybeUninit::new(_rt::as_i64(e) as u64), 0usize), - Value::Null=> { - (4i32, ::core::mem::MaybeUninit::::zeroed(), 0usize) - } - Value::Text(e) => { - let vec1 = e; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - - (5i32, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(ptr1.cast_mut()); - t - }, len1) - }, - }; - let ptr3 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:sqlite/api")] - extern "C" { - #[link_name = "[method]statement.bind"] - fn wit_import(_: i32, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, _rt::as_i32(&index), result2_0, result2_1, result2_2, ptr3); - let l4 = i32::from(*ptr3.add(0).cast::()); - match l4 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*ptr3.add(4).cast::()); - let v7 = match l5 { - 0 => { - let e7 = { - let l6 = *ptr3.add(8).cast::(); - - l6 - }; - Errno::Sqlite(e7) - } - 1 => { - Errno::ConvertingCString - } - 2 => { - Errno::InvalidInMemoryConfig - } - 3 => { - Errno::InvalidPersistentConfig - } - 4 => { - Errno::MissingDatabaseNameForPersistentConfig - } - 5 => { - Errno::FailedOpeningDatabase - } - 6 => { - Errno::FailedSettingDatabaseSize - } - 7 => { - Errno::UnknownColumnType - } - 8 => { - Errno::ForbiddenPragmaCommand - } - 9 => { - Errno::ReturnedNullPointer - } - n => { - debug_assert_eq!(n, 10, "invalid enum discriminant"); - Errno::ConvertingNumeric - } - }; - - v7 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Statement { - #[allow(unused_unsafe, clippy::all)] - /// Advances a statement to the next result row or to completion. - /// - /// After a prepared statement has been prepared, this function must be called one or more times to evaluate the statement. - pub fn step(&self,) -> Result<(),Errno>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:sqlite/api")] - extern "C" { - #[link_name = "[method]statement.step"] - 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 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*ptr0.add(4).cast::()); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *ptr0.add(8).cast::(); - - l3 - }; - Errno::Sqlite(e4) - } - 1 => { - Errno::ConvertingCString - } - 2 => { - Errno::InvalidInMemoryConfig - } - 3 => { - Errno::InvalidPersistentConfig - } - 4 => { - Errno::MissingDatabaseNameForPersistentConfig - } - 5 => { - Errno::FailedOpeningDatabase - } - 6 => { - Errno::FailedSettingDatabaseSize - } - 7 => { - Errno::UnknownColumnType - } - 8 => { - Errno::ForbiddenPragmaCommand - } - 9 => { - Errno::ReturnedNullPointer - } - n => { - debug_assert_eq!(n, 10, "invalid enum discriminant"); - Errno::ConvertingNumeric - } - }; - - v4 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Statement { - #[allow(unused_unsafe, clippy::all)] - /// Returns information about a single column of the current result row of a query. - /// - /// If the SQL statement does not currently point to a valid row, or if the column index is out of range, the result is undefined. - /// - /// ## Parameters - /// - /// - `index`: The index of the column for which information should be returned. The leftmost column of the result set has the index 0. - /// - /// ## Returns - /// - /// The value of a result column in a specific data format. - pub fn column(&self,index: u32,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:sqlite/api")] - extern "C" { - #[link_name = "[method]statement.column"] - fn wit_import(_: i32, _: i32, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, _rt::as_i32(&index), ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = { - let l2 = i32::from(*ptr0.add(8).cast::()); - let v12 = match l2 { - 0 => { - let e12 = { - let l3 = *ptr0.add(16).cast::<*mut u8>(); - let l4 = *ptr0.add(20).cast::(); - let len5 = l4; - - _rt::Vec::from_raw_parts(l3.cast(), len5, len5) - }; - Value::Blob(e12) - } - 1 => { - let e12 = { - let l6 = *ptr0.add(16).cast::(); - - l6 - }; - Value::Double(e12) - } - 2 => { - let e12 = { - let l7 = *ptr0.add(16).cast::(); - - l7 - }; - Value::Int32(e12) - } - 3 => { - let e12 = { - let l8 = *ptr0.add(16).cast::(); - - l8 - }; - Value::Int64(e12) - } - 4 => { - Value::Null - } - n => { - debug_assert_eq!(n, 5, "invalid enum discriminant"); - let e12 = { - let l9 = *ptr0.add(16).cast::<*mut u8>(); - let l10 = *ptr0.add(20).cast::(); - let len11 = l10; - let bytes11 = _rt::Vec::from_raw_parts(l9.cast(), len11, len11); - - _rt::string_lift(bytes11) - }; - Value::Text(e12) - } - }; - - v12 - }; - Ok(e) - } - 1 => { - let e = { - let l13 = i32::from(*ptr0.add(8).cast::()); - let v15 = match l13 { - 0 => { - let e15 = { - let l14 = *ptr0.add(12).cast::(); - - l14 - }; - Errno::Sqlite(e15) - } - 1 => { - Errno::ConvertingCString - } - 2 => { - Errno::InvalidInMemoryConfig - } - 3 => { - Errno::InvalidPersistentConfig - } - 4 => { - Errno::MissingDatabaseNameForPersistentConfig - } - 5 => { - Errno::FailedOpeningDatabase - } - 6 => { - Errno::FailedSettingDatabaseSize - } - 7 => { - Errno::UnknownColumnType - } - 8 => { - Errno::ForbiddenPragmaCommand - } - 9 => { - Errno::ReturnedNullPointer - } - n => { - debug_assert_eq!(n, 10, "invalid enum discriminant"); - Errno::ConvertingNumeric - } - }; - - v15 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Statement { - #[allow(unused_unsafe, clippy::all)] - /// Destroys a prepared statement object. If the most recent evaluation of the statement encountered no errors or if the statement is never been evaluated, - /// then the function results without errors. If the most recent evaluation of statement failed, then the function results the appropriate error code. - /// - /// The application must finalize every prepared statement in order to avoid resource leaks. - /// It is a grievous error for the application to try to use a prepared statement after it has been finalized. - /// Any use of a prepared statement after it has been finalized can result in undefined and undesirable behavior such as segfaults and heap corruption. - pub fn finalize(&self,) -> Result<(),Errno>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:sqlite/api")] - extern "C" { - #[link_name = "[method]statement.finalize"] - 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 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*ptr0.add(4).cast::()); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *ptr0.add(8).cast::(); - - l3 - }; - Errno::Sqlite(e4) - } - 1 => { - Errno::ConvertingCString - } - 2 => { - Errno::InvalidInMemoryConfig - } - 3 => { - Errno::InvalidPersistentConfig - } - 4 => { - Errno::MissingDatabaseNameForPersistentConfig - } - 5 => { - Errno::FailedOpeningDatabase - } - 6 => { - Errno::FailedSettingDatabaseSize - } - 7 => { - Errno::UnknownColumnType - } - 8 => { - Errno::ForbiddenPragmaCommand - } - 9 => { - Errno::ReturnedNullPointer - } - n => { - debug_assert_eq!(n, 10, "invalid enum discriminant"); - Errno::ConvertingNumeric - } - }; - - v4 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Opens a connection to a new or existing SQLite database. - /// - /// ## Parameters - /// - /// - `readonly`: If set to true, the database is opened in read-only mode. An error is returned if the database doesn't already exist. - /// - `memory`: If set to true, the database will be opened as an in-memory database. - /// - /// ## Returns - /// - /// If the database is opened (and/or created) successfully, then the `sqlite3` object is returned. Otherwise an error code is returned. - pub fn open(readonly: bool,memory: bool,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "hermes:sqlite/api")] - extern "C" { - #[link_name = "open"] - fn wit_import(_: i32, _: i32, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: *mut u8, ){ unreachable!() } - wit_import(match &readonly { true => 1, false => 0 }, match &memory { true => 1, false => 0 }, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = { - let l2 = *ptr0.add(4).cast::(); - - Sqlite::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(4).cast::()); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *ptr0.add(8).cast::(); - - l4 - }; - Errno::Sqlite(e5) - } - 1 => { - Errno::ConvertingCString - } - 2 => { - Errno::InvalidInMemoryConfig - } - 3 => { - Errno::InvalidPersistentConfig - } - 4 => { - Errno::MissingDatabaseNameForPersistentConfig - } - 5 => { - Errno::FailedOpeningDatabase - } - 6 => { - Errno::FailedSettingDatabaseSize - } - 7 => { - Errno::UnknownColumnType - } - 8 => { - Errno::ForbiddenPragmaCommand - } - 9 => { - Errno::ReturnedNullPointer - } - n => { - debug_assert_eq!(n, 10, "invalid enum discriminant"); - Errno::ConvertingNumeric - } - }; - - v5 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - - } - - } -} -#[allow(dead_code)] -pub mod wasi { - #[allow(dead_code)] - pub mod cli { - #[allow(dead_code, clippy::all)] - pub mod environment { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - #[allow(unused_unsafe, clippy::all)] - /// Get the POSIX-style environment variables. - /// - /// Each environment variable is provided as a pair of string variable names - /// and string value. - /// - /// Morally, these are a value import, but until value imports are available - /// in the component model, this import function should return the same - /// values each time it is called. - pub fn get_environment() -> _rt::Vec::<(_rt::String,_rt::String,)>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/environment@0.2.0")] - extern "C" { - #[link_name = "get-environment"] - 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::<*mut u8>(); - let l2 = *ptr0.add(4).cast::(); - let base9 = l1; - let len9 = l2; - let mut result9 = _rt::Vec::with_capacity(len9); - for i in 0..len9 { - let base = base9.add(i * 16); - let e9 = { - let l3 = *base.add(0).cast::<*mut u8>(); - let l4 = *base.add(4).cast::(); - let len5 = l4; - let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); - let l6 = *base.add(8).cast::<*mut u8>(); - let l7 = *base.add(12).cast::(); - let len8 = l7; - let bytes8 = _rt::Vec::from_raw_parts(l6.cast(), len8, len8); - - (_rt::string_lift(bytes5), _rt::string_lift(bytes8)) - }; - result9.push(e9); - } - _rt::cabi_dealloc(base9, len9 * 16, 4); - result9 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Get the POSIX-style arguments to the program. - pub fn get_arguments() -> _rt::Vec::<_rt::String>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/environment@0.2.0")] - extern "C" { - #[link_name = "get-arguments"] - 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::<*mut u8>(); - let l2 = *ptr0.add(4).cast::(); - let base6 = l1; - let len6 = l2; - let mut result6 = _rt::Vec::with_capacity(len6); - for i in 0..len6 { - let base = base6.add(i * 8); - let e6 = { - let l3 = *base.add(0).cast::<*mut u8>(); - let l4 = *base.add(4).cast::(); - let len5 = l4; - let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); - - _rt::string_lift(bytes5) - }; - result6.push(e6); - } - _rt::cabi_dealloc(base6, len6 * 8, 4); - result6 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Return a path that programs should use as their initial current working - /// directory, interpreting `.` as shorthand for this. - pub fn initial_cwd() -> Option<_rt::String>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/environment@0.2.0")] - extern "C" { - #[link_name = "initial-cwd"] - fn wit_import(_: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, ){ unreachable!() } - wit_import(ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => None, - 1 => { - let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - - _rt::string_lift(bytes4) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - - } - - #[allow(dead_code, clippy::all)] - pub mod exit { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - #[allow(unused_unsafe, clippy::all)] - /// Exit the current instance and any linked instances. - pub fn exit(status: Result<(),()>,){ - unsafe { - let result0 = match status { - Ok(_) => { 0i32 }, - Err(_) => { 1i32 }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/exit@0.2.0")] - extern "C" { - #[link_name = "exit"] - fn wit_import(_: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ){ unreachable!() } - wit_import(result0); - } - } - - } - - #[allow(dead_code, clippy::all)] - pub mod stdin { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - pub type InputStream = super::super::super::wasi::io::streams::InputStream; - #[allow(unused_unsafe, clippy::all)] - pub fn get_stdin() -> InputStream{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/stdin@0.2.0")] - extern "C" { - #[link_name = "get-stdin"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - super::super::super::wasi::io::streams::InputStream::from_handle(ret as u32) - } - } - - } - - #[allow(dead_code, clippy::all)] - pub mod stdout { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; - #[allow(unused_unsafe, clippy::all)] - pub fn get_stdout() -> OutputStream{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/stdout@0.2.0")] - extern "C" { - #[link_name = "get-stdout"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - super::super::super::wasi::io::streams::OutputStream::from_handle(ret as u32) - } - } - - } - - #[allow(dead_code, clippy::all)] - pub mod stderr { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; - #[allow(unused_unsafe, clippy::all)] - pub fn get_stderr() -> OutputStream{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:cli/stderr@0.2.0")] - extern "C" { - #[link_name = "get-stderr"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - super::super::super::wasi::io::streams::OutputStream::from_handle(ret as u32) - } - } - - } - - } - #[allow(dead_code)] - pub mod clocks { - #[allow(dead_code, clippy::all)] - pub mod monotonic_clock { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - /// Hermes does not support `poll` - /// use wasi:io/poll@0.2.0.{pollable}; - /// An instant in time, in nanoseconds. An instant is relative to an - /// unspecified initial value, and can only be compared to instances from - /// the same monotonic-clock. - pub type Instant = u64; - /// A duration of time, in nanoseconds. - pub type Duration = u64; - #[allow(unused_unsafe, clippy::all)] - /// Read the current value of the clock. - /// - /// The clock is monotonic, therefore calling this function repeatedly will - /// produce a sequence of non-decreasing values. - pub fn now() -> Instant{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] - extern "C" { - #[link_name = "now"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - #[allow(unused_unsafe, clippy::all)] - /// Query the resolution of the clock. Returns the duration of time - /// corresponding to a clock tick. - pub fn resolution() -> Duration{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.0")] - extern "C" { - #[link_name = "resolution"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - - } - - #[allow(dead_code, clippy::all)] - pub mod wall_clock { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - /// A time and date in seconds plus nanoseconds. - #[repr(C)] - #[derive(Clone, Copy)] - pub struct Datetime { - pub seconds: u64, - pub nanoseconds: u32, - } - impl ::core::fmt::Debug for Datetime { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("Datetime").field("seconds", &self.seconds).field("nanoseconds", &self.nanoseconds).finish() - } - } - #[allow(unused_unsafe, clippy::all)] - /// Read the current value of the clock. - /// - /// This clock is not monotonic, therefore calling this function repeatedly - /// will not necessarily produce a sequence of non-decreasing values. - /// - /// The returned timestamps represent the number of seconds since - /// 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch], - /// also known as [Unix Time]. - /// - /// The nanoseconds field of the output is always less than 1000000000. - /// - /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 - /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time - pub fn now() -> Datetime{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.0")] - extern "C" { - #[link_name = "now"] - 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::(); - Datetime{ - seconds: l1 as u64, - nanoseconds: l2 as u32, - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Query the resolution of the clock. - /// - /// The nanoseconds field of the output is always less than 1000000000. - pub fn resolution() -> Datetime{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.0")] - extern "C" { - #[link_name = "resolution"] - 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::(); - Datetime{ - seconds: l1 as u64, - nanoseconds: l2 as u32, - } - } - } - - } - - } - #[allow(dead_code)] - pub mod filesystem { - #[allow(dead_code, clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - pub type InputStream = super::super::super::wasi::io::streams::InputStream; - pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; - pub type Error = super::super::super::wasi::io::streams::Error; - pub type Datetime = super::super::super::wasi::clocks::wall_clock::Datetime; - /// File size or length of a region within a file. - pub type Filesize = u64; - /// The type of a filesystem object referenced by a descriptor. - /// - /// Note: This was called `filetype` in earlier versions of WASI. - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum DescriptorType { - /// The type of the descriptor or file is unknown or is different from - /// any of the other types specified. - Unknown, - /// The descriptor refers to a block device inode. - BlockDevice, - /// The descriptor refers to a character device inode. - CharacterDevice, - /// The descriptor refers to a directory inode. - Directory, - /// The descriptor refers to a named pipe. - Fifo, - /// The file refers to a symbolic link inode. - SymbolicLink, - /// The descriptor refers to a regular file inode. - RegularFile, - /// The descriptor refers to a socket. - Socket, - } - impl ::core::fmt::Debug for DescriptorType { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - DescriptorType::Unknown => { - f.debug_tuple("DescriptorType::Unknown").finish() - } - DescriptorType::BlockDevice => { - f.debug_tuple("DescriptorType::BlockDevice").finish() - } - DescriptorType::CharacterDevice => { - f.debug_tuple("DescriptorType::CharacterDevice").finish() - } - DescriptorType::Directory => { - f.debug_tuple("DescriptorType::Directory").finish() - } - DescriptorType::Fifo => { - f.debug_tuple("DescriptorType::Fifo").finish() - } - DescriptorType::SymbolicLink => { - f.debug_tuple("DescriptorType::SymbolicLink").finish() - } - DescriptorType::RegularFile => { - f.debug_tuple("DescriptorType::RegularFile").finish() - } - DescriptorType::Socket => { - f.debug_tuple("DescriptorType::Socket").finish() - } - } - } - } - - impl DescriptorType{ - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> DescriptorType{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => DescriptorType::Unknown, - 1 => DescriptorType::BlockDevice, - 2 => DescriptorType::CharacterDevice, - 3 => DescriptorType::Directory, - 4 => DescriptorType::Fifo, - 5 => DescriptorType::SymbolicLink, - 6 => DescriptorType::RegularFile, - 7 => DescriptorType::Socket, - - _ => panic!("invalid enum discriminant"), - } - } - } - - wit_bindgen::rt::bitflags::bitflags! { - /// Descriptor flags. - /// - /// Note: This was called `fdflags` in earlier versions of WASI. - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] - pub struct DescriptorFlags: u8 { - /// Read mode: Data can be read. - const READ = 1 << 0; - /// Write mode: Data can be written to. - const WRITE = 1 << 1; - /// Request that writes be performed according to synchronized I/O file - /// integrity completion. The data stored in the file and the file's - /// metadata are synchronized. This is similar to `O_SYNC` in POSIX. - /// - /// The precise semantics of this operation have not yet been defined for - /// WASI. At this time, it should be interpreted as a request, and not a - /// requirement. - const FILE_INTEGRITY_SYNC = 1 << 2; - /// Request that writes be performed according to synchronized I/O data - /// integrity completion. Only the data stored in the file is - /// synchronized. This is similar to `O_DSYNC` in POSIX. - /// - /// The precise semantics of this operation have not yet been defined for - /// WASI. At this time, it should be interpreted as a request, and not a - /// requirement. - const DATA_INTEGRITY_SYNC = 1 << 3; - /// Requests that reads be performed at the same level of integrety - /// requested for writes. This is similar to `O_RSYNC` in POSIX. - /// - /// The precise semantics of this operation have not yet been defined for - /// WASI. At this time, it should be interpreted as a request, and not a - /// requirement. - const REQUESTED_WRITE_SYNC = 1 << 4; - /// Mutating directories mode: Directory contents may be mutated. - /// - /// When this flag is unset on a descriptor, operations using the - /// descriptor which would create, rename, delete, modify the data or - /// metadata of filesystem objects, or obtain another handle which - /// would permit any of those, shall fail with `error-code::read-only` if - /// they would otherwise succeed. - /// - /// This may only be set on directories. - const MUTATE_DIRECTORY = 1 << 5; - } - } - wit_bindgen::rt::bitflags::bitflags! { - /// Flags determining the method of how paths are resolved. - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] - pub struct PathFlags: u8 { - /// As long as the resolved path corresponds to a symbolic link, it is - /// expanded. - const SYMLINK_FOLLOW = 1 << 0; - } - } - wit_bindgen::rt::bitflags::bitflags! { - /// Open flags used by `open-at`. - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] - pub struct OpenFlags: u8 { - /// Create file if it does not exist, similar to `O_CREAT` in POSIX. - const CREATE = 1 << 0; - /// Fail if not a directory, similar to `O_DIRECTORY` in POSIX. - const DIRECTORY = 1 << 1; - /// Fail if file already exists, similar to `O_EXCL` in POSIX. - const EXCLUSIVE = 1 << 2; - /// Truncate file to size 0, similar to `O_TRUNC` in POSIX. - const TRUNCATE = 1 << 3; - } - } - /// Number of hard links to an inode. - pub type LinkCount = u64; - /// File attributes. - /// - /// Note: This was called `filestat` in earlier versions of WASI. - #[repr(C)] - #[derive(Clone, Copy)] - pub struct DescriptorStat { - /// File type. - pub type_: DescriptorType, - /// Number of hard links to the file. - pub link_count: LinkCount, - /// For regular files, the file size in bytes. For symbolic links, the - /// length in bytes of the pathname contained in the symbolic link. - pub size: Filesize, - /// Last data access timestamp. - /// - /// If the `option` is none, the platform doesn't maintain an access - /// timestamp for this file. - pub data_access_timestamp: Option, - /// Last data modification timestamp. - /// - /// If the `option` is none, the platform doesn't maintain a - /// modification timestamp for this file. - pub data_modification_timestamp: Option, - /// Last file status-change timestamp. - /// - /// If the `option` is none, the platform doesn't maintain a - /// status-change timestamp for this file. - pub status_change_timestamp: Option, - } - impl ::core::fmt::Debug for DescriptorStat { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("DescriptorStat").field("type", &self.type_).field("link-count", &self.link_count).field("size", &self.size).field("data-access-timestamp", &self.data_access_timestamp).field("data-modification-timestamp", &self.data_modification_timestamp).field("status-change-timestamp", &self.status_change_timestamp).finish() - } - } - /// When setting a timestamp, this gives the value to set it to. - #[derive(Clone, Copy)] - pub enum NewTimestamp { - /// Leave the timestamp set to its previous value. - NoChange, - /// Set the timestamp to the current time of the system clock associated - /// with the filesystem. - Now, - /// Set the timestamp to the given value. - Timestamp(Datetime), - } - impl ::core::fmt::Debug for NewTimestamp { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - NewTimestamp::NoChange => { - f.debug_tuple("NewTimestamp::NoChange").finish() - } - NewTimestamp::Now => { - f.debug_tuple("NewTimestamp::Now").finish() - } - NewTimestamp::Timestamp(e) => { - f.debug_tuple("NewTimestamp::Timestamp").field(e).finish() - } - } - } - } - /// A directory entry. - #[derive(Clone)] - pub struct DirectoryEntry { - /// The type of the file referred to by this directory entry. - pub type_: DescriptorType, - /// The name of the object. - pub name: _rt::String, - } - impl ::core::fmt::Debug for DirectoryEntry { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("DirectoryEntry").field("type", &self.type_).field("name", &self.name).finish() - } - } - /// Error codes returned by functions, similar to `errno` in POSIX. - /// Not all of these error codes are returned by the functions provided by this - /// API; some are used in higher-level library layers, and others are provided - /// merely for alignment with POSIX. - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum ErrorCode { - /// Permission denied, similar to `EACCES` in POSIX. - Access, - /// Resource unavailable, or operation would block, similar to `EAGAIN` and `EWOULDBLOCK` in POSIX. - WouldBlock, - /// Connection already in progress, similar to `EALREADY` in POSIX. - Already, - /// Bad descriptor, similar to `EBADF` in POSIX. - BadDescriptor, - /// Device or resource busy, similar to `EBUSY` in POSIX. - Busy, - /// Resource deadlock would occur, similar to `EDEADLK` in POSIX. - Deadlock, - /// Storage quota exceeded, similar to `EDQUOT` in POSIX. - Quota, - /// File exists, similar to `EEXIST` in POSIX. - Exist, - /// File too large, similar to `EFBIG` in POSIX. - FileTooLarge, - /// Illegal byte sequence, similar to `EILSEQ` in POSIX. - IllegalByteSequence, - /// Operation in progress, similar to `EINPROGRESS` in POSIX. - InProgress, - /// Interrupted function, similar to `EINTR` in POSIX. - Interrupted, - /// Invalid argument, similar to `EINVAL` in POSIX. - Invalid, - /// I/O error, similar to `EIO` in POSIX. - Io, - /// Is a directory, similar to `EISDIR` in POSIX. - IsDirectory, - /// Too many levels of symbolic links, similar to `ELOOP` in POSIX. - Loop, - /// Too many links, similar to `EMLINK` in POSIX. - TooManyLinks, - /// Message too large, similar to `EMSGSIZE` in POSIX. - MessageSize, - /// Filename too long, similar to `ENAMETOOLONG` in POSIX. - NameTooLong, - /// No such device, similar to `ENODEV` in POSIX. - NoDevice, - /// No such file or directory, similar to `ENOENT` in POSIX. - NoEntry, - /// No locks available, similar to `ENOLCK` in POSIX. - NoLock, - /// Not enough space, similar to `ENOMEM` in POSIX. - InsufficientMemory, - /// No space left on device, similar to `ENOSPC` in POSIX. - InsufficientSpace, - /// Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX. - NotDirectory, - /// Directory not empty, similar to `ENOTEMPTY` in POSIX. - NotEmpty, - /// State not recoverable, similar to `ENOTRECOVERABLE` in POSIX. - NotRecoverable, - /// Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX. - Unsupported, - /// Inappropriate I/O control operation, similar to `ENOTTY` in POSIX. - NoTty, - /// No such device or address, similar to `ENXIO` in POSIX. - NoSuchDevice, - /// Value too large to be stored in data type, similar to `EOVERFLOW` in POSIX. - Overflow, - /// Operation not permitted, similar to `EPERM` in POSIX. - NotPermitted, - /// Broken pipe, similar to `EPIPE` in POSIX. - Pipe, - /// Read-only file system, similar to `EROFS` in POSIX. - ReadOnly, - /// Invalid seek, similar to `ESPIPE` in POSIX. - InvalidSeek, - /// Text file busy, similar to `ETXTBSY` in POSIX. - TextFileBusy, - /// Cross-device link, similar to `EXDEV` in POSIX. - CrossDevice, - } - impl ErrorCode{ - pub fn name(&self) -> &'static str { - match self { - ErrorCode::Access => "access", - ErrorCode::WouldBlock => "would-block", - ErrorCode::Already => "already", - ErrorCode::BadDescriptor => "bad-descriptor", - ErrorCode::Busy => "busy", - ErrorCode::Deadlock => "deadlock", - ErrorCode::Quota => "quota", - ErrorCode::Exist => "exist", - ErrorCode::FileTooLarge => "file-too-large", - ErrorCode::IllegalByteSequence => "illegal-byte-sequence", - ErrorCode::InProgress => "in-progress", - ErrorCode::Interrupted => "interrupted", - ErrorCode::Invalid => "invalid", - ErrorCode::Io => "io", - ErrorCode::IsDirectory => "is-directory", - ErrorCode::Loop => "loop", - ErrorCode::TooManyLinks => "too-many-links", - ErrorCode::MessageSize => "message-size", - ErrorCode::NameTooLong => "name-too-long", - ErrorCode::NoDevice => "no-device", - ErrorCode::NoEntry => "no-entry", - ErrorCode::NoLock => "no-lock", - ErrorCode::InsufficientMemory => "insufficient-memory", - ErrorCode::InsufficientSpace => "insufficient-space", - ErrorCode::NotDirectory => "not-directory", - ErrorCode::NotEmpty => "not-empty", - ErrorCode::NotRecoverable => "not-recoverable", - ErrorCode::Unsupported => "unsupported", - ErrorCode::NoTty => "no-tty", - ErrorCode::NoSuchDevice => "no-such-device", - ErrorCode::Overflow => "overflow", - ErrorCode::NotPermitted => "not-permitted", - ErrorCode::Pipe => "pipe", - ErrorCode::ReadOnly => "read-only", - ErrorCode::InvalidSeek => "invalid-seek", - ErrorCode::TextFileBusy => "text-file-busy", - ErrorCode::CrossDevice => "cross-device", - } - } - 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.", - } - } - } - impl ::core::fmt::Debug for ErrorCode{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("ErrorCode") - .field("code", &(*self as i32)) - .field("name", &self.name()) - .field("message", &self.message()) - .finish() - } - } - impl ::core::fmt::Display for ErrorCode{ - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{} (error {})", self.name(), *self as i32) - } - } - - impl std::error::Error for ErrorCode {} - - impl ErrorCode{ - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> ErrorCode{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => ErrorCode::Access, - 1 => ErrorCode::WouldBlock, - 2 => ErrorCode::Already, - 3 => ErrorCode::BadDescriptor, - 4 => ErrorCode::Busy, - 5 => ErrorCode::Deadlock, - 6 => ErrorCode::Quota, - 7 => ErrorCode::Exist, - 8 => ErrorCode::FileTooLarge, - 9 => ErrorCode::IllegalByteSequence, - 10 => ErrorCode::InProgress, - 11 => ErrorCode::Interrupted, - 12 => ErrorCode::Invalid, - 13 => ErrorCode::Io, - 14 => ErrorCode::IsDirectory, - 15 => ErrorCode::Loop, - 16 => ErrorCode::TooManyLinks, - 17 => ErrorCode::MessageSize, - 18 => ErrorCode::NameTooLong, - 19 => ErrorCode::NoDevice, - 20 => ErrorCode::NoEntry, - 21 => ErrorCode::NoLock, - 22 => ErrorCode::InsufficientMemory, - 23 => ErrorCode::InsufficientSpace, - 24 => ErrorCode::NotDirectory, - 25 => ErrorCode::NotEmpty, - 26 => ErrorCode::NotRecoverable, - 27 => ErrorCode::Unsupported, - 28 => ErrorCode::NoTty, - 29 => ErrorCode::NoSuchDevice, - 30 => ErrorCode::Overflow, - 31 => ErrorCode::NotPermitted, - 32 => ErrorCode::Pipe, - 33 => ErrorCode::ReadOnly, - 34 => ErrorCode::InvalidSeek, - 35 => ErrorCode::TextFileBusy, - 36 => ErrorCode::CrossDevice, - - _ => panic!("invalid enum discriminant"), - } - } - } - - /// File or memory access pattern advisory information. - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] - pub enum Advice { - /// The application has no advice to give on its behavior with respect - /// to the specified data. - Normal, - /// The application expects to access the specified data sequentially - /// from lower offsets to higher offsets. - Sequential, - /// The application expects to access the specified data in a random - /// order. - Random, - /// The application expects to access the specified data in the near - /// future. - WillNeed, - /// The application expects that it will not access the specified data - /// in the near future. - DontNeed, - /// The application expects to access the specified data once and then - /// not reuse it thereafter. - NoReuse, - } - impl ::core::fmt::Debug for Advice { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - Advice::Normal => { - f.debug_tuple("Advice::Normal").finish() - } - Advice::Sequential => { - f.debug_tuple("Advice::Sequential").finish() - } - Advice::Random => { - f.debug_tuple("Advice::Random").finish() - } - Advice::WillNeed => { - f.debug_tuple("Advice::WillNeed").finish() - } - Advice::DontNeed => { - f.debug_tuple("Advice::DontNeed").finish() - } - Advice::NoReuse => { - f.debug_tuple("Advice::NoReuse").finish() - } - } - } - } - - impl Advice{ - #[doc(hidden)] - pub unsafe fn _lift(val: u8) -> Advice{ - if !cfg!(debug_assertions) { - return ::core::mem::transmute(val); - } - - match val { - 0 => Advice::Normal, - 1 => Advice::Sequential, - 2 => Advice::Random, - 3 => Advice::WillNeed, - 4 => Advice::DontNeed, - 5 => Advice::NoReuse, - - _ => panic!("invalid enum discriminant"), - } - } - } - - /// A 128-bit hash value, split into parts because wasm doesn't have a - /// 128-bit integer type. - #[repr(C)] - #[derive(Clone, Copy)] - pub struct MetadataHashValue { - /// 64 bits of a 128-bit hash value. - pub lower: u64, - /// Another 64 bits of a 128-bit hash value. - pub upper: u64, - } - impl ::core::fmt::Debug for MetadataHashValue { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("MetadataHashValue").field("lower", &self.lower).field("upper", &self.upper).finish() - } - } - /// A descriptor is a reference to a filesystem object, which may be a file, - /// directory, named pipe, special file, or other object on which filesystem - /// calls may be made. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Descriptor{ - handle: _rt::Resource, - } - - impl Descriptor{ - #[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 Descriptor{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]descriptor"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// A stream of directory entries. - - #[derive(Debug)] - #[repr(transparent)] - pub struct DirectoryEntryStream{ - handle: _rt::Resource, - } - - impl DirectoryEntryStream{ - #[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 DirectoryEntryStream{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]directory-entry-stream"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return a stream for reading from a file, if available. - /// - /// May fail with an error-code describing why the file cannot be read. - /// - /// Multiple read, write, and append streams may be active on the same open - /// file and they do not interfere with each other. - /// - /// Note: This allows using `read-stream`, which is similar to `read` in POSIX. - pub fn read_via_stream(&self,offset: Filesize,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.read-via-stream"] - fn wit_import(_: i32, _: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, _rt::as_i64(offset), ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = { - let l2 = *ptr0.add(4).cast::(); - - super::super::super::wasi::io::streams::InputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(4).cast::()); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return a stream for writing to a file, if available. - /// - /// May fail with an error-code describing why the file cannot be written. - /// - /// Note: This allows using `write-stream`, which is similar to `write` in - /// POSIX. - pub fn write_via_stream(&self,offset: Filesize,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.write-via-stream"] - fn wit_import(_: i32, _: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, _rt::as_i64(offset), ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = { - let l2 = *ptr0.add(4).cast::(); - - super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(4).cast::()); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return a stream for appending to a file, if available. - /// - /// May fail with an error-code describing why the file cannot be appended. - /// - /// Note: This allows using `write-stream`, which is similar to `write` with - /// `O_APPEND` in in POSIX. - pub fn append_via_stream(&self,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.append-via-stream"] - 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 => { - let e = { - let l2 = *ptr0.add(4).cast::(); - - super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(4).cast::()); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Provide file advisory information on a descriptor. - /// - /// This is similar to `posix_fadvise` in POSIX. - pub fn advise(&self,offset: Filesize,length: Filesize,advice: Advice,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.advise"] - fn wit_import(_: i32, _: i64, _: i64, _: i32, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i64, _: i32, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, _rt::as_i64(offset), _rt::as_i64(length), advice.clone() as i32, ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*ptr0.add(1).cast::()); - - ErrorCode::_lift(l2 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Synchronize the data of a file to disk. - /// - /// This function succeeds with no effect if the file descriptor is not - /// opened for writing. - /// - /// Note: This is similar to `fdatasync` in POSIX. - pub fn sync_data(&self,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.sync-data"] - 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 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*ptr0.add(1).cast::()); - - ErrorCode::_lift(l2 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Get flags associated with a descriptor. - /// - /// Note: This returns similar flags to `fcntl(fd, F_GETFL)` in POSIX. - /// - /// Note: This returns the value that was the `fs_flags` value returned - /// from `fdstat_get` in earlier versions of WASI. - pub fn get_flags(&self,) -> Result{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.get-flags"] - 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 => { - let e = { - let l2 = i32::from(*ptr0.add(1).cast::()); - - DescriptorFlags::empty() | DescriptorFlags::from_bits_retain(((l2 as u8) << 0) as _) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Get the dynamic type of a descriptor. - /// - /// Note: This returns the same value as the `type` field of the `fd-stat` - /// returned by `stat`, `stat-at` and similar. - /// - /// Note: This returns similar flags to the `st_mode & S_IFMT` value provided - /// by `fstat` in POSIX. - /// - /// Note: This returns the value that was the `fs_filetype` value returned - /// from `fdstat_get` in earlier versions of WASI. - pub fn get_type(&self,) -> Result{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.get-type"] - 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 => { - let e = { - let l2 = i32::from(*ptr0.add(1).cast::()); - - DescriptorType::_lift(l2 as u8) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(1).cast::()); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Adjust the size of an open file. If this increases the file's size, the - /// extra bytes are filled with zeros. - /// - /// Note: This was called `fd_filestat_set_size` in earlier versions of WASI. - pub fn set_size(&self,size: Filesize,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.set-size"] - fn wit_import(_: i32, _: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, _rt::as_i64(size), ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*ptr0.add(1).cast::()); - - ErrorCode::_lift(l2 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Adjust the timestamps of an open file or directory. - /// - /// Note: This is similar to `futimens` in POSIX. - /// - /// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. - pub fn set_times(&self,data_access_timestamp: NewTimestamp,data_modification_timestamp: NewTimestamp,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let (result1_0,result1_1,result1_2,) = match data_access_timestamp { - NewTimestamp::NoChange=> { - (0i32, 0i64, 0i32) - } - NewTimestamp::Now=> { - (1i32, 0i64, 0i32) - } - NewTimestamp::Timestamp(e) => { - let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds0, nanoseconds:nanoseconds0, } = e; - - (2i32, _rt::as_i64(seconds0), _rt::as_i32(nanoseconds0)) - }, - }; - let (result3_0,result3_1,result3_2,) = match data_modification_timestamp { - NewTimestamp::NoChange=> { - (0i32, 0i64, 0i32) - } - NewTimestamp::Now=> { - (1i32, 0i64, 0i32) - } - NewTimestamp::Timestamp(e) => { - let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds2, nanoseconds:nanoseconds2, } = e; - - (2i32, _rt::as_i64(seconds2), _rt::as_i32(nanoseconds2)) - }, - }; - let ptr4 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.set-times"] - fn wit_import(_: i32, _: i32, _: i64, _: i32, _: i32, _: i64, _: i32, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: i32, _: i32, _: i64, _: i32, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, result1_0, result1_1, result1_2, result3_0, result3_1, result3_2, ptr4); - let l5 = i32::from(*ptr4.add(0).cast::()); - match l5 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*ptr4.add(1).cast::()); - - ErrorCode::_lift(l6 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Read from a descriptor, without using and updating the descriptor's offset. - /// - /// This function returns a list of bytes containing the data that was - /// read, along with a bool which, when true, indicates that the end of the - /// file was reached. The returned list will contain up to `length` bytes; it - /// may return fewer than requested, if the end of the file is reached or - /// if the I/O operation is interrupted. - /// - /// In the future, this may change to return a `stream`. - /// - /// Note: This is similar to `pread` in POSIX. - pub fn read(&self,length: Filesize,offset: Filesize,) -> Result<(_rt::Vec::,bool,),ErrorCode>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.read"] - fn wit_import(_: i32, _: i64, _: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: i64, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, _rt::as_i64(length), _rt::as_i64(offset), ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - let l5 = i32::from(*ptr0.add(12).cast::()); - - (_rt::Vec::from_raw_parts(l2.cast(), len4, len4), _rt::bool_lift(l5 as u8)) - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*ptr0.add(4).cast::()); - - ErrorCode::_lift(l6 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Write to a descriptor, without using and updating the descriptor's offset. - /// - /// It is valid to write past the end of a file; the file is extended to the - /// extent of the write, with bytes between the previous end and the start of - /// the write set to zero. - /// - /// In the future, this may change to take a `stream`. - /// - /// Note: This is similar to `pwrite` in POSIX. - pub fn write(&self,buffer: &[u8],offset: Filesize,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let vec0 = buffer; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.write"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: i64, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, _rt::as_i64(offset), ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = { - let l3 = *ptr1.add(8).cast::(); - - l3 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*ptr1.add(8).cast::()); - - ErrorCode::_lift(l4 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Read directory entries from a directory. - /// - /// On filesystems where directories contain entries referring to themselves - /// and their parents, often named `.` and `..` respectively, these entries - /// are omitted. - /// - /// This always returns a new stream which starts at the beginning of the - /// directory. Multiple streams may be active on the same directory, and they - /// do not interfere with each other. - pub fn read_directory(&self,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.read-directory"] - 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 => { - let e = { - let l2 = *ptr0.add(4).cast::(); - - DirectoryEntryStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(4).cast::()); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Synchronize the data and metadata of a file to disk. - /// - /// This function succeeds with no effect if the file descriptor is not - /// opened for writing. - /// - /// Note: This is similar to `fsync` in POSIX. - pub fn sync(&self,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.sync"] - 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 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*ptr0.add(1).cast::()); - - ErrorCode::_lift(l2 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Create a directory. - /// - /// Note: This is similar to `mkdirat` in POSIX. - pub fn create_directory_at(&self,path: &str,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.create-directory-at"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr1.add(1).cast::()); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return the attributes of an open file or directory. - /// - /// Note: This is similar to `fstat` in POSIX, except that it does not return - /// device and inode information. For testing whether two descriptors refer to - /// the same underlying filesystem object, use `is-same-object`. To obtain - /// additional data that can be used do determine whether a file has been - /// modified, use `metadata-hash`. - /// - /// Note: This was called `fd_filestat_get` in earlier versions of WASI. - pub fn stat(&self,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 104]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 104]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.stat"] - 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 => { - let e = { - let l2 = i32::from(*ptr0.add(8).cast::()); - let l3 = *ptr0.add(16).cast::(); - let l4 = *ptr0.add(24).cast::(); - let l5 = i32::from(*ptr0.add(32).cast::()); - let l8 = i32::from(*ptr0.add(56).cast::()); - let l11 = i32::from(*ptr0.add(80).cast::()); - - DescriptorStat{ - type_: DescriptorType::_lift(l2 as u8), - link_count: l3 as u64, - size: l4 as u64, - data_access_timestamp: match l5 { - 0 => None, - 1 => { - let e = { - let l6 = *ptr0.add(40).cast::(); - let l7 = *ptr0.add(48).cast::(); - - super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l6 as u64, - nanoseconds: l7 as u32, - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - data_modification_timestamp: match l8 { - 0 => None, - 1 => { - let e = { - let l9 = *ptr0.add(64).cast::(); - let l10 = *ptr0.add(72).cast::(); - - super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l9 as u64, - nanoseconds: l10 as u32, - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - status_change_timestamp: match l11 { - 0 => None, - 1 => { - let e = { - let l12 = *ptr0.add(88).cast::(); - let l13 = *ptr0.add(96).cast::(); - - super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l12 as u64, - nanoseconds: l13 as u32, - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - Ok(e) - } - 1 => { - let e = { - let l14 = i32::from(*ptr0.add(8).cast::()); - - ErrorCode::_lift(l14 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return the attributes of a file or directory. - /// - /// Note: This is similar to `fstatat` in POSIX, except that it does not - /// return device and inode information. See the `stat` description for a - /// discussion of alternatives. - /// - /// Note: This was called `path_filestat_get` in earlier versions of WASI. - pub fn stat_at(&self,path_flags: PathFlags,path: &str,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 104]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 104]); - let flags0 = path_flags; - let vec1 = path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.stat-at"] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1.cast_mut(), len1, ptr2); - let l3 = i32::from(*ptr2.add(0).cast::()); - match l3 { - 0 => { - let e = { - let l4 = i32::from(*ptr2.add(8).cast::()); - let l5 = *ptr2.add(16).cast::(); - let l6 = *ptr2.add(24).cast::(); - let l7 = i32::from(*ptr2.add(32).cast::()); - let l10 = i32::from(*ptr2.add(56).cast::()); - let l13 = i32::from(*ptr2.add(80).cast::()); - - DescriptorStat{ - type_: DescriptorType::_lift(l4 as u8), - link_count: l5 as u64, - size: l6 as u64, - data_access_timestamp: match l7 { - 0 => None, - 1 => { - let e = { - let l8 = *ptr2.add(40).cast::(); - let l9 = *ptr2.add(48).cast::(); - - super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l8 as u64, - nanoseconds: l9 as u32, - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - data_modification_timestamp: match l10 { - 0 => None, - 1 => { - let e = { - let l11 = *ptr2.add(64).cast::(); - let l12 = *ptr2.add(72).cast::(); - - super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l11 as u64, - nanoseconds: l12 as u32, - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - status_change_timestamp: match l13 { - 0 => None, - 1 => { - let e = { - let l14 = *ptr2.add(88).cast::(); - let l15 = *ptr2.add(96).cast::(); - - super::super::super::wasi::clocks::wall_clock::Datetime{ - seconds: l14 as u64, - nanoseconds: l15 as u32, - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - Ok(e) - } - 1 => { - let e = { - let l16 = i32::from(*ptr2.add(8).cast::()); - - ErrorCode::_lift(l16 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Adjust the timestamps of a file or directory. - /// - /// Note: This is similar to `utimensat` in POSIX. - /// - /// Note: This was called `path_filestat_set_times` in earlier versions of - /// WASI. - pub fn set_times_at(&self,path_flags: PathFlags,path: &str,data_access_timestamp: NewTimestamp,data_modification_timestamp: NewTimestamp,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let flags0 = path_flags; - let vec1 = path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let (result3_0,result3_1,result3_2,) = match data_access_timestamp { - NewTimestamp::NoChange=> { - (0i32, 0i64, 0i32) - } - NewTimestamp::Now=> { - (1i32, 0i64, 0i32) - } - NewTimestamp::Timestamp(e) => { - let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds2, nanoseconds:nanoseconds2, } = e; - - (2i32, _rt::as_i64(seconds2), _rt::as_i32(nanoseconds2)) - }, - }; - let (result5_0,result5_1,result5_2,) = match data_modification_timestamp { - NewTimestamp::NoChange=> { - (0i32, 0i64, 0i32) - } - NewTimestamp::Now=> { - (1i32, 0i64, 0i32) - } - NewTimestamp::Timestamp(e) => { - let super::super::super::wasi::clocks::wall_clock::Datetime{ seconds:seconds4, nanoseconds:nanoseconds4, } = e; - - (2i32, _rt::as_i64(seconds4), _rt::as_i32(nanoseconds4)) - }, - }; - let ptr6 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.set-times-at"] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: i32, _: i64, _: i32, _: i32, _: i64, _: i32, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: i32, _: i64, _: i32, _: i32, _: i64, _: i32, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1.cast_mut(), len1, result3_0, result3_1, result3_2, result5_0, result5_1, result5_2, ptr6); - let l7 = i32::from(*ptr6.add(0).cast::()); - match l7 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l8 = i32::from(*ptr6.add(1).cast::()); - - ErrorCode::_lift(l8 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Create a hard link. - /// - /// Note: This is similar to `linkat` in POSIX. - pub fn link_at(&self,old_path_flags: PathFlags,old_path: &str,new_descriptor: &Descriptor,new_path: &str,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let flags0 = old_path_flags; - let vec1 = old_path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let vec2 = new_path; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - let ptr3 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.link-at"] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1.cast_mut(), len1, (new_descriptor).handle() as i32, ptr2.cast_mut(), len2, ptr3); - let l4 = i32::from(*ptr3.add(0).cast::()); - match l4 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*ptr3.add(1).cast::()); - - ErrorCode::_lift(l5 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Open a file or directory. - /// - /// The returned descriptor is not guaranteed to be the lowest-numbered - /// descriptor not currently open/ it is randomized to prevent applications - /// from depending on making assumptions about indexes, since this is - /// error-prone in multi-threaded contexts. The returned descriptor is - /// guaranteed to be less than 2**31. - /// - /// If `flags` contains `descriptor-flags::mutate-directory`, and the base - /// descriptor doesn't have `descriptor-flags::mutate-directory` set, - /// `open-at` fails with `error-code::read-only`. - /// - /// If `flags` contains `write` or `mutate-directory`, or `open-flags` - /// contains `truncate` or `create`, and the base descriptor doesn't have - /// `descriptor-flags::mutate-directory` set, `open-at` fails with - /// `error-code::read-only`. - /// - /// Note: This is similar to `openat` in POSIX. - pub fn open_at(&self,path_flags: PathFlags,path: &str,open_flags: OpenFlags,flags: DescriptorFlags,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let flags0 = path_flags; - let vec1 = path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let flags2 = open_flags; - let flags3 = flags; - let ptr4 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.open-at"] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: i32, _: i32, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1.cast_mut(), len1, (flags2.bits() >> 0) as i32, (flags3.bits() >> 0) as i32, ptr4); - let l5 = i32::from(*ptr4.add(0).cast::()); - match l5 { - 0 => { - let e = { - let l6 = *ptr4.add(4).cast::(); - - Descriptor::from_handle(l6 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l7 = i32::from(*ptr4.add(4).cast::()); - - ErrorCode::_lift(l7 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Read the contents of a symbolic link. - /// - /// If the contents contain an absolute or rooted path in the underlying - /// filesystem, this function fails with `error-code::not-permitted`. - /// - /// Note: This is similar to `readlinkat` in POSIX. - pub fn readlink_at(&self,path: &str,) -> Result<_rt::String,ErrorCode>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.readlink-at"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = { - let l3 = *ptr1.add(4).cast::<*mut u8>(); - let l4 = *ptr1.add(8).cast::(); - let len5 = l4; - let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); - - _rt::string_lift(bytes5) - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*ptr1.add(4).cast::()); - - ErrorCode::_lift(l6 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Remove a directory. - /// - /// Return `error-code::not-empty` if the directory is not empty. - /// - /// Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. - pub fn remove_directory_at(&self,path: &str,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.remove-directory-at"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr1.add(1).cast::()); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Rename a filesystem object. - /// - /// Note: This is similar to `renameat` in POSIX. - pub fn rename_at(&self,old_path: &str,new_descriptor: &Descriptor,new_path: &str,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = old_path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let vec1 = new_path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.rename-at"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, (new_descriptor).handle() as i32, ptr1.cast_mut(), len1, ptr2); - let l3 = i32::from(*ptr2.add(0).cast::()); - match l3 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*ptr2.add(1).cast::()); - - ErrorCode::_lift(l4 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Create a symbolic link (also known as a "symlink"). - /// - /// If `old-path` starts with `/`, the function fails with - /// `error-code::not-permitted`. - /// - /// Note: This is similar to `symlinkat` in POSIX. - pub fn symlink_at(&self,old_path: &str,new_path: &str,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = old_path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let vec1 = new_path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.symlink-at"] - 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, ptr1.cast_mut(), len1, ptr2); - let l3 = i32::from(*ptr2.add(0).cast::()); - match l3 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*ptr2.add(1).cast::()); - - ErrorCode::_lift(l4 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Unlink a filesystem object that is not a directory. - /// - /// Return `error-code::is-directory` if the path refers to a directory. - /// Note: This is similar to `unlinkat(fd, path, 0)` in POSIX. - pub fn unlink_file_at(&self,path: &str,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = path; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.unlink-file-at"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr1.add(1).cast::()); - - ErrorCode::_lift(l3 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Test whether two descriptors refer to the same filesystem object. - /// - /// In POSIX, this corresponds to testing whether the two descriptors have the - /// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers. - /// wasi-filesystem does not expose device and inode numbers, so this function - /// may be used instead. - pub fn is_same_object(&self,other: &Descriptor,) -> bool{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.is-same-object"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, (other).handle() as i32); - _rt::bool_lift(ret as u8) - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return a hash of the metadata associated with a filesystem object referred - /// to by a descriptor. - /// - /// This returns a hash of the last-modification timestamp and file size, and - /// may also include the inode number, device number, birth timestamp, and - /// other metadata fields that may change when the file is modified or - /// replaced. It may also include a secret value chosen by the - /// implementation and not otherwise exposed. - /// - /// Implementations are encourated to provide the following properties: - /// - /// - If the file is not modified or replaced, the computed hash value should - /// usually not change. - /// - If the object is modified or replaced, the computed hash value should - /// usually change. - /// - The inputs to the hash should not be easily computable from the - /// computed hash. - /// - /// However, none of these is required. - pub fn metadata_hash(&self,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.metadata-hash"] - 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 => { - let e = { - let l2 = *ptr0.add(8).cast::(); - let l3 = *ptr0.add(16).cast::(); - - MetadataHashValue{ - lower: l2 as u64, - upper: l3 as u64, - } - }; - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*ptr0.add(8).cast::()); - - ErrorCode::_lift(l4 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Descriptor { - #[allow(unused_unsafe, clippy::all)] - /// Return a hash of the metadata associated with a filesystem object referred - /// to by a directory descriptor and a relative path. - /// - /// This performs the same hash computation as `metadata-hash`. - pub fn metadata_hash_at(&self,path_flags: PathFlags,path: &str,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); - let flags0 = path_flags; - let vec1 = path; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]descriptor.metadata-hash-at"] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, (flags0.bits() >> 0) as i32, ptr1.cast_mut(), len1, ptr2); - let l3 = i32::from(*ptr2.add(0).cast::()); - match l3 { - 0 => { - let e = { - let l4 = *ptr2.add(8).cast::(); - let l5 = *ptr2.add(16).cast::(); - - MetadataHashValue{ - lower: l4 as u64, - upper: l5 as u64, - } - }; - Ok(e) - } - 1 => { - let e = { - let l6 = i32::from(*ptr2.add(8).cast::()); - - ErrorCode::_lift(l6 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl DirectoryEntryStream { - #[allow(unused_unsafe, clippy::all)] - /// Read a single directory entry from a `directory-entry-stream`. - pub fn read_directory_entry(&self,) -> Result,ErrorCode>{ - 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 = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "[method]directory-entry-stream.read-directory-entry"] - 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 => { - let e = { - let l2 = i32::from(*ptr0.add(4).cast::()); - - match l2 { - 0 => None, - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(8).cast::()); - let l4 = *ptr0.add(12).cast::<*mut u8>(); - let l5 = *ptr0.add(16).cast::(); - let len6 = l5; - let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); - - DirectoryEntry{ - type_: DescriptorType::_lift(l3 as u8), - name: _rt::string_lift(bytes6), - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - Ok(e) - } - 1 => { - let e = { - let l7 = i32::from(*ptr0.add(4).cast::()); - - ErrorCode::_lift(l7 as u8) - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - #[allow(unused_unsafe, clippy::all)] - /// Attempts to extract a filesystem-related `error-code` from the stream - /// `error` provided. - /// - /// Stream operations which return `stream-error::last-operation-failed` - /// have a payload with more information about the operation that failed. - /// This payload can be passed through to this function to see if there's - /// filesystem-related information about the error to return. - /// - /// Note that this function is fallible because not all stream-related - /// errors are filesystem-related errors. - pub fn filesystem_error_code(err: &Error,) -> Option{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/types@0.2.0")] - extern "C" { - #[link_name = "filesystem-error-code"] - fn wit_import(_: i32, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, ){ unreachable!() } - wit_import((err).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(1).cast::()); - - ErrorCode::_lift(l2 as u8) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - - } - - #[allow(dead_code, clippy::all)] - pub mod preopens { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - pub type Descriptor = super::super::super::wasi::filesystem::types::Descriptor; - #[allow(unused_unsafe, clippy::all)] - /// Return the set of preopened directories, and their path. - pub fn get_directories() -> _rt::Vec::<(Descriptor,_rt::String,)>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:filesystem/preopens@0.2.0")] - extern "C" { - #[link_name = "get-directories"] - 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::<*mut u8>(); - let l2 = *ptr0.add(4).cast::(); - let base7 = l1; - let len7 = l2; - let mut result7 = _rt::Vec::with_capacity(len7); - for i in 0..len7 { - let base = base7.add(i * 12); - let e7 = { - let l3 = *base.add(0).cast::(); - let l4 = *base.add(4).cast::<*mut u8>(); - let l5 = *base.add(8).cast::(); - let len6 = l5; - let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); - - (super::super::super::wasi::filesystem::types::Descriptor::from_handle(l3 as u32), _rt::string_lift(bytes6)) - }; - result7.push(e7); - } - _rt::cabi_dealloc(base7, len7 * 12, 4); - result7 - } - } - - } - - } - #[allow(dead_code)] - pub mod http { - #[allow(dead_code, clippy::all)] - pub mod types { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration; - pub type InputStream = super::super::super::wasi::io::streams::InputStream; - pub type OutputStream = super::super::super::wasi::io::streams::OutputStream; - pub type IoError = super::super::super::wasi::io::error::Error; - /// Hermes doews not support `poll` - /// use wasi:io/poll@0.2.0.{pollable}; - /// This type corresponds to HTTP standard Methods. - #[derive(Clone)] - pub enum Method { - Get, - Head, - Post, - Put, - Delete, - Connect, - Options, - Trace, - Patch, - Other(_rt::String), - } - impl ::core::fmt::Debug for Method { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - Method::Get => { - f.debug_tuple("Method::Get").finish() - } - Method::Head => { - f.debug_tuple("Method::Head").finish() - } - Method::Post => { - f.debug_tuple("Method::Post").finish() - } - Method::Put => { - f.debug_tuple("Method::Put").finish() - } - Method::Delete => { - f.debug_tuple("Method::Delete").finish() - } - Method::Connect => { - f.debug_tuple("Method::Connect").finish() - } - Method::Options => { - f.debug_tuple("Method::Options").finish() - } - Method::Trace => { - f.debug_tuple("Method::Trace").finish() - } - Method::Patch => { - f.debug_tuple("Method::Patch").finish() - } - Method::Other(e) => { - f.debug_tuple("Method::Other").field(e).finish() - } - } - } - } - /// This type corresponds to HTTP standard Related Schemes. - #[derive(Clone)] - pub enum Scheme { - Http, - Https, - Other(_rt::String), - } - impl ::core::fmt::Debug for Scheme { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - Scheme::Http => { - f.debug_tuple("Scheme::Http").finish() - } - Scheme::Https => { - f.debug_tuple("Scheme::Https").finish() - } - Scheme::Other(e) => { - f.debug_tuple("Scheme::Other").field(e).finish() - } - } - } - } - /// Defines the case payload type for `DNS-error` above: - #[derive(Clone)] - pub struct DnsErrorPayload { - pub rcode: Option<_rt::String>, - pub info_code: Option, - } - impl ::core::fmt::Debug for DnsErrorPayload { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("DnsErrorPayload").field("rcode", &self.rcode).field("info-code", &self.info_code).finish() - } - } - /// Defines the case payload type for `TLS-alert-received` above: - #[derive(Clone)] - pub struct TlsAlertReceivedPayload { - pub alert_id: Option, - pub alert_message: Option<_rt::String>, - } - impl ::core::fmt::Debug for TlsAlertReceivedPayload { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("TlsAlertReceivedPayload").field("alert-id", &self.alert_id).field("alert-message", &self.alert_message).finish() - } - } - /// Defines the case payload type for `HTTP-response-{header,trailer}-size` above: - #[derive(Clone)] - pub struct FieldSizePayload { - pub field_name: Option<_rt::String>, - pub field_size: Option, - } - impl ::core::fmt::Debug for FieldSizePayload { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("FieldSizePayload").field("field-name", &self.field_name).field("field-size", &self.field_size).finish() - } - } - /// These cases are inspired by the IANA HTTP Proxy Error Types: - /// https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types - #[derive(Clone)] - pub enum ErrorCode { - DnsTimeout, - DnsError(DnsErrorPayload), - DestinationNotFound, - DestinationUnavailable, - DestinationIpProhibited, - DestinationIpUnroutable, - ConnectionRefused, - ConnectionTerminated, - ConnectionTimeout, - ConnectionReadTimeout, - ConnectionWriteTimeout, - ConnectionLimitReached, - TlsProtocolError, - TlsCertificateError, - TlsAlertReceived(TlsAlertReceivedPayload), - HttpRequestDenied, - HttpRequestLengthRequired, - HttpRequestBodySize(Option), - HttpRequestMethodInvalid, - HttpRequestUriInvalid, - HttpRequestUriTooLong, - HttpRequestHeaderSectionSize(Option), - HttpRequestHeaderSize(Option), - HttpRequestTrailerSectionSize(Option), - HttpRequestTrailerSize(FieldSizePayload), - HttpResponseIncomplete, - HttpResponseHeaderSectionSize(Option), - HttpResponseHeaderSize(FieldSizePayload), - HttpResponseBodySize(Option), - HttpResponseTrailerSectionSize(Option), - HttpResponseTrailerSize(FieldSizePayload), - HttpResponseTransferCoding(Option<_rt::String>), - HttpResponseContentCoding(Option<_rt::String>), - HttpResponseTimeout, - HttpUpgradeFailed, - HttpProtocolError, - LoopDetected, - ConfigurationError, - /// This is a catch-all error for anything that doesn't fit cleanly into a - /// more specific case. It also includes an optional string for an - /// unstructured description of the error. Users should not depend on the - /// string for diagnosing errors, as it's not required to be consistent - /// between implementations. - InternalError(Option<_rt::String>), - } - impl ::core::fmt::Debug for ErrorCode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - ErrorCode::DnsTimeout => { - f.debug_tuple("ErrorCode::DnsTimeout").finish() - } - ErrorCode::DnsError(e) => { - f.debug_tuple("ErrorCode::DnsError").field(e).finish() - } - ErrorCode::DestinationNotFound => { - f.debug_tuple("ErrorCode::DestinationNotFound").finish() - } - ErrorCode::DestinationUnavailable => { - f.debug_tuple("ErrorCode::DestinationUnavailable").finish() - } - ErrorCode::DestinationIpProhibited => { - f.debug_tuple("ErrorCode::DestinationIpProhibited").finish() - } - ErrorCode::DestinationIpUnroutable => { - f.debug_tuple("ErrorCode::DestinationIpUnroutable").finish() - } - ErrorCode::ConnectionRefused => { - f.debug_tuple("ErrorCode::ConnectionRefused").finish() - } - ErrorCode::ConnectionTerminated => { - f.debug_tuple("ErrorCode::ConnectionTerminated").finish() - } - ErrorCode::ConnectionTimeout => { - f.debug_tuple("ErrorCode::ConnectionTimeout").finish() - } - ErrorCode::ConnectionReadTimeout => { - f.debug_tuple("ErrorCode::ConnectionReadTimeout").finish() - } - ErrorCode::ConnectionWriteTimeout => { - f.debug_tuple("ErrorCode::ConnectionWriteTimeout").finish() - } - ErrorCode::ConnectionLimitReached => { - f.debug_tuple("ErrorCode::ConnectionLimitReached").finish() - } - ErrorCode::TlsProtocolError => { - f.debug_tuple("ErrorCode::TlsProtocolError").finish() - } - ErrorCode::TlsCertificateError => { - f.debug_tuple("ErrorCode::TlsCertificateError").finish() - } - ErrorCode::TlsAlertReceived(e) => { - f.debug_tuple("ErrorCode::TlsAlertReceived").field(e).finish() - } - ErrorCode::HttpRequestDenied => { - f.debug_tuple("ErrorCode::HttpRequestDenied").finish() - } - ErrorCode::HttpRequestLengthRequired => { - f.debug_tuple("ErrorCode::HttpRequestLengthRequired").finish() - } - ErrorCode::HttpRequestBodySize(e) => { - f.debug_tuple("ErrorCode::HttpRequestBodySize").field(e).finish() - } - ErrorCode::HttpRequestMethodInvalid => { - f.debug_tuple("ErrorCode::HttpRequestMethodInvalid").finish() - } - ErrorCode::HttpRequestUriInvalid => { - f.debug_tuple("ErrorCode::HttpRequestUriInvalid").finish() - } - ErrorCode::HttpRequestUriTooLong => { - f.debug_tuple("ErrorCode::HttpRequestUriTooLong").finish() - } - ErrorCode::HttpRequestHeaderSectionSize(e) => { - f.debug_tuple("ErrorCode::HttpRequestHeaderSectionSize").field(e).finish() - } - ErrorCode::HttpRequestHeaderSize(e) => { - f.debug_tuple("ErrorCode::HttpRequestHeaderSize").field(e).finish() - } - ErrorCode::HttpRequestTrailerSectionSize(e) => { - f.debug_tuple("ErrorCode::HttpRequestTrailerSectionSize").field(e).finish() - } - ErrorCode::HttpRequestTrailerSize(e) => { - f.debug_tuple("ErrorCode::HttpRequestTrailerSize").field(e).finish() - } - ErrorCode::HttpResponseIncomplete => { - f.debug_tuple("ErrorCode::HttpResponseIncomplete").finish() - } - ErrorCode::HttpResponseHeaderSectionSize(e) => { - f.debug_tuple("ErrorCode::HttpResponseHeaderSectionSize").field(e).finish() - } - ErrorCode::HttpResponseHeaderSize(e) => { - f.debug_tuple("ErrorCode::HttpResponseHeaderSize").field(e).finish() - } - ErrorCode::HttpResponseBodySize(e) => { - f.debug_tuple("ErrorCode::HttpResponseBodySize").field(e).finish() - } - ErrorCode::HttpResponseTrailerSectionSize(e) => { - f.debug_tuple("ErrorCode::HttpResponseTrailerSectionSize").field(e).finish() - } - ErrorCode::HttpResponseTrailerSize(e) => { - f.debug_tuple("ErrorCode::HttpResponseTrailerSize").field(e).finish() - } - ErrorCode::HttpResponseTransferCoding(e) => { - f.debug_tuple("ErrorCode::HttpResponseTransferCoding").field(e).finish() - } - ErrorCode::HttpResponseContentCoding(e) => { - f.debug_tuple("ErrorCode::HttpResponseContentCoding").field(e).finish() - } - ErrorCode::HttpResponseTimeout => { - f.debug_tuple("ErrorCode::HttpResponseTimeout").finish() - } - ErrorCode::HttpUpgradeFailed => { - f.debug_tuple("ErrorCode::HttpUpgradeFailed").finish() - } - ErrorCode::HttpProtocolError => { - f.debug_tuple("ErrorCode::HttpProtocolError").finish() - } - ErrorCode::LoopDetected => { - f.debug_tuple("ErrorCode::LoopDetected").finish() - } - ErrorCode::ConfigurationError => { - f.debug_tuple("ErrorCode::ConfigurationError").finish() - } - ErrorCode::InternalError(e) => { - f.debug_tuple("ErrorCode::InternalError").field(e).finish() - } - } - } - } - impl ::core::fmt::Display for ErrorCode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for ErrorCode {} - /// This type enumerates the different kinds of errors that may occur when - /// setting or appending to a `fields` resource. - #[derive(Clone, Copy)] - pub enum HeaderError { - /// This error indicates that a `field-key` or `field-value` was - /// syntactically invalid when used with an operation that sets headers in a - /// `fields`. - InvalidSyntax, - /// This error indicates that a forbidden `field-key` was used when trying - /// to set a header in a `fields`. - Forbidden, - /// This error indicates that the operation on the `fields` was not - /// permitted because the fields are immutable. - Immutable, - } - impl ::core::fmt::Debug for HeaderError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - HeaderError::InvalidSyntax => { - f.debug_tuple("HeaderError::InvalidSyntax").finish() - } - HeaderError::Forbidden => { - f.debug_tuple("HeaderError::Forbidden").finish() - } - HeaderError::Immutable => { - f.debug_tuple("HeaderError::Immutable").finish() - } - } - } - } - impl ::core::fmt::Display for HeaderError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for HeaderError {} - /// Field keys are always strings. - pub type FieldKey = _rt::String; - /// Field values should always be ASCII strings. However, in - /// reality, HTTP implementations often have to interpret malformed values, - /// so they are provided as a list of bytes. - pub type FieldValue = _rt::Vec::; - /// This following block defines the `fields` resource which corresponds to - /// HTTP standard Fields. Fields are a common representation used for both - /// Headers and Trailers. - /// - /// A `fields` may be mutable or immutable. A `fields` created using the - /// constructor, `from-list`, or `clone` will be mutable, but a `fields` - /// resource given by other means (including, but not limited to, - /// `incoming-request.headers`, `outgoing-request.headers`) might be be - /// immutable. In an immutable fields, the `set`, `append`, and `delete` - /// operations will fail with `header-error.immutable`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Fields{ - handle: _rt::Resource, - } - - impl Fields{ - #[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 Fields{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]fields"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Headers is an alias for Fields. - pub type Headers = Fields; - /// Trailers is an alias for Fields. - pub type Trailers = Fields; - /// Represents an incoming HTTP Request. - - #[derive(Debug)] - #[repr(transparent)] - pub struct IncomingRequest{ - handle: _rt::Resource, - } - - impl IncomingRequest{ - #[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 IncomingRequest{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]incoming-request"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents an outgoing HTTP Request. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutgoingRequest{ - handle: _rt::Resource, - } - - impl OutgoingRequest{ - #[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 OutgoingRequest{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]outgoing-request"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Parameters for making an HTTP Request. Each of these parameters is - /// currently an optional timeout applicable to the transport layer of the - /// HTTP protocol. - /// - /// These timeouts are separate from any the user may use to bound a - /// blocking call to `wasi:io/poll.poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct RequestOptions{ - handle: _rt::Resource, - } - - impl RequestOptions{ - #[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 RequestOptions{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]request-options"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents the ability to send an HTTP Response. - /// - /// This resource is used by the `wasi:http/incoming-handler` interface to - /// allow a Response to be sent corresponding to the Request provided as the - /// other argument to `incoming-handler.handle`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct ResponseOutparam{ - handle: _rt::Resource, - } - - impl ResponseOutparam{ - #[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 ResponseOutparam{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]response-outparam"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// This type corresponds to the HTTP standard Status Code. - pub type StatusCode = u16; - /// Represents an incoming HTTP Response. - - #[derive(Debug)] - #[repr(transparent)] - pub struct IncomingResponse{ - handle: _rt::Resource, - } - - impl IncomingResponse{ - #[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 IncomingResponse{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]incoming-response"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents an incoming HTTP Request or Response's Body. - /// - /// A body has both its contents - a stream of bytes - and a (possibly - /// empty) set of trailers, indicating that the full contents of the - /// body have been received. This resource represents the contents as - /// an `input-stream` and the delivery of trailers as a `future-trailers`, - /// and ensures that the user of this interface may only be consuming either - /// the body contents or waiting on trailers at any given time. - - #[derive(Debug)] - #[repr(transparent)] - pub struct IncomingBody{ - handle: _rt::Resource, - } - - impl IncomingBody{ - #[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 IncomingBody{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]incoming-body"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents a future which may eventaully return trailers, or an error. - /// - /// In the case that the incoming HTTP Request or Response did not have any - /// trailers, this future will resolve to the empty set of trailers once the - /// complete Request or Response body has been received. - - #[derive(Debug)] - #[repr(transparent)] - pub struct FutureTrailers{ - handle: _rt::Resource, - } - - impl FutureTrailers{ - #[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 FutureTrailers{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]future-trailers"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents an outgoing HTTP Response. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutgoingResponse{ - handle: _rt::Resource, - } - - impl OutgoingResponse{ - #[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 OutgoingResponse{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]outgoing-response"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents an outgoing HTTP Request or Response's Body. - /// - /// A body has both its contents - a stream of bytes - and a (possibly - /// empty) set of trailers, inducating the full contents of the body - /// have been sent. This resource represents the contents as an - /// `output-stream` child resource, and the completion of the body (with - /// optional trailers) with a static function that consumes the - /// `outgoing-body` resource, and ensures that the user of this interface - /// may not write to the body contents after the body has been finished. - /// - /// If the user code drops this resource, as opposed to calling the static - /// method `finish`, the implementation should treat the body as incomplete, - /// and that an error has occured. The implementation should propogate this - /// error to the HTTP protocol by whatever means it has available, - /// including: corrupting the body on the wire, aborting the associated - /// Request, or sending a late status code for the Response. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutgoingBody{ - handle: _rt::Resource, - } - - impl OutgoingBody{ - #[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 OutgoingBody{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]outgoing-body"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// Represents a future which may eventaully return an incoming HTTP - /// Response, or an error. - /// - /// This resource is returned by the `wasi:http/outgoing-handler` interface to - /// provide the HTTP Response corresponding to the sent Request. - - #[derive(Debug)] - #[repr(transparent)] - pub struct FutureIncomingResponse{ - handle: _rt::Resource, - } - - impl FutureIncomingResponse{ - #[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 FutureIncomingResponse{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]future-incoming-response"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - #[allow(unused_unsafe, clippy::all)] - /// Attempts to extract a http-related `error` from the wasi:io `error` - /// provided. - /// - /// Stream operations which return - /// `wasi:io/stream/stream-error::last-operation-failed` have a payload of - /// type `wasi:io/error/error` with more information about the operation - /// that failed. This payload can be passed through to this function to see - /// if there's http-related information about the error to return. - /// - /// Note that this function is fallible because not all io-errors are - /// http-related errors. - pub fn http_error_code(err: &IoError,) -> Option{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 40]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "http-error-code"] - fn wit_import(_: i32, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, ){ unreachable!() } - wit_import((err).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::()); - let v64 = match l2 { - 0 => { - ErrorCode::DnsTimeout - } - 1 => { - let e64 = { - let l3 = i32::from(*ptr0.add(16).cast::()); - let l7 = i32::from(*ptr0.add(28).cast::()); - - DnsErrorPayload{ - rcode: match l3 { - 0 => None, - 1 => { - let e = { - let l4 = *ptr0.add(20).cast::<*mut u8>(); - let l5 = *ptr0.add(24).cast::(); - let len6 = l5; - let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); - - _rt::string_lift(bytes6) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - info_code: match l7 { - 0 => None, - 1 => { - let e = { - let l8 = i32::from(*ptr0.add(30).cast::()); - - l8 as u16 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::DnsError(e64) - } - 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 e64 = { - let l9 = i32::from(*ptr0.add(16).cast::()); - let l11 = i32::from(*ptr0.add(20).cast::()); - - TlsAlertReceivedPayload{ - alert_id: match l9 { - 0 => None, - 1 => { - let e = { - let l10 = i32::from(*ptr0.add(17).cast::()); - - l10 as u8 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - alert_message: match l11 { - 0 => None, - 1 => { - let e = { - let l12 = *ptr0.add(24).cast::<*mut u8>(); - let l13 = *ptr0.add(28).cast::(); - let len14 = l13; - let bytes14 = _rt::Vec::from_raw_parts(l12.cast(), len14, len14); - - _rt::string_lift(bytes14) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::TlsAlertReceived(e64) - } - 15 => { - ErrorCode::HttpRequestDenied - } - 16 => { - ErrorCode::HttpRequestLengthRequired - } - 17 => { - let e64 = { - let l15 = i32::from(*ptr0.add(16).cast::()); - - match l15 { - 0 => None, - 1 => { - let e = { - let l16 = *ptr0.add(24).cast::(); - - l16 as u64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestBodySize(e64) - } - 18 => { - ErrorCode::HttpRequestMethodInvalid - } - 19 => { - ErrorCode::HttpRequestUriInvalid - } - 20 => { - ErrorCode::HttpRequestUriTooLong - } - 21 => { - let e64 = { - let l17 = i32::from(*ptr0.add(16).cast::()); - - match l17 { - 0 => None, - 1 => { - let e = { - let l18 = *ptr0.add(20).cast::(); - - l18 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSectionSize(e64) - } - 22 => { - let e64 = { - let l19 = i32::from(*ptr0.add(16).cast::()); - - match l19 { - 0 => None, - 1 => { - let e = { - let l20 = i32::from(*ptr0.add(20).cast::()); - let l24 = i32::from(*ptr0.add(32).cast::()); - - FieldSizePayload{ - field_name: match l20 { - 0 => None, - 1 => { - let e = { - let l21 = *ptr0.add(24).cast::<*mut u8>(); - let l22 = *ptr0.add(28).cast::(); - let len23 = l22; - let bytes23 = _rt::Vec::from_raw_parts(l21.cast(), len23, len23); - - _rt::string_lift(bytes23) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l24 { - 0 => None, - 1 => { - let e = { - let l25 = *ptr0.add(36).cast::(); - - l25 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSize(e64) - } - 23 => { - let e64 = { - let l26 = i32::from(*ptr0.add(16).cast::()); - - match l26 { - 0 => None, - 1 => { - let e = { - let l27 = *ptr0.add(20).cast::(); - - l27 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestTrailerSectionSize(e64) - } - 24 => { - let e64 = { - let l28 = i32::from(*ptr0.add(16).cast::()); - let l32 = i32::from(*ptr0.add(28).cast::()); - - FieldSizePayload{ - field_name: match l28 { - 0 => None, - 1 => { - let e = { - let l29 = *ptr0.add(20).cast::<*mut u8>(); - let l30 = *ptr0.add(24).cast::(); - let len31 = l30; - let bytes31 = _rt::Vec::from_raw_parts(l29.cast(), len31, len31); - - _rt::string_lift(bytes31) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l32 { - 0 => None, - 1 => { - let e = { - let l33 = *ptr0.add(32).cast::(); - - l33 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpRequestTrailerSize(e64) - } - 25 => { - ErrorCode::HttpResponseIncomplete - } - 26 => { - let e64 = { - let l34 = i32::from(*ptr0.add(16).cast::()); - - match l34 { - 0 => None, - 1 => { - let e = { - let l35 = *ptr0.add(20).cast::(); - - l35 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseHeaderSectionSize(e64) - } - 27 => { - let e64 = { - let l36 = i32::from(*ptr0.add(16).cast::()); - let l40 = i32::from(*ptr0.add(28).cast::()); - - FieldSizePayload{ - field_name: match l36 { - 0 => None, - 1 => { - let e = { - let l37 = *ptr0.add(20).cast::<*mut u8>(); - let l38 = *ptr0.add(24).cast::(); - let len39 = l38; - let bytes39 = _rt::Vec::from_raw_parts(l37.cast(), len39, len39); - - _rt::string_lift(bytes39) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l40 { - 0 => None, - 1 => { - let e = { - let l41 = *ptr0.add(32).cast::(); - - l41 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseHeaderSize(e64) - } - 28 => { - let e64 = { - let l42 = i32::from(*ptr0.add(16).cast::()); - - match l42 { - 0 => None, - 1 => { - let e = { - let l43 = *ptr0.add(24).cast::(); - - l43 as u64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseBodySize(e64) - } - 29 => { - let e64 = { - let l44 = i32::from(*ptr0.add(16).cast::()); - - match l44 { - 0 => None, - 1 => { - let e = { - let l45 = *ptr0.add(20).cast::(); - - l45 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTrailerSectionSize(e64) - } - 30 => { - let e64 = { - let l46 = i32::from(*ptr0.add(16).cast::()); - let l50 = i32::from(*ptr0.add(28).cast::()); - - FieldSizePayload{ - field_name: match l46 { - 0 => None, - 1 => { - let e = { - let l47 = *ptr0.add(20).cast::<*mut u8>(); - let l48 = *ptr0.add(24).cast::(); - let len49 = l48; - let bytes49 = _rt::Vec::from_raw_parts(l47.cast(), len49, len49); - - _rt::string_lift(bytes49) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l50 { - 0 => None, - 1 => { - let e = { - let l51 = *ptr0.add(32).cast::(); - - l51 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseTrailerSize(e64) - } - 31 => { - let e64 = { - let l52 = i32::from(*ptr0.add(16).cast::()); - - match l52 { - 0 => None, - 1 => { - let e = { - let l53 = *ptr0.add(20).cast::<*mut u8>(); - let l54 = *ptr0.add(24).cast::(); - let len55 = l54; - let bytes55 = _rt::Vec::from_raw_parts(l53.cast(), len55, len55); - - _rt::string_lift(bytes55) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTransferCoding(e64) - } - 32 => { - let e64 = { - let l56 = i32::from(*ptr0.add(16).cast::()); - - match l56 { - 0 => None, - 1 => { - let e = { - let l57 = *ptr0.add(20).cast::<*mut u8>(); - let l58 = *ptr0.add(24).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::HttpResponseContentCoding(e64) - } - 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 e64 = { - let l60 = i32::from(*ptr0.add(16).cast::()); - - match l60 { - 0 => None, - 1 => { - let e = { - let l61 = *ptr0.add(20).cast::<*mut u8>(); - let l62 = *ptr0.add(24).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::InternalError(e64) - } - }; - - v64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Construct an empty HTTP Fields. - /// - /// The resulting `fields` is mutable. - pub fn new() -> Self{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[constructor]fields"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - Fields::from_handle(ret as u32) - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Construct an HTTP Fields. - /// - /// The resulting `fields` is mutable. - /// - /// The list represents each key-value pair in the Fields. Keys - /// which have multiple values are represented by multiple entries in this - /// list with the same key. - /// - /// The tuple is a pair of the field key, represented as a string, and - /// Value, represented as a list of bytes. In a valid Fields, all keys - /// and values are valid UTF-8 strings. However, values are not always - /// well-formed, so they are represented as a raw list of bytes. - /// - /// An error result will be returned if any header or value was - /// syntactically invalid, or if a header was forbidden. - pub fn from_list(entries: &[(FieldKey,FieldValue,)],) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let vec3 = entries; - let len3 = vec3.len(); - let layout3 = _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 16, 4); - let result3 = if layout3.size() != 0 { - let ptr = _rt::alloc::alloc(layout3).cast::(); - if ptr.is_null() - { - _rt::alloc::handle_alloc_error(layout3); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec3.into_iter().enumerate() { - let base = result3.add(i * 16); - { - let (t0_0, t0_1, ) = e; - let vec1 = t0_0; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - *base.add(4).cast::() = len1; - *base.add(0).cast::<*mut u8>() = ptr1.cast_mut(); - let vec2 = t0_1; - let ptr2 = vec2.as_ptr().cast::(); - let len2 = vec2.len(); - *base.add(12).cast::() = len2; - *base.add(8).cast::<*mut u8>() = ptr2.cast_mut(); - } - } - let ptr4 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[static]fields.from-list"] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import(result3, len3, ptr4); - let l5 = i32::from(*ptr4.add(0).cast::()); - if layout3.size() != 0 { - _rt::alloc::dealloc(result3.cast(), layout3); - } - match l5 { - 0 => { - let e = { - let l6 = *ptr4.add(4).cast::(); - - Fields::from_handle(l6 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l7 = i32::from(*ptr4.add(4).cast::()); - let v8 = match l7 { - 0 => { - HeaderError::InvalidSyntax - } - 1 => { - HeaderError::Forbidden - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - HeaderError::Immutable - } - }; - - v8 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Get all of the values corresponding to a key. If the key is not present - /// in this `fields`, an empty list is returned. However, if the key is - /// present but empty, this is represented by a list with one or more - /// empty field-values present. - pub fn get(&self,name: &FieldKey,) -> _rt::Vec::{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let vec0 = name; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.get"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = *ptr1.add(0).cast::<*mut u8>(); - let l3 = *ptr1.add(4).cast::(); - let base7 = l2; - let len7 = l3; - let mut result7 = _rt::Vec::with_capacity(len7); - for i in 0..len7 { - let base = base7.add(i * 8); - let e7 = { - let l4 = *base.add(0).cast::<*mut u8>(); - let l5 = *base.add(4).cast::(); - let len6 = l5; - - _rt::Vec::from_raw_parts(l4.cast(), len6, len6) - }; - result7.push(e7); - } - _rt::cabi_dealloc(base7, len7 * 8, 4); - result7 - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Returns `true` when the key is present in this `fields`. If the key is - /// syntactically invalid, `false` is returned. - pub fn has(&self,name: &FieldKey,) -> bool{ - unsafe { - let vec0 = name; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.has"] - fn wit_import(_: i32, _: *mut u8, _: usize, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, ptr0.cast_mut(), len0); - _rt::bool_lift(ret as u8) - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Set all of the values for a key. Clears any existing values for that - /// key, if they have been set. - /// - /// Fails with `header-error.immutable` if the `fields` are immutable. - pub fn set(&self,name: &FieldKey,value: &[FieldValue],) -> Result<(),HeaderError>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = name; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let vec2 = value; - let len2 = vec2.len(); - let layout2 = _rt::alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); - let result2 = if layout2.size() != 0 { - let ptr = _rt::alloc::alloc(layout2).cast::(); - if ptr.is_null() - { - _rt::alloc::handle_alloc_error(layout2); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec2.into_iter().enumerate() { - let base = result2.add(i * 8); - { - let vec1 = e; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - *base.add(4).cast::() = len1; - *base.add(0).cast::<*mut u8>() = ptr1.cast_mut(); - } - } - let ptr3 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.set"] - 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, result2, len2, ptr3); - let l4 = i32::from(*ptr3.add(0).cast::()); - if layout2.size() != 0 { - _rt::alloc::dealloc(result2.cast(), layout2); - } - match l4 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*ptr3.add(1).cast::()); - let v6 = match l5 { - 0 => { - HeaderError::InvalidSyntax - } - 1 => { - HeaderError::Forbidden - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - HeaderError::Immutable - } - }; - - v6 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Delete all values for a key. Does nothing if no values for the key - /// exist. - /// - /// Fails with `header-error.immutable` if the `fields` are immutable. - pub fn delete(&self,name: &FieldKey,) -> Result<(),HeaderError>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = name; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.delete"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr1.add(1).cast::()); - let v4 = match l3 { - 0 => { - HeaderError::InvalidSyntax - } - 1 => { - HeaderError::Forbidden - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - HeaderError::Immutable - } - }; - - v4 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Append a value for a key. Does not change or delete any existing - /// values for that key. - /// - /// Fails with `header-error.immutable` if the `fields` are immutable. - pub fn append(&self,name: &FieldKey,value: &FieldValue,) -> Result<(),HeaderError>{ - unsafe { - #[repr(align(1))] - struct RetArea([::core::mem::MaybeUninit::; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); - let vec0 = name; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let vec1 = value; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - let ptr2 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.append"] - 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, ptr1.cast_mut(), len1, ptr2); - let l3 = i32::from(*ptr2.add(0).cast::()); - match l3 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*ptr2.add(1).cast::()); - let v5 = match l4 { - 0 => { - HeaderError::InvalidSyntax - } - 1 => { - HeaderError::Forbidden - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - HeaderError::Immutable - } - }; - - v5 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Retrieve the full set of keys and values in the Fields. Like the - /// constructor, the list represents each key-value pair. - /// - /// The outer list represents each key-value pair in the Fields. Keys - /// which have multiple values are represented by multiple entries in this - /// list with the same key. - pub fn entries(&self,) -> _rt::Vec::<(FieldKey,FieldValue,)>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.entries"] - 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 = *ptr0.add(0).cast::<*mut u8>(); - let l2 = *ptr0.add(4).cast::(); - let base9 = l1; - let len9 = l2; - let mut result9 = _rt::Vec::with_capacity(len9); - for i in 0..len9 { - let base = base9.add(i * 16); - let e9 = { - let l3 = *base.add(0).cast::<*mut u8>(); - let l4 = *base.add(4).cast::(); - let len5 = l4; - let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); - let l6 = *base.add(8).cast::<*mut u8>(); - let l7 = *base.add(12).cast::(); - let len8 = l7; - - (_rt::string_lift(bytes5), _rt::Vec::from_raw_parts(l6.cast(), len8, len8)) - }; - result9.push(e9); - } - _rt::cabi_dealloc(base9, len9 * 16, 4); - result9 - } - } - } - impl Fields { - #[allow(unused_unsafe, clippy::all)] - /// Make a deep copy of the Fields. Equivelant in behavior to calling the - /// `fields` constructor on the return value of `entries`. The resulting - /// `fields` is mutable. - pub fn clone(&self,) -> Fields{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]fields.clone"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the method of the incoming request. - pub fn method(&self,) -> Method{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.method"] - 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::()); - let v5 = match l1 { - 0 => { - Method::Get - } - 1 => { - Method::Head - } - 2 => { - Method::Post - } - 3 => { - Method::Put - } - 4 => { - Method::Delete - } - 5 => { - Method::Connect - } - 6 => { - Method::Options - } - 7 => { - Method::Trace - } - 8 => { - Method::Patch - } - n => { - debug_assert_eq!(n, 9, "invalid enum discriminant"); - let e5 = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - - _rt::string_lift(bytes4) - }; - Method::Other(e5) - } - }; - v5 - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the path with query parameters from the request, as a string. - pub fn path_with_query(&self,) -> Option<_rt::String>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.path-with-query"] - 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 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - - _rt::string_lift(bytes4) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the protocol scheme from the request. - pub fn scheme(&self,) -> Option{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.scheme"] - 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::()); - let v6 = match l2 { - 0 => { - Scheme::Http - } - 1 => { - Scheme::Https - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - let e6 = { - let l3 = *ptr0.add(8).cast::<*mut u8>(); - let l4 = *ptr0.add(12).cast::(); - let len5 = l4; - let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); - - _rt::string_lift(bytes5) - }; - Scheme::Other(e6) - } - }; - - v6 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the authority from the request, if it was present. - pub fn authority(&self,) -> Option<_rt::String>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.authority"] - 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 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - - _rt::string_lift(bytes4) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the `headers` associated with the request. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// The `headers` returned are a child resource: it must be dropped before - /// the parent `incoming-request` is dropped. Dropping this - /// `incoming-request` before all children are dropped will trap. - pub fn headers(&self,) -> Headers{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.headers"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl IncomingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Gives the `incoming-body` associated with this request. Will only - /// return success at most once, and subsequent calls will return error. - pub fn consume(&self,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-request.consume"] - 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 => { - let e = { - let l2 = *ptr0.add(4).cast::(); - - IncomingBody::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Construct a new `outgoing-request` with a default `method` of `GET`, and - /// `none` values for `path-with-query`, `scheme`, and `authority`. - /// - /// * `headers` is the HTTP Headers for the Request. - /// - /// It is possible to construct, or manipulate with the accessor functions - /// below, an `outgoing-request` with an invalid combination of `scheme` - /// and `authority`, or `headers` which are not permitted to be sent. - /// It is the obligation of the `outgoing-handler.handle` implementation - /// to reject invalid constructions of `outgoing-request`. - pub fn new(headers: Headers,) -> Self{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[constructor]outgoing-request"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((&headers).take_handle() as i32); - OutgoingRequest::from_handle(ret as u32) - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Returns the resource corresponding to the outgoing Body for this - /// Request. - /// - /// Returns success on the first call: the `outgoing-body` resource for - /// this `outgoing-request` can be retrieved at most once. Subsequent - /// calls will return error. - pub fn body(&self,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.body"] - 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 => { - let e = { - let l2 = *ptr0.add(4).cast::(); - - OutgoingBody::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the Method for the Request. - pub fn method(&self,) -> Method{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.method"] - 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::()); - let v5 = match l1 { - 0 => { - Method::Get - } - 1 => { - Method::Head - } - 2 => { - Method::Post - } - 3 => { - Method::Put - } - 4 => { - Method::Delete - } - 5 => { - Method::Connect - } - 6 => { - Method::Options - } - 7 => { - Method::Trace - } - 8 => { - Method::Patch - } - n => { - debug_assert_eq!(n, 9, "invalid enum discriminant"); - let e5 = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - - _rt::string_lift(bytes4) - }; - Method::Other(e5) - } - }; - v5 - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Set the Method for the Request. Fails if the string present in a - /// `method.other` argument is not a syntactically valid method. - pub fn set_method(&self,method: &Method,) -> Result<(),()>{ - unsafe { - let (result1_0,result1_1,result1_2,) = match method { - Method::Get=> { - (0i32, ::core::ptr::null_mut(), 0usize) - } - Method::Head=> { - (1i32, ::core::ptr::null_mut(), 0usize) - } - Method::Post=> { - (2i32, ::core::ptr::null_mut(), 0usize) - } - Method::Put=> { - (3i32, ::core::ptr::null_mut(), 0usize) - } - Method::Delete=> { - (4i32, ::core::ptr::null_mut(), 0usize) - } - Method::Connect=> { - (5i32, ::core::ptr::null_mut(), 0usize) - } - Method::Options=> { - (6i32, ::core::ptr::null_mut(), 0usize) - } - Method::Trace=> { - (7i32, ::core::ptr::null_mut(), 0usize) - } - Method::Patch=> { - (8i32, ::core::ptr::null_mut(), 0usize) - } - Method::Other(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - - (9i32, ptr0.cast_mut(), len0) - }, - }; - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.set-method"] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result1_0, result1_1, result1_2); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the combination of the HTTP Path and Query for the Request. - /// When `none`, this represents an empty Path and empty Query. - pub fn path_with_query(&self,) -> Option<_rt::String>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.path-with-query"] - 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 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - - _rt::string_lift(bytes4) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Set the combination of the HTTP Path and Query for the Request. - /// When `none`, this represents an empty Path and empty Query. Fails is the - /// string given is not a syntactically valid path and query uri component. - pub fn set_path_with_query(&self,path_with_query: Option<&str>,) -> Result<(),()>{ - unsafe { - let (result1_0,result1_1,result1_2,) = match path_with_query { - Some(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - - (1i32, ptr0.cast_mut(), len0) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.set-path-with-query"] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result1_0, result1_1, result1_2); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the HTTP Related Scheme for the Request. When `none`, the - /// implementation may choose an appropriate default scheme. - pub fn scheme(&self,) -> Option{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.scheme"] - 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::()); - let v6 = match l2 { - 0 => { - Scheme::Http - } - 1 => { - Scheme::Https - } - n => { - debug_assert_eq!(n, 2, "invalid enum discriminant"); - let e6 = { - let l3 = *ptr0.add(8).cast::<*mut u8>(); - let l4 = *ptr0.add(12).cast::(); - let len5 = l4; - let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); - - _rt::string_lift(bytes5) - }; - Scheme::Other(e6) - } - }; - - v6 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Set the HTTP Related Scheme for the Request. When `none`, the - /// implementation may choose an appropriate default scheme. Fails if the - /// string given is not a syntactically valid uri scheme. - pub fn set_scheme(&self,scheme: Option<&Scheme>,) -> Result<(),()>{ - unsafe { - let (result2_0,result2_1,result2_2,result2_3,) = match scheme { - Some(e) => { - let (result1_0,result1_1,result1_2,) = match e { - Scheme::Http=> { - (0i32, ::core::ptr::null_mut(), 0usize) - } - Scheme::Https=> { - (1i32, ::core::ptr::null_mut(), 0usize) - } - Scheme::Other(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - - (2i32, ptr0.cast_mut(), len0) - }, - }; - - (1i32, result1_0, result1_1, result1_2) - }, - None => { - (0i32, 0i32, ::core::ptr::null_mut(), 0usize) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.set-scheme"] - fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, _: usize, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result2_0, result2_1, result2_2, result2_3); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the HTTP Authority for the Request. A value of `none` may be used - /// with Related Schemes which do not require an Authority. The HTTP and - /// HTTPS schemes always require an authority. - pub fn authority(&self,) -> Option<_rt::String>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.authority"] - 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 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - - _rt::string_lift(bytes4) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Set the HTTP Authority for the Request. A value of `none` may be used - /// with Related Schemes which do not require an Authority. The HTTP and - /// HTTPS schemes always require an authority. Fails if the string given is - /// not a syntactically valid uri authority. - pub fn set_authority(&self,authority: Option<&str>,) -> Result<(),()>{ - unsafe { - let (result1_0,result1_1,result1_2,) = match authority { - Some(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - - (1i32, ptr0.cast_mut(), len0) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.set-authority"] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: *mut u8, _: usize, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result1_0, result1_1, result1_2); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingRequest { - #[allow(unused_unsafe, clippy::all)] - /// Get the headers associated with the Request. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// This headers resource is a child: it must be dropped before the parent - /// `outgoing-request` is dropped, or its ownership is transfered to - /// another component by e.g. `outgoing-handler.handle`. - pub fn headers(&self,) -> Headers{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-request.headers"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// Construct a default `request-options` value. - pub fn new() -> Self{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[constructor]request-options"] - fn wit_import() -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i32{ unreachable!() } - let ret = wit_import(); - RequestOptions::from_handle(ret as u32) - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// The timeout for the initial connect to the HTTP Server. - pub fn connect_timeout(&self,) -> Option{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.connect-timeout"] - 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 = *ptr0.add(8).cast::(); - - l2 as u64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// Set the timeout for the initial connect to the HTTP Server. An error - /// return value indicates that this timeout is not supported. - pub fn set_connect_timeout(&self,duration: Option,) -> Result<(),()>{ - unsafe { - let (result0_0,result0_1,) = match duration { - Some(e) => (1i32, _rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.set-connect-timeout"] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result0_0, result0_1); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// The timeout for receiving the first byte of the Response body. - pub fn first_byte_timeout(&self,) -> Option{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.first-byte-timeout"] - 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 = *ptr0.add(8).cast::(); - - l2 as u64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// Set the timeout for receiving the first byte of the Response body. An - /// error return value indicates that this timeout is not supported. - pub fn set_first_byte_timeout(&self,duration: Option,) -> Result<(),()>{ - unsafe { - let (result0_0,result0_1,) = match duration { - Some(e) => (1i32, _rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.set-first-byte-timeout"] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result0_0, result0_1); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// The timeout for receiving subsequent chunks of bytes in the Response - /// body stream. - pub fn between_bytes_timeout(&self,) -> Option{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.between-bytes-timeout"] - 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 = *ptr0.add(8).cast::(); - - l2 as u64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl RequestOptions { - #[allow(unused_unsafe, clippy::all)] - /// Set the timeout for receiving subsequent chunks of bytes in the Response - /// body stream. An error return value indicates that this timeout is not - /// supported. - pub fn set_between_bytes_timeout(&self,duration: Option,) -> Result<(),()>{ - unsafe { - let (result0_0,result0_1,) = match duration { - Some(e) => (1i32, _rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]request-options.set-between-bytes-timeout"] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, result0_0, result0_1); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl ResponseOutparam { - #[allow(unused_unsafe, clippy::all)] - /// Set the value of the `response-outparam` to either send a response, - /// or indicate an error. - /// - /// This method consumes the `response-outparam` to ensure that it is - /// called at most once. If it is never called, the implementation - /// will respond with an error. - /// - /// The user may provide an `error` to `response` to allow the - /// implementation determine how to respond with an HTTP error response. - pub fn set(param: ResponseOutparam,response: Result,){ - unsafe { - let (result38_0,result38_1,result38_2,result38_3,result38_4,result38_5,result38_6,result38_7,) = match &response { - Ok(e) => { (0i32, (e).take_handle() as i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) }, - Err(e) => { { - let (result37_0,result37_1,result37_2,result37_3,result37_4,result37_5,result37_6,) = match e { - ErrorCode::DnsTimeout=> { - (0i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::DnsError(e) => { - let DnsErrorPayload{ rcode:rcode0, info_code:info_code0, } = e; - let (result2_0,result2_1,result2_2,) = match rcode0 { - Some(e) => { - let vec1 = e; - let ptr1 = vec1.as_ptr().cast::(); - let len1 = vec1.len(); - - (1i32, ptr1.cast_mut(), len1) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let (result3_0,result3_1,) = match info_code0 { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (1i32, result2_0, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(result2_1); - t - }, result2_2 as *mut u8, result3_0 as *mut u8, result3_1 as usize, 0i32) - }, - ErrorCode::DestinationNotFound=> { - (2i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::DestinationUnavailable=> { - (3i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::DestinationIpProhibited=> { - (4i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::DestinationIpUnroutable=> { - (5i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::ConnectionRefused=> { - (6i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::ConnectionTerminated=> { - (7i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::ConnectionTimeout=> { - (8i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::ConnectionReadTimeout=> { - (9i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::ConnectionWriteTimeout=> { - (10i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::ConnectionLimitReached=> { - (11i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::TlsProtocolError=> { - (12i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::TlsCertificateError=> { - (13i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::TlsAlertReceived(e) => { - let TlsAlertReceivedPayload{ alert_id:alert_id4, alert_message:alert_message4, } = e; - let (result5_0,result5_1,) = match alert_id4 { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - };let (result7_0,result7_1,result7_2,) = match alert_message4 { - Some(e) => { - let vec6 = e; - let ptr6 = vec6.as_ptr().cast::(); - let len6 = vec6.len(); - - (1i32, ptr6.cast_mut(), len6) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - }; - (14i32, result5_0, ::core::mem::MaybeUninit::new(i64::from(result5_1) as u64), result7_0 as *mut u8, result7_1, result7_2, 0i32) - }, - ErrorCode::HttpRequestDenied=> { - (15i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::HttpRequestLengthRequired=> { - (16i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::HttpRequestBodySize(e) => { - let (result8_0,result8_1,) = match e { - Some(e) => (1i32, _rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - (17i32, result8_0, ::core::mem::MaybeUninit::new(result8_1 as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - }, - ErrorCode::HttpRequestMethodInvalid=> { - (18i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::HttpRequestUriInvalid=> { - (19i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::HttpRequestUriTooLong=> { - (20i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::HttpRequestHeaderSectionSize(e) => { - let (result9_0,result9_1,) = match e { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (21i32, result9_0, ::core::mem::MaybeUninit::new(i64::from(result9_1) as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - }, - ErrorCode::HttpRequestHeaderSize(e) => { - let (result14_0,result14_1,result14_2,result14_3,result14_4,result14_5,) = match e { - Some(e) => { - let FieldSizePayload{ field_name:field_name10, field_size:field_size10, } = e; - let (result12_0,result12_1,result12_2,) = match field_name10 { - Some(e) => { - let vec11 = e; - let ptr11 = vec11.as_ptr().cast::(); - let len11 = vec11.len(); - - (1i32, ptr11.cast_mut(), len11) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let (result13_0,result13_1,) = match field_size10 { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (1i32, result12_0, result12_1, result12_2, result13_0, result13_1) - }, - None => { - (0i32, 0i32, ::core::ptr::null_mut(), 0usize, 0i32, 0i32) - }, - }; - (22i32, result14_0, ::core::mem::MaybeUninit::new(i64::from(result14_1) as u64), result14_2, result14_3 as *mut u8, result14_4 as usize, result14_5) - }, - ErrorCode::HttpRequestTrailerSectionSize(e) => { - let (result15_0,result15_1,) = match e { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (23i32, result15_0, ::core::mem::MaybeUninit::new(i64::from(result15_1) as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - }, - ErrorCode::HttpRequestTrailerSize(e) => { - let FieldSizePayload{ field_name:field_name16, field_size:field_size16, } = e; - let (result18_0,result18_1,result18_2,) = match field_name16 { - Some(e) => { - let vec17 = e; - let ptr17 = vec17.as_ptr().cast::(); - let len17 = vec17.len(); - - (1i32, ptr17.cast_mut(), len17) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let (result19_0,result19_1,) = match field_size16 { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (24i32, result18_0, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(result18_1); - t - }, result18_2 as *mut u8, result19_0 as *mut u8, result19_1 as usize, 0i32) - }, - ErrorCode::HttpResponseIncomplete=> { - (25i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::HttpResponseHeaderSectionSize(e) => { - let (result20_0,result20_1,) = match e { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (26i32, result20_0, ::core::mem::MaybeUninit::new(i64::from(result20_1) as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - }, - ErrorCode::HttpResponseHeaderSize(e) => { - let FieldSizePayload{ field_name:field_name21, field_size:field_size21, } = e; - let (result23_0,result23_1,result23_2,) = match field_name21 { - Some(e) => { - let vec22 = e; - let ptr22 = vec22.as_ptr().cast::(); - let len22 = vec22.len(); - - (1i32, ptr22.cast_mut(), len22) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let (result24_0,result24_1,) = match field_size21 { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (27i32, result23_0, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(result23_1); - t - }, result23_2 as *mut u8, result24_0 as *mut u8, result24_1 as usize, 0i32) - }, - ErrorCode::HttpResponseBodySize(e) => { - let (result25_0,result25_1,) = match e { - Some(e) => (1i32, _rt::as_i64(e)), - None => { - (0i32, 0i64) - }, - }; - (28i32, result25_0, ::core::mem::MaybeUninit::new(result25_1 as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - }, - ErrorCode::HttpResponseTrailerSectionSize(e) => { - let (result26_0,result26_1,) = match e { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (29i32, result26_0, ::core::mem::MaybeUninit::new(i64::from(result26_1) as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - }, - ErrorCode::HttpResponseTrailerSize(e) => { - let FieldSizePayload{ field_name:field_name27, field_size:field_size27, } = e; - let (result29_0,result29_1,result29_2,) = match field_name27 { - Some(e) => { - let vec28 = e; - let ptr28 = vec28.as_ptr().cast::(); - let len28 = vec28.len(); - - (1i32, ptr28.cast_mut(), len28) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - };let (result30_0,result30_1,) = match field_size27 { - Some(e) => (1i32, _rt::as_i32(e)), - None => { - (0i32, 0i32) - }, - }; - (30i32, result29_0, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(result29_1); - t - }, result29_2 as *mut u8, result30_0 as *mut u8, result30_1 as usize, 0i32) - }, - ErrorCode::HttpResponseTransferCoding(e) => { - let (result32_0,result32_1,result32_2,) = match e { - Some(e) => { - let vec31 = e; - let ptr31 = vec31.as_ptr().cast::(); - let len31 = vec31.len(); - - (1i32, ptr31.cast_mut(), len31) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - }; - (31i32, result32_0, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(result32_1); - t - }, result32_2 as *mut u8, ::core::ptr::null_mut(), 0usize, 0i32) - }, - ErrorCode::HttpResponseContentCoding(e) => { - let (result34_0,result34_1,result34_2,) = match e { - Some(e) => { - let vec33 = e; - let ptr33 = vec33.as_ptr().cast::(); - let len33 = vec33.len(); - - (1i32, ptr33.cast_mut(), len33) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - }; - (32i32, result34_0, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(result34_1); - t - }, result34_2 as *mut u8, ::core::ptr::null_mut(), 0usize, 0i32) - }, - ErrorCode::HttpResponseTimeout=> { - (33i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::HttpUpgradeFailed=> { - (34i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::HttpProtocolError=> { - (35i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::LoopDetected=> { - (36i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::ConfigurationError=> { - (37i32, 0i32, ::core::mem::MaybeUninit::::zeroed(), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, 0i32) - } - ErrorCode::InternalError(e) => { - let (result36_0,result36_1,result36_2,) = match e { - Some(e) => { - let vec35 = e; - let ptr35 = vec35.as_ptr().cast::(); - let len35 = vec35.len(); - - (1i32, ptr35.cast_mut(), len35) - }, - None => { - (0i32, ::core::ptr::null_mut(), 0usize) - }, - }; - (38i32, result36_0, { - let mut t = ::core::mem::MaybeUninit::::uninit(); - t.as_mut_ptr().cast::<*mut u8>().write(result36_1); - t - }, result36_2 as *mut u8, ::core::ptr::null_mut(), 0usize, 0i32) - }, - }; - - (1i32, result37_0, result37_1, result37_2, result37_3, result37_4, result37_5, result37_6) - } }, - }; - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[static]response-outparam.set"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: *mut u8, _: *mut u8, _: usize, _: i32, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: ::core::mem::MaybeUninit::, _: *mut u8, _: *mut u8, _: usize, _: i32, ){ unreachable!() } - wit_import((¶m).take_handle() as i32, result38_0, result38_1, result38_2, result38_3, result38_4, result38_5, result38_6, result38_7); - } - } - } - impl IncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the status code from the incoming response. - pub fn status(&self,) -> StatusCode{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-response.status"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - ret as u16 - } - } - } - impl IncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the headers from the incoming response. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// This headers resource is a child: it must be dropped before the parent - /// `incoming-response` is dropped. - pub fn headers(&self,) -> Headers{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-response.headers"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl IncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the incoming body. May be called at most once. Returns error - /// if called additional times. - pub fn consume(&self,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-response.consume"] - 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 => { - let e = { - let l2 = *ptr0.add(4).cast::(); - - IncomingBody::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingBody { - #[allow(unused_unsafe, clippy::all)] - /// Returns the contents of the body, as a stream of bytes. - /// - /// Returns success on first call: the stream representing the contents - /// can be retrieved at most once. Subsequent calls will return error. - /// - /// The returned `input-stream` resource is a child: it must be dropped - /// before the parent `incoming-body` is dropped, or consumed by - /// `incoming-body.finish`. - /// - /// This invariant ensures that the implementation can determine whether - /// the user is consuming the contents of the body, waiting on the - /// `future-trailers` to be ready, or neither. This allows for network - /// backpressure is to be applied when the user is consuming the body, - /// and for that backpressure to not inhibit delivery of the trailers if - /// the user does not read the entire body. - pub fn stream(&self,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]incoming-body.stream"] - 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 => { - let e = { - let l2 = *ptr0.add(4).cast::(); - - super::super::super::wasi::io::streams::InputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl IncomingBody { - #[allow(unused_unsafe, clippy::all)] - /// Takes ownership of `incoming-body`, and returns a `future-trailers`. - /// This function will trap if the `input-stream` child is still alive. - pub fn finish(this: IncomingBody,) -> FutureTrailers{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[static]incoming-body.finish"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((&this).take_handle() as i32); - FutureTrailers::from_handle(ret as u32) - } - } - } - impl FutureTrailers { - #[allow(unused_unsafe, clippy::all)] - /// Returns a pollable which becomes ready when either the trailers have - /// been received, or an error has occured. When this pollable is ready, - /// the `get` method will return `some`. - /// subscribe: func() -> pollable; // Hermes does NOT support `poll` - /// Returns the contents of the trailers, or an error which occured, - /// once the future is ready. - /// - /// The outer `option` represents future readiness. Users can wait on this - /// `option` to become `some` using the `subscribe` method. - /// - /// The outer `result` is used to retrieve the trailers or error at most - /// once. It will be success on the first call in which the outer option - /// is `some`, and error on subsequent calls. - /// - /// The inner `result` represents that either the HTTP Request or Response - /// body, as well as any trailers, were received successfully, or that an - /// error occured receiving them. The optional `trailers` indicates whether - /// or not trailers were present in the body. - /// - /// When some `trailers` are returned by this method, the `trailers` - /// resource is immutable, and a child. Use of the `set`, `append`, or - /// `delete` methods will return an error, and the resource must be - /// dropped before the parent `future-trailers` is dropped. - pub fn get(&self,) -> Option,ErrorCode>,()>>{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 56]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 56]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]future-trailers.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 = 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::()); - - 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 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Construct an `outgoing-response`, with a default `status-code` of `200`. - /// If a different `status-code` is needed, it must be set via the - /// `set-status-code` method. - /// - /// * `headers` is the HTTP Headers for the Response. - pub fn new(headers: Headers,) -> Self{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[constructor]outgoing-response"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((&headers).take_handle() as i32); - OutgoingResponse::from_handle(ret as u32) - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Get the HTTP Status Code for the Response. - pub fn status_code(&self,) -> StatusCode{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-response.status-code"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - ret as u16 - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Set the HTTP Status Code for the Response. Fails if the status-code - /// given is not a valid http status code. - pub fn set_status_code(&self,status_code: StatusCode,) -> Result<(),()>{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-response.set-status-code"] - fn wit_import(_: i32, _: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32, _rt::as_i32(status_code)); - match ret { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Get the headers associated with the Request. - /// - /// The returned `headers` resource is immutable: `set`, `append`, and - /// `delete` operations will fail with `header-error.immutable`. - /// - /// This headers resource is a child: it must be dropped before the parent - /// `outgoing-request` is dropped, or its ownership is transfered to - /// another component by e.g. `outgoing-handler.handle`. - pub fn headers(&self,) -> Headers{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-response.headers"] - fn wit_import(_: i32, ) -> i32; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, ) -> i32{ unreachable!() } - let ret = wit_import((self).handle() as i32); - Fields::from_handle(ret as u32) - } - } - } - impl OutgoingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns the resource corresponding to the outgoing Body for this Response. - /// - /// Returns success on the first call: the `outgoing-body` resource for - /// this `outgoing-response` can be retrieved at most once. Subsequent - /// calls will return error. - pub fn body(&self,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-response.body"] - 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 => { - let e = { - let l2 = *ptr0.add(4).cast::(); - - OutgoingBody::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingBody { - #[allow(unused_unsafe, clippy::all)] - /// Returns a stream for writing the body contents. - /// - /// The returned `output-stream` is a child resource: it must be dropped - /// before the parent `outgoing-body` resource is dropped (or finished), - /// otherwise the `outgoing-body` drop or `finish` will trap. - /// - /// Returns success on the first call: the `output-stream` resource for - /// this `outgoing-body` may be retrieved at most once. Subsequent calls - /// will return error. - pub fn write(&self,) -> Result{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[method]outgoing-body.write"] - 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 => { - let e = { - let l2 = *ptr0.add(4).cast::(); - - super::super::super::wasi::io::streams::OutputStream::from_handle(l2 as u32) - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutgoingBody { - #[allow(unused_unsafe, clippy::all)] - /// Finalize an outgoing body, optionally providing trailers. This must be - /// called to signal that the response is complete. If the `outgoing-body` - /// is dropped without calling `outgoing-body.finalize`, the implementation - /// should treat the body as corrupted. - /// - /// Fails if the body's `outgoing-request` or `outgoing-response` was - /// constructed with a Content-Length header, and the contents written - /// to the body (via `write`) does not match the value given in the - /// Content-Length. - pub fn finish(this: OutgoingBody,trailers: Option,) -> Result<(),ErrorCode>{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 40]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); - let (result0_0,result0_1,) = match &trailers { - Some(e) => (1i32, (e).take_handle() as i32), - None => { - (0i32, 0i32) - }, - };let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/types@0.2.0")] - extern "C" { - #[link_name = "[static]outgoing-body.finish"] - fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, ){ unreachable!() } - wit_import((&this).take_handle() as i32, result0_0, result0_1, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr1.add(8).cast::()); - let v65 = match l3 { - 0 => { - ErrorCode::DnsTimeout - } - 1 => { - let e65 = { - let l4 = i32::from(*ptr1.add(16).cast::()); - let l8 = i32::from(*ptr1.add(28).cast::()); - - DnsErrorPayload{ - rcode: match l4 { - 0 => None, - 1 => { - let e = { - let l5 = *ptr1.add(20).cast::<*mut u8>(); - let l6 = *ptr1.add(24).cast::(); - let len7 = l6; - let bytes7 = _rt::Vec::from_raw_parts(l5.cast(), len7, len7); - - _rt::string_lift(bytes7) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - info_code: match l8 { - 0 => None, - 1 => { - let e = { - let l9 = i32::from(*ptr1.add(30).cast::()); - - l9 as u16 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::DnsError(e65) - } - 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 e65 = { - let l10 = i32::from(*ptr1.add(16).cast::()); - let l12 = i32::from(*ptr1.add(20).cast::()); - - TlsAlertReceivedPayload{ - alert_id: match l10 { - 0 => None, - 1 => { - let e = { - let l11 = i32::from(*ptr1.add(17).cast::()); - - l11 as u8 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - alert_message: match l12 { - 0 => None, - 1 => { - let e = { - let l13 = *ptr1.add(24).cast::<*mut u8>(); - let l14 = *ptr1.add(28).cast::(); - let len15 = l14; - let bytes15 = _rt::Vec::from_raw_parts(l13.cast(), len15, len15); - - _rt::string_lift(bytes15) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::TlsAlertReceived(e65) - } - 15 => { - ErrorCode::HttpRequestDenied - } - 16 => { - ErrorCode::HttpRequestLengthRequired - } - 17 => { - let e65 = { - let l16 = i32::from(*ptr1.add(16).cast::()); - - match l16 { - 0 => None, - 1 => { - let e = { - let l17 = *ptr1.add(24).cast::(); - - l17 as u64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestBodySize(e65) - } - 18 => { - ErrorCode::HttpRequestMethodInvalid - } - 19 => { - ErrorCode::HttpRequestUriInvalid - } - 20 => { - ErrorCode::HttpRequestUriTooLong - } - 21 => { - let e65 = { - let l18 = i32::from(*ptr1.add(16).cast::()); - - match l18 { - 0 => None, - 1 => { - let e = { - let l19 = *ptr1.add(20).cast::(); - - l19 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSectionSize(e65) - } - 22 => { - let e65 = { - let l20 = i32::from(*ptr1.add(16).cast::()); - - match l20 { - 0 => None, - 1 => { - let e = { - let l21 = i32::from(*ptr1.add(20).cast::()); - let l25 = i32::from(*ptr1.add(32).cast::()); - - 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::(); - - l26 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestHeaderSize(e65) - } - 23 => { - let e65 = { - let l27 = i32::from(*ptr1.add(16).cast::()); - - match l27 { - 0 => None, - 1 => { - let e = { - let l28 = *ptr1.add(20).cast::(); - - l28 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpRequestTrailerSectionSize(e65) - } - 24 => { - let e65 = { - let l29 = i32::from(*ptr1.add(16).cast::()); - let l33 = i32::from(*ptr1.add(28).cast::()); - - FieldSizePayload{ - field_name: match l29 { - 0 => None, - 1 => { - let e = { - let l30 = *ptr1.add(20).cast::<*mut u8>(); - let l31 = *ptr1.add(24).cast::(); - let len32 = l31; - let bytes32 = _rt::Vec::from_raw_parts(l30.cast(), len32, len32); - - _rt::string_lift(bytes32) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l33 { - 0 => None, - 1 => { - let e = { - let l34 = *ptr1.add(32).cast::(); - - l34 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpRequestTrailerSize(e65) - } - 25 => { - ErrorCode::HttpResponseIncomplete - } - 26 => { - let e65 = { - let l35 = i32::from(*ptr1.add(16).cast::()); - - match l35 { - 0 => None, - 1 => { - let e = { - let l36 = *ptr1.add(20).cast::(); - - l36 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseHeaderSectionSize(e65) - } - 27 => { - let e65 = { - let l37 = i32::from(*ptr1.add(16).cast::()); - let l41 = i32::from(*ptr1.add(28).cast::()); - - FieldSizePayload{ - field_name: match l37 { - 0 => None, - 1 => { - let e = { - let l38 = *ptr1.add(20).cast::<*mut u8>(); - let l39 = *ptr1.add(24).cast::(); - let len40 = l39; - let bytes40 = _rt::Vec::from_raw_parts(l38.cast(), len40, len40); - - _rt::string_lift(bytes40) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l41 { - 0 => None, - 1 => { - let e = { - let l42 = *ptr1.add(32).cast::(); - - l42 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseHeaderSize(e65) - } - 28 => { - let e65 = { - let l43 = i32::from(*ptr1.add(16).cast::()); - - match l43 { - 0 => None, - 1 => { - let e = { - let l44 = *ptr1.add(24).cast::(); - - l44 as u64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseBodySize(e65) - } - 29 => { - let e65 = { - let l45 = i32::from(*ptr1.add(16).cast::()); - - match l45 { - 0 => None, - 1 => { - let e = { - let l46 = *ptr1.add(20).cast::(); - - l46 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTrailerSectionSize(e65) - } - 30 => { - let e65 = { - let l47 = i32::from(*ptr1.add(16).cast::()); - let l51 = i32::from(*ptr1.add(28).cast::()); - - FieldSizePayload{ - field_name: match l47 { - 0 => None, - 1 => { - let e = { - let l48 = *ptr1.add(20).cast::<*mut u8>(); - let l49 = *ptr1.add(24).cast::(); - let len50 = l49; - let bytes50 = _rt::Vec::from_raw_parts(l48.cast(), len50, len50); - - _rt::string_lift(bytes50) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - field_size: match l51 { - 0 => None, - 1 => { - let e = { - let l52 = *ptr1.add(32).cast::(); - - l52 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - ErrorCode::HttpResponseTrailerSize(e65) - } - 31 => { - let e65 = { - let l53 = i32::from(*ptr1.add(16).cast::()); - - match l53 { - 0 => None, - 1 => { - let e = { - let l54 = *ptr1.add(20).cast::<*mut u8>(); - let l55 = *ptr1.add(24).cast::(); - let len56 = l55; - let bytes56 = _rt::Vec::from_raw_parts(l54.cast(), len56, len56); - - _rt::string_lift(bytes56) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseTransferCoding(e65) - } - 32 => { - let e65 = { - let l57 = i32::from(*ptr1.add(16).cast::()); - - match l57 { - 0 => None, - 1 => { - let e = { - let l58 = *ptr1.add(20).cast::<*mut u8>(); - let l59 = *ptr1.add(24).cast::(); - let len60 = l59; - let bytes60 = _rt::Vec::from_raw_parts(l58.cast(), len60, len60); - - _rt::string_lift(bytes60) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::HttpResponseContentCoding(e65) - } - 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 e65 = { - let l61 = i32::from(*ptr1.add(16).cast::()); - - match l61 { - 0 => None, - 1 => { - let e = { - let l62 = *ptr1.add(20).cast::<*mut u8>(); - let l63 = *ptr1.add(24).cast::(); - let len64 = l63; - let bytes64 = _rt::Vec::from_raw_parts(l62.cast(), len64, len64); - - _rt::string_lift(bytes64) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - ErrorCode::InternalError(e65) - } - }; - - v65 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl FutureIncomingResponse { - #[allow(unused_unsafe, clippy::all)] - /// Returns a pollable which becomes ready when either the Response has - /// been received, or an error has occured. When this pollable is ready, - /// the `get` method will return `some`. - /// subscribe: func() -> pollable; // Hermes does NOT support `poll` - /// Returns the incoming HTTP Response, or an error, once one is ready. - /// - /// The outer `option` represents future readiness. Users can wait on this - /// `option` to become `some` using the `subscribe` method. - /// - /// The outer `result` is used to retrieve the response or error at most - /// once. It will be success on the first call in which the outer option - /// is `some`, and error on subsequent calls. - /// - /// The inner `result` represents that either the incoming HTTP Response - /// status and headers have recieved successfully, or that an error - /// occured. Errors may also occur while consuming the response body, - /// but those will be reported by the `incoming-body` and its - /// `output-stream` child. - pub fn get(&self,) -> Option,()>>{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 56]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 56]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[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::()); - - 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 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - Ok(e) - } - 1 => { - let e = (); - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - - } - - #[allow(dead_code, clippy::all)] - pub mod outgoing_handler { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - pub type OutgoingRequest = super::super::super::wasi::http::types::OutgoingRequest; - pub type RequestOptions = super::super::super::wasi::http::types::RequestOptions; - pub type FutureIncomingResponse = super::super::super::wasi::http::types::FutureIncomingResponse; - pub type ErrorCode = super::super::super::wasi::http::types::ErrorCode; - #[allow(unused_unsafe, clippy::all)] - /// This function is invoked with an outgoing HTTP Request, and it returns - /// a resource `future-incoming-response` which represents an HTTP Response - /// which may arrive in the future. - /// - /// The `options` argument accepts optional parameters for the HTTP - /// protocol's transport layer. - /// - /// This function may return an error if the `outgoing-request` is invalid - /// or not allowed to be made. Otherwise, protocol errors are reported - /// through the `future-incoming-response`. - pub fn handle(request: OutgoingRequest,options: Option,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 40]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]); - let (result0_0,result0_1,) = match &options { - Some(e) => (1i32, (e).take_handle() as i32), - None => { - (0i32, 0i32) - }, - };let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:http/outgoing-handler@0.2.0")] - extern "C" { - #[link_name = "handle"] - fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i32, _: *mut u8, ){ unreachable!() } - wit_import((&request).take_handle() as i32, result0_0, result0_1, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = { - let l3 = *ptr1.add(8).cast::(); - - super::super::super::wasi::http::types::FutureIncomingResponse::from_handle(l3 as u32) - }; - Ok(e) - } - 1 => { - let e = { - let l4 = i32::from(*ptr1.add(8).cast::()); - use super::super::super::wasi::http::types::ErrorCode as V66; - let v66 = match l4 { - 0 => { - V66::DnsTimeout - } - 1 => { - let e66 = { - let l5 = i32::from(*ptr1.add(16).cast::()); - 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::()); - - l10 as u16 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - V66::DnsError(e66) - } - 2 => { - V66::DestinationNotFound - } - 3 => { - V66::DestinationUnavailable - } - 4 => { - V66::DestinationIpProhibited - } - 5 => { - V66::DestinationIpUnroutable - } - 6 => { - V66::ConnectionRefused - } - 7 => { - V66::ConnectionTerminated - } - 8 => { - V66::ConnectionTimeout - } - 9 => { - V66::ConnectionReadTimeout - } - 10 => { - V66::ConnectionWriteTimeout - } - 11 => { - V66::ConnectionLimitReached - } - 12 => { - V66::TlsProtocolError - } - 13 => { - V66::TlsCertificateError - } - 14 => { - let e66 = { - let l11 = i32::from(*ptr1.add(16).cast::()); - 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::()); - - 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) - } - 15 => { - V66::HttpRequestDenied - } - 16 => { - V66::HttpRequestLengthRequired - } - 17 => { - let e66 = { - let l17 = i32::from(*ptr1.add(16).cast::()); - - match l17 { - 0 => None, - 1 => { - let e = { - let l18 = *ptr1.add(24).cast::(); - - l18 as u64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - V66::HttpRequestBodySize(e66) - } - 18 => { - V66::HttpRequestMethodInvalid - } - 19 => { - V66::HttpRequestUriInvalid - } - 20 => { - V66::HttpRequestUriTooLong - } - 21 => { - let e66 = { - let l19 = i32::from(*ptr1.add(16).cast::()); - - match l19 { - 0 => None, - 1 => { - let e = { - let l20 = *ptr1.add(20).cast::(); - - l20 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - V66::HttpRequestHeaderSectionSize(e66) - } - 22 => { - let e66 = { - let l21 = i32::from(*ptr1.add(16).cast::()); - - match l21 { - 0 => None, - 1 => { - let e = { - let l22 = i32::from(*ptr1.add(20).cast::()); - let l26 = 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); - - _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(), - }, - } - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - V66::HttpRequestHeaderSize(e66) - } - 23 => { - let e66 = { - let l28 = i32::from(*ptr1.add(16).cast::()); - - match l28 { - 0 => None, - 1 => { - let e = { - let l29 = *ptr1.add(20).cast::(); - - l29 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - V66::HttpRequestTrailerSectionSize(e66) - } - 24 => { - let e66 = { - let l30 = i32::from(*ptr1.add(16).cast::()); - 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::(); - - l35 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - V66::HttpRequestTrailerSize(e66) - } - 25 => { - V66::HttpResponseIncomplete - } - 26 => { - let e66 = { - let l36 = i32::from(*ptr1.add(16).cast::()); - - match l36 { - 0 => None, - 1 => { - let e = { - let l37 = *ptr1.add(20).cast::(); - - l37 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseHeaderSectionSize(e66) - } - 27 => { - let e66 = { - let l38 = i32::from(*ptr1.add(16).cast::()); - 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::(); - - l43 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - V66::HttpResponseHeaderSize(e66) - } - 28 => { - let e66 = { - let l44 = i32::from(*ptr1.add(16).cast::()); - - match l44 { - 0 => None, - 1 => { - let e = { - let l45 = *ptr1.add(24).cast::(); - - l45 as u64 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseBodySize(e66) - } - 29 => { - let e66 = { - let l46 = i32::from(*ptr1.add(16).cast::()); - - match l46 { - 0 => None, - 1 => { - let e = { - let l47 = *ptr1.add(20).cast::(); - - l47 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseTrailerSectionSize(e66) - } - 30 => { - let e66 = { - let l48 = i32::from(*ptr1.add(16).cast::()); - 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::(); - - l53 as u32 - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - } - }; - V66::HttpResponseTrailerSize(e66) - } - 31 => { - let e66 = { - let l54 = i32::from(*ptr1.add(16).cast::()); - - match l54 { - 0 => None, - 1 => { - let e = { - let l55 = *ptr1.add(20).cast::<*mut u8>(); - let l56 = *ptr1.add(24).cast::(); - let len57 = l56; - let bytes57 = _rt::Vec::from_raw_parts(l55.cast(), len57, len57); - - _rt::string_lift(bytes57) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseTransferCoding(e66) - } - 32 => { - let e66 = { - let l58 = i32::from(*ptr1.add(16).cast::()); - - match l58 { - 0 => None, - 1 => { - let e = { - let l59 = *ptr1.add(20).cast::<*mut u8>(); - let l60 = *ptr1.add(24).cast::(); - let len61 = l60; - let bytes61 = _rt::Vec::from_raw_parts(l59.cast(), len61, len61); - - _rt::string_lift(bytes61) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - V66::HttpResponseContentCoding(e66) - } - 33 => { - V66::HttpResponseTimeout - } - 34 => { - V66::HttpUpgradeFailed - } - 35 => { - V66::HttpProtocolError - } - 36 => { - V66::LoopDetected - } - 37 => { - V66::ConfigurationError - } - n => { - debug_assert_eq!(n, 38, "invalid enum discriminant"); - let e66 = { - let l62 = i32::from(*ptr1.add(16).cast::()); - - match l62 { - 0 => None, - 1 => { - let e = { - let l63 = *ptr1.add(20).cast::<*mut u8>(); - let l64 = *ptr1.add(24).cast::(); - let len65 = l64; - let bytes65 = _rt::Vec::from_raw_parts(l63.cast(), len65, len65); - - _rt::string_lift(bytes65) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - } - }; - V66::InternalError(e66) - } - }; - - v66 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - - } - - } - #[allow(dead_code)] - pub mod io { - #[allow(dead_code, clippy::all)] - pub mod error { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - /// A resource which represents some error information. - /// - /// The only method provided by this resource is `to-debug-string`, - /// which provides some human-readable information about the error. - /// - /// In the `wasi:io` package, this resource is returned through the - /// `wasi:io/streams/stream-error` type. - /// - /// To provide more specific error information, other interfaces may - /// provide functions to further "downcast" this error into more specific - /// error information. For example, `error`s returned in streams derived - /// from filesystem types to be described using the filesystem's own - /// error-code type, using the function - /// `wasi:filesystem/types/filesystem-error-code`, which takes a parameter - /// `borrow` and returns - /// `option`. - /// - /// The set of functions which can "downcast" an `error` into a more - /// concrete type is open. - - #[derive(Debug)] - #[repr(transparent)] - pub struct Error{ - handle: _rt::Resource, - } - - impl Error{ - #[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 Error{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/error@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]error"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl Error { - #[allow(unused_unsafe, clippy::all)] - /// Returns a string that is suitable to assist humans in debugging - /// this error. - /// - /// WARNING: The returned string should not be consumed mechanically! - /// It may change across platforms, hosts, or other implementation - /// details. Parsing this string is a major platform-compatibility - /// hazard. - pub fn to_debug_string(&self,) -> _rt::String{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/error@0.2.0")] - extern "C" { - #[link_name = "[method]error.to-debug-string"] - 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 = *ptr0.add(0).cast::<*mut u8>(); - let l2 = *ptr0.add(4).cast::(); - let len3 = l2; - let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); - _rt::string_lift(bytes3) - } - } - } - - } - - #[allow(dead_code, clippy::all)] - pub mod streams { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - pub type Error = super::super::super::wasi::io::error::Error; - /// * - /// // Hermes does not support `poll` - /// use poll.{pollable}; - /// */ - /// An error for input-stream and output-stream operations. - pub enum StreamError { - /// The last operation (a write or flush) failed before completion. - /// - /// More information is available in the `error` payload. - LastOperationFailed(Error), - /// The stream is closed: no more input will be accepted by the - /// stream. A closed output-stream will return this error on all - /// future operations. - Closed, - } - impl ::core::fmt::Debug for StreamError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - match self { - StreamError::LastOperationFailed(e) => { - f.debug_tuple("StreamError::LastOperationFailed").field(e).finish() - } - StreamError::Closed => { - f.debug_tuple("StreamError::Closed").finish() - } - } - } - } - impl ::core::fmt::Display for StreamError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - write!(f, "{:?}", self) - } - } - - impl std::error::Error for StreamError {} - /// An input bytestream. - /// - /// `input-stream`s are *non-blocking* to the extent practical on underlying - /// platforms. I/O operations always return promptly; if fewer bytes are - /// promptly available than requested, they return the number of bytes promptly - /// available, which could even be zero. To wait for data to be available, - /// use the `subscribe` function to obtain a `pollable` which can be polled - /// for using `wasi:io/poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct InputStream{ - handle: _rt::Resource, - } - - impl InputStream{ - #[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 InputStream{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]input-stream"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - /// An output bytestream. - /// - /// `output-stream`s are *non-blocking* to the extent practical on - /// underlying platforms. Except where specified otherwise, I/O operations also - /// always return promptly, after the number of bytes that can be written - /// promptly, which could even be zero. To wait for the stream to be ready to - /// accept data, the `subscribe` function to obtain a `pollable` which can be - /// polled for using `wasi:io/poll`. - - #[derive(Debug)] - #[repr(transparent)] - pub struct OutputStream{ - handle: _rt::Resource, - } - - impl OutputStream{ - #[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 OutputStream{ - #[inline] - unsafe fn drop(_handle: u32) { - #[cfg(not(target_arch = "wasm32"))] - unreachable!(); - - #[cfg(target_arch = "wasm32")] - { - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[resource-drop]output-stream"] - fn drop(_: u32); - } - - drop(_handle); - } - } - } - - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a non-blocking read from the stream. - /// - /// This function returns a list of bytes containing the read data, - /// when successful. The returned list will contain up to `len` bytes; - /// it may return fewer than requested, but not more. The list is - /// empty when no bytes are available for reading at this time. The - /// pollable given by `subscribe` will be ready when more bytes are - /// available. - /// - /// This function fails with a `stream-error` when the operation - /// encounters an error, giving `last-operation-failed`, or when the - /// stream is closed, giving `closed`. - /// - /// When the caller gives a `len` of 0, it represents a request to - /// read 0 bytes. If the stream is still open, this call should - /// succeed and return an empty list, or otherwise fail with `closed`. - /// - /// The `len` parameter is a `u64`, which could represent a list of u8 which - /// is not possible to allocate in wasm32, or not desirable to allocate as - /// as a return value by the callee. The callee may return a list of bytes - /// less than `len` in size while more bytes are available for reading. - pub fn read(&self,len: u64,) -> Result<_rt::Vec::,StreamError>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.read"] - fn wit_import(_: i32, _: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - - _rt::Vec::from_raw_parts(l2.cast(), len4, len4) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*ptr0.add(4).cast::()); - let v7 = match l5 { - 0 => { - let e7 = { - let l6 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l6 as u32) - }; - StreamError::LastOperationFailed(e7) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v7 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read bytes from a stream, after blocking until at least one byte can - /// be read. Except for blocking, behavior is identical to `read`. - pub fn blocking_read(&self,len: u64,) -> Result<_rt::Vec::,StreamError>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.blocking-read"] - fn wit_import(_: i32, _: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = { - let l2 = *ptr0.add(4).cast::<*mut u8>(); - let l3 = *ptr0.add(8).cast::(); - let len4 = l3; - - _rt::Vec::from_raw_parts(l2.cast(), len4, len4) - }; - Ok(e) - } - 1 => { - let e = { - let l5 = i32::from(*ptr0.add(4).cast::()); - let v7 = match l5 { - 0 => { - let e7 = { - let l6 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l6 as u32) - }; - StreamError::LastOperationFailed(e7) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v7 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Skip bytes from a stream. Returns number of bytes skipped. - /// - /// Behaves identical to `read`, except instead of returning a list - /// of bytes, returns the number of bytes consumed from the stream. - pub fn skip(&self,len: u64,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.skip"] - fn wit_import(_: i32, _: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = { - let l2 = *ptr0.add(8).cast::(); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(8).cast::()); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *ptr0.add(12).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl InputStream { - #[allow(unused_unsafe, clippy::all)] - /// Skip bytes from a stream, after blocking until at least one byte - /// can be skipped. Except for blocking behavior, identical to `skip`. - pub fn blocking_skip(&self,len: u64,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]input-stream.blocking-skip"] - fn wit_import(_: i32, _: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = { - let l2 = *ptr0.add(8).cast::(); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(8).cast::()); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *ptr0.add(12).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Check readiness for writing. This function never blocks. - /// - /// Returns the number of bytes permitted for the next call to `write`, - /// or an error. Calling `write` with more bytes than this function has - /// permitted will trap. - /// - /// When this function returns 0 bytes, the `subscribe` pollable will - /// become ready when this function will report at least 1 byte, or an - /// error. - pub fn check_write(&self,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.check-write"] - 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 => { - let e = { - let l2 = *ptr0.add(8).cast::(); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(8).cast::()); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *ptr0.add(12).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write. This function never blocks. - /// - /// Precondition: check-write gave permit of Ok(n) and contents has a - /// length of less than or equal to n. Otherwise, this function will trap. - /// - /// returns Err(closed) without writing if the stream has closed since - /// the last call to check-write provided a permit. - pub fn write(&self,contents: &[u8],) -> Result<(),StreamError>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = contents; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.write"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr1.add(4).cast::()); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *ptr1.add(8).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write of up to 4096 bytes, and then flush the stream. Block - /// until all of these operations are complete, or an error occurs. - /// - /// This is a convenience wrapper around the use of `check-write`, - /// `subscribe`, `write`, and `flush`, and is implemented with the - /// following pseudo-code: - /// - /// ```text - /// let pollable = this.subscribe(); - /// while !contents.is_empty() { - /// // Wait for the stream to become writable - /// poll-one(pollable); - /// let Ok(n) = this.check-write(); // eliding error handling - /// let len = min(n, contents.len()); - /// let (chunk, rest) = contents.split_at(len); - /// this.write(chunk ); // eliding error handling - /// contents = rest; - /// } - /// this.flush(); - /// // Wait for completion of `flush` - /// poll-one(pollable); - /// // Check for any errors that arose during `flush` - /// let _ = this.check-write(); // eliding error handling - /// ``` - pub fn blocking_write_and_flush(&self,contents: &[u8],) -> Result<(),StreamError>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let vec0 = contents; - let ptr0 = vec0.as_ptr().cast::(); - let len0 = vec0.len(); - let ptr1 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-write-and-flush"] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: *mut u8, _: usize, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); - let l2 = i32::from(*ptr1.add(0).cast::()); - match l2 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr1.add(4).cast::()); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *ptr1.add(8).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Request to flush buffered output. This function never blocks. - /// - /// This tells the output-stream that the caller intends any buffered - /// output to be flushed. the output which is expected to be flushed - /// is all that has been passed to `write` prior to this call. - /// - /// Upon calling this function, the `output-stream` will not accept any - /// writes (`check-write` will return `ok(0)`) until the flush has - /// completed. The `subscribe` pollable will become ready when the - /// flush has completed and the stream can accept more writes. - pub fn flush(&self,) -> Result<(),StreamError>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.flush"] - 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 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*ptr0.add(4).cast::()); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Request to flush buffered output, and block until flush completes - /// and stream is ready for writing again. - pub fn blocking_flush(&self,) -> Result<(),StreamError>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-flush"] - 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 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*ptr0.add(4).cast::()); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Create a `pollable` which will resolve once the output-stream - /// is ready for more writing, or an error has occured. When this - /// pollable is ready, `check-write` will return `ok(n)` with n>0, or an - /// error. - /// - /// If the stream is closed, this pollable is always ready immediately. - /// - /// The created `pollable` is a child resource of the `output-stream`. - /// Implementations may trap if the `output-stream` is dropped before - /// all derived `pollable`s created with this function are dropped. - /// subscribe: func() -> pollable; // Hermes does NOT support `poll` - /// Write zeroes to a stream. - /// - /// this should be used precisely like `write` with the exact same - /// preconditions (must use check-write first), but instead of - /// passing a list of bytes, you simply pass the number of zero-bytes - /// that should be written. - pub fn write_zeroes(&self,len: u64,) -> Result<(),StreamError>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.write-zeroes"] - fn wit_import(_: i32, _: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*ptr0.add(4).cast::()); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Perform a write of up to 4096 zeroes, and then flush the stream. - /// Block until all of these operations are complete, or an error - /// occurs. - /// - /// This is a convenience wrapper around the use of `check-write`, - /// `subscribe`, `write-zeroes`, and `flush`, and is implemented with - /// the following pseudo-code: - /// - /// ```text - /// let pollable = this.subscribe(); - /// while num_zeroes != 0 { - /// // Wait for the stream to become writable - /// poll-one(pollable); - /// let Ok(n) = this.check-write(); // eliding error handling - /// let len = min(n, num_zeroes); - /// this.write-zeroes(len); // eliding error handling - /// num_zeroes -= len; - /// } - /// this.flush(); - /// // Wait for completion of `flush` - /// poll-one(pollable); - /// // Check for any errors that arose during `flush` - /// let _ = this.check-write(); // eliding error handling - /// ``` - pub fn blocking_write_zeroes_and_flush(&self,len: u64,) -> Result<(),StreamError>{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-write-zeroes-and-flush"] - fn wit_import(_: i32, _: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i64, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, _rt::as_i64(&len), ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = (); - Ok(e) - } - 1 => { - let e = { - let l2 = i32::from(*ptr0.add(4).cast::()); - let v4 = match l2 { - 0 => { - let e4 = { - let l3 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l3 as u32) - }; - StreamError::LastOperationFailed(e4) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v4 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read from one stream and write to another. - /// - /// The behavior of splice is equivelant to: - /// 1. calling `check-write` on the `output-stream` - /// 2. calling `read` on the `input-stream` with the smaller of the - /// `check-write` permitted length and the `len` provided to `splice` - /// 3. calling `write` on the `output-stream` with that read data. - /// - /// Any error reported by the call to `check-write`, `read`, or - /// `write` ends the splice and reports that error. - /// - /// This function returns the number of bytes transferred; it may be less - /// than `len`. - pub fn splice(&self,src: &InputStream,len: u64,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.splice"] - fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, (src).handle() as i32, _rt::as_i64(&len), ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = { - let l2 = *ptr0.add(8).cast::(); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(8).cast::()); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *ptr0.add(12).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - impl OutputStream { - #[allow(unused_unsafe, clippy::all)] - /// Read from one stream and write to another, with blocking. - /// - /// This is similar to `splice`, except that it blocks until the - /// `output-stream` is ready for writing, and the `input-stream` - /// is ready for reading, before performing the `splice`. - pub fn blocking_splice(&self,src: &InputStream,len: u64,) -> Result{ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:io/streams@0.2.0")] - extern "C" { - #[link_name = "[method]output-stream.blocking-splice"] - fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i32, _: i32, _: i64, _: *mut u8, ){ unreachable!() } - wit_import((self).handle() as i32, (src).handle() as i32, _rt::as_i64(&len), ptr0); - let l1 = i32::from(*ptr0.add(0).cast::()); - match l1 { - 0 => { - let e = { - let l2 = *ptr0.add(8).cast::(); - - l2 as u64 - }; - Ok(e) - } - 1 => { - let e = { - let l3 = i32::from(*ptr0.add(8).cast::()); - let v5 = match l3 { - 0 => { - let e5 = { - let l4 = *ptr0.add(12).cast::(); - - super::super::super::wasi::io::error::Error::from_handle(l4 as u32) - }; - StreamError::LastOperationFailed(e5) - } - n => { - debug_assert_eq!(n, 1, "invalid enum discriminant"); - StreamError::Closed - } - }; - - v5 - }; - Err(e) - } - _ => _rt::invalid_enum_discriminant(), - } - } - } - } - - } - - } - #[allow(dead_code)] - pub mod random { - #[allow(dead_code, clippy::all)] - pub mod random { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - #[allow(unused_unsafe, clippy::all)] - /// Return `len` cryptographically-secure random or pseudo-random bytes. - /// - /// This function must produce data at least as cryptographically secure and - /// fast as an adequately seeded cryptographically-secure pseudo-random - /// number generator (CSPRNG). It must not block, from the perspective of - /// the calling program, under any circumstances, including on the first - /// request and on requests for numbers of bytes. The returned data must - /// always be unpredictable. - /// - /// This function must always return fresh data. Deterministic environments - /// must omit this function, rather than implementing it with deterministic - /// data. - pub fn get_random_bytes(len: u64,) -> _rt::Vec::{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:random/random@0.2.0")] - extern "C" { - #[link_name = "get-random-bytes"] - fn wit_import(_: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: *mut u8, ){ unreachable!() } - wit_import(_rt::as_i64(&len), ptr0); - let l1 = *ptr0.add(0).cast::<*mut u8>(); - let l2 = *ptr0.add(4).cast::(); - let len3 = l2; - _rt::Vec::from_raw_parts(l1.cast(), len3, len3) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Return a cryptographically-secure random or pseudo-random `u64` value. - /// - /// This function returns the same type of data as `get-random-bytes`, - /// represented as a `u64`. - pub fn get_random_u64() -> u64{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:random/random@0.2.0")] - extern "C" { - #[link_name = "get-random-u64"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - - } - - #[allow(dead_code, clippy::all)] - pub mod insecure { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - use super::super::super::_rt; - #[allow(unused_unsafe, clippy::all)] - /// Return `len` insecure pseudo-random bytes. - /// - /// This function is not cryptographically secure. Do not use it for - /// anything related to security. - /// - /// There are no requirements on the values of the returned bytes, however - /// implementations are encouraged to return evenly distributed values with - /// a long period. - pub fn get_insecure_random_bytes(len: u64,) -> _rt::Vec::{ - unsafe { - #[repr(align(4))] - struct RetArea([::core::mem::MaybeUninit::; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:random/insecure@0.2.0")] - extern "C" { - #[link_name = "get-insecure-random-bytes"] - fn wit_import(_: i64, _: *mut u8, ); - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import(_: i64, _: *mut u8, ){ unreachable!() } - wit_import(_rt::as_i64(&len), ptr0); - let l1 = *ptr0.add(0).cast::<*mut u8>(); - let l2 = *ptr0.add(4).cast::(); - let len3 = l2; - _rt::Vec::from_raw_parts(l1.cast(), len3, len3) - } - } - #[allow(unused_unsafe, clippy::all)] - /// Return an insecure pseudo-random `u64` value. - /// - /// This function returns the same type of pseudo-random data as - /// `get-insecure-random-bytes`, represented as a `u64`. - pub fn get_insecure_random_u64() -> u64{ - unsafe { - - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:random/insecure@0.2.0")] - extern "C" { - #[link_name = "get-insecure-random-u64"] - fn wit_import() -> i64; - } - - #[cfg(not(target_arch = "wasm32"))] - fn wit_import() -> i64{ unreachable!() } - let ret = wit_import(); - ret as u64 - } - } - - } - - #[allow(dead_code, clippy::all)] - pub mod insecure_seed { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; - #[allow(unused_unsafe, clippy::all)] - /// Return a 128-bit value that may contain a pseudo-random value. - /// - /// The returned value is not required to be computed from a CSPRNG, and may - /// even be entirely deterministic. Host implementations are encouraged to - /// provide pseudo-random values to any program exposed to - /// attacker-controlled content, to enable DoS protection built into many - /// languages' hash-map implementations. - /// - /// This function is intended to only be called once, by a source language - /// to initialize Denial Of Service (DoS) protection in its hash-map - /// implementation. - /// - /// # Expected future evolution - /// - /// This will likely be changed to a value import, to prevent it from being - /// called multiple times and potentially used for purposes other than DoS - /// protection. - pub fn insecure_seed() -> (u64,u64,){ - unsafe { - #[repr(align(8))] - struct RetArea([::core::mem::MaybeUninit::; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); - let ptr0 = ret_area.0.as_mut_ptr().cast::(); - #[cfg(target_arch = "wasm32")] - #[link(wasm_import_module = "wasi:random/insecure-seed@0.2.0")] - extern "C" { - #[link_name = "insecure-seed"] - 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::(); - (l1 as u64, l2 as u64) - } - } - - } - - } -} -#[allow(dead_code)] -pub mod exports { - #[allow(dead_code)] - pub mod hermes { - #[allow(dead_code)] - pub mod cardano { - #[allow(dead_code, clippy::all)] - pub mod event_on_block { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; - use super::super::super::super::_rt; - pub type CardanoBlockchainId = super::super::super::super::hermes::cardano::api::CardanoBlockchainId; - pub type CardanoBlock = super::super::super::super::hermes::cardano::api::CardanoBlock; - pub type BlockSrc = super::super::super::super::hermes::cardano::api::BlockSrc; - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_on_cardano_block_cabi(arg0: i32,arg1: *mut u8,arg2: usize,arg3: i32,) {#[cfg(target_arch="wasm32")] - _rt::run_ctors_once();let len0 = arg2; - T::on_cardano_block(super::super::super::super::hermes::cardano::api::CardanoBlockchainId::_lift(arg0 as u8), _rt::Vec::from_raw_parts(arg1.cast(), len0, len0), super::super::super::super::hermes::cardano::api::BlockSrc::empty() | super::super::super::super::hermes::cardano::api::BlockSrc::from_bits_retain(((arg3 as u8) << 0) as _)); - } - pub trait Guest { - /// Triggered when a cardano block event fires. - /// - /// The module must export this interface to use it. - /// - /// ## Parameters - /// - /// - `blockchain` : The blockchain id the block originated from. - /// - `block` : This raw CBOR block data. - /// - `source` : Source information about where the block came from, and if we are at tip or not. - /// - /// Returns: - /// Nothing. - fn on_cardano_block(blockchain: CardanoBlockchainId,block: CardanoBlock,source: BlockSrc,); - } - #[doc(hidden)] - - macro_rules! __export_hermes_cardano_event_on_block_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "hermes:cardano/event-on-block#on-cardano-block"] - unsafe extern "C" fn export_on_cardano_block(arg0: i32,arg1: *mut u8,arg2: usize,arg3: i32,) { - $($path_to_types)*::_export_on_cardano_block_cabi::<$ty>(arg0, arg1, arg2, arg3) - } - };); - } - #[doc(hidden)] - pub(crate) use __export_hermes_cardano_event_on_block_cabi; - - } - - #[allow(dead_code, clippy::all)] - pub mod event_on_txn { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; - use super::super::super::super::_rt; - pub type CardanoBlockchainId = super::super::super::super::hermes::cardano::api::CardanoBlockchainId; - pub type CardanoTxn = super::super::super::super::hermes::cardano::api::CardanoTxn; - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_on_cardano_txn_cabi(arg0: i32,arg1: i64,arg2: i32,arg3: *mut u8,arg4: usize,) {#[cfg(target_arch="wasm32")] - _rt::run_ctors_once();let len0 = arg4; - T::on_cardano_txn(super::super::super::super::hermes::cardano::api::CardanoBlockchainId::_lift(arg0 as u8), arg1 as u64, arg2 as u32, _rt::Vec::from_raw_parts(arg3.cast(), len0, len0)); - } - pub trait Guest { - /// Triggered when a cardano transaction event fires. - /// - /// The module must export this interface to use it. - /// - /// ## Parameters - /// - /// - `blockchain` : The blockchain id the block originated from. - /// - `slot` : The slot the transaction is in. - /// - `txn-index` : The offset in the block this transaction is at. - /// - `txn` : The raw transaction data itself. - /// - /// Returns: - /// Nothing. - fn on_cardano_txn(blockchain: CardanoBlockchainId,slot: u64,txn_index: u32,txn: CardanoTxn,); - } - #[doc(hidden)] - - macro_rules! __export_hermes_cardano_event_on_txn_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "hermes:cardano/event-on-txn#on-cardano-txn"] - unsafe extern "C" fn export_on_cardano_txn(arg0: i32,arg1: i64,arg2: i32,arg3: *mut u8,arg4: usize,) { - $($path_to_types)*::_export_on_cardano_txn_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4) - } - };); - } - #[doc(hidden)] - pub(crate) use __export_hermes_cardano_event_on_txn_cabi; - - } - - #[allow(dead_code, clippy::all)] - pub mod event_on_rollback { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; - use super::super::super::super::_rt; - pub type CardanoBlockchainId = super::super::super::super::hermes::cardano::api::CardanoBlockchainId; - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_on_cardano_rollback_cabi(arg0: i32,arg1: i64,) {#[cfg(target_arch="wasm32")] - _rt::run_ctors_once();T::on_cardano_rollback(super::super::super::super::hermes::cardano::api::CardanoBlockchainId::_lift(arg0 as u8), arg1 as u64); - } - pub trait Guest { - /// Triggered when a cardano rollback event fires. - /// - /// The module must export this interface to use it. - /// - /// ## Parameters - /// - /// - `blockchain` : The blockchain id the rollback originated from. - /// - `slot` : The slot the rollback is targeting. (The next block event will be from this slot.) - /// - /// Returns: - /// Nothing. - fn on_cardano_rollback(blockchain: CardanoBlockchainId,slot: u64,); - } - #[doc(hidden)] - - macro_rules! __export_hermes_cardano_event_on_rollback_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "hermes:cardano/event-on-rollback#on-cardano-rollback"] - unsafe extern "C" fn export_on_cardano_rollback(arg0: i32,arg1: i64,) { - $($path_to_types)*::_export_on_cardano_rollback_cabi::<$ty>(arg0, arg1) - } - };); - } - #[doc(hidden)] - pub(crate) use __export_hermes_cardano_event_on_rollback_cabi; - -} - -} -#[allow(dead_code)] -pub mod cron { - #[allow(dead_code, clippy::all)] - pub mod event { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; - use super::super::super::super::_rt; - pub type CronTagged = super::super::super::super::hermes::cron::api::CronTagged; - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_on_cron_cabi(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: i32,) -> i32 {#[cfg(target_arch="wasm32")] - _rt::run_ctors_once();let len0 = arg1; - let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); - let len1 = arg3; - let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); - let result2 = T::on_cron(super::super::super::super::hermes::cron::api::CronTagged{ - when: _rt::string_lift(bytes0), - tag: _rt::string_lift(bytes1), - }, _rt::bool_lift(arg4 as u8)); - match result2 { true => 1, false => 0 } - } - pub trait Guest { - /// Triggered when a cron event fires. - /// - /// This event is only ever generated for the application that added - /// the cron job. - /// - /// The module must export this interface to use it. - /// - /// ## Parameters - /// - /// - `event` : The tagged cron event that was triggered. - /// - `last` : This cron event will not retrigger. - /// - /// Returns: - /// - `true` - retrigger. (Ignored if the cron event is `final`). - /// - `false` - stop the cron. - fn on_cron(event: CronTagged,last: bool,) -> bool; - } - #[doc(hidden)] - - macro_rules! __export_hermes_cron_event_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "hermes:cron/event#on-cron"] - unsafe extern "C" fn export_on_cron(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: i32,) -> i32 { - $($path_to_types)*::_export_on_cron_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4) - } - };); - } - #[doc(hidden)] - pub(crate) use __export_hermes_cron_event_cabi; - -} - -} -#[allow(dead_code)] -pub mod http_gateway { - #[allow(dead_code, clippy::all)] - pub mod event { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; - use super::super::super::super::_rt; - pub type Bstr = super::super::super::super::hermes::binary::api::Bstr; - pub type Header = (_rt::String,_rt::Vec::<_rt::String>,); - pub type Headers = _rt::Vec::
; - #[derive(Clone)] - pub struct HttpResponse { - pub code: u16, - pub headers: Headers, - pub body: Bstr, - } - impl ::core::fmt::Debug for HttpResponse { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("HttpResponse").field("code", &self.code).field("headers", &self.headers).field("body", &self.body).finish() - } - } - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_reply_cabi(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: *mut u8,arg5: usize,arg6: *mut u8,arg7: usize,) -> *mut u8 {#[cfg(target_arch="wasm32")] - _rt::run_ctors_once();let len0 = arg1; - let base10 = arg2; - let len10 = arg3; - let mut result10 = _rt::Vec::with_capacity(len10); - for i in 0..len10 { - let base = base10.add(i * 16); - let e10 = { - let l1 = *base.add(0).cast::<*mut u8>(); - let l2 = *base.add(4).cast::(); - let len3 = l2; - let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); - let l4 = *base.add(8).cast::<*mut u8>(); - let l5 = *base.add(12).cast::(); - let base9 = l4; - let len9 = l5; - let mut result9 = _rt::Vec::with_capacity(len9); - for i in 0..len9 { - let base = base9.add(i * 8); - let e9 = { - let l6 = *base.add(0).cast::<*mut u8>(); - let l7 = *base.add(4).cast::(); - let len8 = l7; - let bytes8 = _rt::Vec::from_raw_parts(l6.cast(), len8, len8); - - _rt::string_lift(bytes8) - }; - result9.push(e9); - } - _rt::cabi_dealloc(base9, len9 * 8, 4); - - (_rt::string_lift(bytes3), result9) - }; - result10.push(e10); - } - _rt::cabi_dealloc(base10, len10 * 16, 4); - let len11 = arg5; - let bytes11 = _rt::Vec::from_raw_parts(arg4.cast(), len11, len11); - let len12 = arg7; - let bytes12 = _rt::Vec::from_raw_parts(arg6.cast(), len12, len12); - let result13 = T::reply(_rt::Vec::from_raw_parts(arg0.cast(), len0, len0), result10, _rt::string_lift(bytes11), _rt::string_lift(bytes12)); - let ptr14 = _RET_AREA.0.as_mut_ptr().cast::(); - match result13 { - Some(e) => { - *ptr14.add(0).cast::() = (1i32) as u8; - let HttpResponse{ code:code15, headers:headers15, body:body15, } = e; - *ptr14.add(4).cast::() = (_rt::as_i32(code15)) as u16; - let vec20 = headers15; - let len20 = vec20.len(); - let layout20 = _rt::alloc::Layout::from_size_align_unchecked(vec20.len() * 16, 4); - let result20 = if layout20.size() != 0 { - let ptr = _rt::alloc::alloc(layout20).cast::(); - if ptr.is_null() - { - _rt::alloc::handle_alloc_error(layout20); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec20.into_iter().enumerate() { - let base = result20.add(i * 16); - { - let (t16_0, t16_1, ) = e; - let vec17 = (t16_0.into_bytes()).into_boxed_slice(); - let ptr17 = vec17.as_ptr().cast::(); - let len17 = vec17.len(); - ::core::mem::forget(vec17); - *base.add(4).cast::() = len17; - *base.add(0).cast::<*mut u8>() = ptr17.cast_mut(); - let vec19 = t16_1; - let len19 = vec19.len(); - let layout19 = _rt::alloc::Layout::from_size_align_unchecked(vec19.len() * 8, 4); - let result19 = if layout19.size() != 0 { - let ptr = _rt::alloc::alloc(layout19).cast::(); - if ptr.is_null() - { - _rt::alloc::handle_alloc_error(layout19); - } - ptr - }else {{ - ::core::ptr::null_mut() - }}; - for (i, e) in vec19.into_iter().enumerate() { - let base = result19.add(i * 8); - { - let vec18 = (e.into_bytes()).into_boxed_slice(); - let ptr18 = vec18.as_ptr().cast::(); - let len18 = vec18.len(); - ::core::mem::forget(vec18); - *base.add(4).cast::() = len18; - *base.add(0).cast::<*mut u8>() = ptr18.cast_mut(); - } - } - *base.add(12).cast::() = len19; - *base.add(8).cast::<*mut u8>() = result19; - } - } - *ptr14.add(12).cast::() = len20; - *ptr14.add(8).cast::<*mut u8>() = result20; - let vec21 = (body15).into_boxed_slice(); - let ptr21 = vec21.as_ptr().cast::(); - let len21 = vec21.len(); - ::core::mem::forget(vec21); - *ptr14.add(20).cast::() = len21; - *ptr14.add(16).cast::<*mut u8>() = ptr21.cast_mut(); - }, - None => { - { - *ptr14.add(0).cast::() = (0i32) as u8; - } - }, - };ptr14 - } - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn __post_return_reply(arg0: *mut u8,) { - let l0 = i32::from(*arg0.add(0).cast::()); - match l0 { - 0 => (), - _ => { - let l1 = *arg0.add(8).cast::<*mut u8>(); - let l2 = *arg0.add(12).cast::(); - let base10 = l1; - let len10 = l2; - for i in 0..len10 { - let base = base10.add(i * 16); - { - let l3 = *base.add(0).cast::<*mut u8>(); - let l4 = *base.add(4).cast::(); - _rt::cabi_dealloc(l3, l4, 1); - let l5 = *base.add(8).cast::<*mut u8>(); - let l6 = *base.add(12).cast::(); - let base9 = l5; - let len9 = l6; - for i in 0..len9 { - let base = base9.add(i * 8); - { - let l7 = *base.add(0).cast::<*mut u8>(); - let l8 = *base.add(4).cast::(); - _rt::cabi_dealloc(l7, l8, 1); - } - } - _rt::cabi_dealloc(base9, len9 * 8, 4); - } - } - _rt::cabi_dealloc(base10, len10 * 16, 4); - let l11 = *arg0.add(16).cast::<*mut u8>(); - let l12 = *arg0.add(20).cast::(); - let base13 = l11; - let len13 = l12; - _rt::cabi_dealloc(base13, len13 * 1, 1); - }, - } - } - pub trait Guest { - fn reply(body: Bstr,headers: Headers,path: _rt::String,method: _rt::String,) -> Option; - } - #[doc(hidden)] - - macro_rules! __export_hermes_http_gateway_event_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "hermes:http-gateway/event#reply"] - unsafe extern "C" fn export_reply(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: *mut u8,arg5: usize,arg6: *mut u8,arg7: usize,) -> *mut u8 { - $($path_to_types)*::_export_reply_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) - } - #[export_name = "cabi_post_hermes:http-gateway/event#reply"] - unsafe extern "C" fn _post_return_reply(arg0: *mut u8,) { - $($path_to_types)*::__post_return_reply::<$ty>(arg0) - } - };); - } - #[doc(hidden)] - pub(crate) use __export_hermes_http_gateway_event_cabi; - #[repr(align(4))] - struct _RetArea([::core::mem::MaybeUninit::; 24]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 24]); - -} - -} -#[allow(dead_code)] -pub mod http_request { - #[allow(dead_code, clippy::all)] - pub mod event_on_http_response { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; - use super::super::super::super::_rt; - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_on_http_response_cabi(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) {#[cfg(target_arch="wasm32")] - _rt::run_ctors_once();let len0 = arg1; - let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); - let len1 = arg3; - let bytes1 = _rt::Vec::from_raw_parts(arg2.cast(), len1, len1); - T::on_http_response(_rt::string_lift(bytes0), _rt::string_lift(bytes1)); - } - pub trait Guest { - fn on_http_response(request_id: _rt::String,response: _rt::String,); - } - #[doc(hidden)] - - macro_rules! __export_hermes_http_request_event_on_http_response_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "hermes:http-request/event-on-http-response#on-http-response"] - unsafe extern "C" fn export_on_http_response(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) { - $($path_to_types)*::_export_on_http_response_cabi::<$ty>(arg0, arg1, arg2, arg3) - } - };); - } - #[doc(hidden)] - pub(crate) use __export_hermes_http_request_event_on_http_response_cabi; - -} - -} -#[allow(dead_code)] -pub mod init { - #[allow(dead_code, clippy::all)] - pub mod event { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; - use super::super::super::super::_rt; - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_init_cabi() -> i32 {#[cfg(target_arch="wasm32")] - _rt::run_ctors_once();let result0 = T::init(); - match result0 { true => 1, false => 0 } - } - pub trait Guest { - /// Perform application start up initialization. - /// - /// This will only ever be called once when the application this module is a part of is started. - /// The module must export this interface to use it. - /// - /// Returns: - /// - `true` - Initialization is successful, the application may commence. - /// - `false` - Fatal error during Initialization. DO NOT START APPLICATION. - fn init() -> bool; - } - #[doc(hidden)] - - macro_rules! __export_hermes_init_event_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "hermes:init/event#init"] - unsafe extern "C" fn export_init() -> i32 { - $($path_to_types)*::_export_init_cabi::<$ty>() - } - };); - } - #[doc(hidden)] - pub(crate) use __export_hermes_init_event_cabi; - -} - -} -#[allow(dead_code)] -pub mod integration_test { - #[allow(dead_code, clippy::all)] - pub mod event { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; - use super::super::super::super::_rt; - /// Time in localtime format. - #[derive(Clone)] - pub struct TestResult { - pub name: _rt::String, - /// Name of the test - pub status: bool, - } - impl ::core::fmt::Debug for TestResult { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { - f.debug_struct("TestResult").field("name", &self.name).field("status", &self.status).finish() - } - } - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_test_cabi(arg0: i32,arg1: i32,) -> *mut u8 {#[cfg(target_arch="wasm32")] - _rt::run_ctors_once();let result0 = T::test(arg0 as u32, _rt::bool_lift(arg1 as u8)); - let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); - match result0 { - Some(e) => { - *ptr1.add(0).cast::() = (1i32) as u8; - let TestResult{ name:name2, status:status2, } = e; - let vec3 = (name2.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - ::core::mem::forget(vec3); - *ptr1.add(8).cast::() = len3; - *ptr1.add(4).cast::<*mut u8>() = ptr3.cast_mut(); - *ptr1.add(12).cast::() = (match status2 { true => 1, false => 0 }) as u8; - }, - None => { - { - *ptr1.add(0).cast::() = (0i32) as u8; - } - }, - };ptr1 - } - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn __post_return_test(arg0: *mut u8,) { - let l0 = i32::from(*arg0.add(0).cast::()); - match l0 { - 0 => (), - _ => { - let l1 = *arg0.add(4).cast::<*mut u8>(); - let l2 = *arg0.add(8).cast::(); - _rt::cabi_dealloc(l1, l2, 1); - }, - } - } - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_bench_cabi(arg0: i32,arg1: i32,) -> *mut u8 {#[cfg(target_arch="wasm32")] - _rt::run_ctors_once();let result0 = T::bench(arg0 as u32, _rt::bool_lift(arg1 as u8)); - let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); - match result0 { - Some(e) => { - *ptr1.add(0).cast::() = (1i32) as u8; - let TestResult{ name:name2, status:status2, } = e; - let vec3 = (name2.into_bytes()).into_boxed_slice(); - let ptr3 = vec3.as_ptr().cast::(); - let len3 = vec3.len(); - ::core::mem::forget(vec3); - *ptr1.add(8).cast::() = len3; - *ptr1.add(4).cast::<*mut u8>() = ptr3.cast_mut(); - *ptr1.add(12).cast::() = (match status2 { true => 1, false => 0 }) as u8; - }, - None => { - { - *ptr1.add(0).cast::() = (0i32) as u8; - } - }, - };ptr1 -} -#[doc(hidden)] -#[allow(non_snake_case)] -pub unsafe fn __post_return_bench(arg0: *mut u8,) { - let l0 = i32::from(*arg0.add(0).cast::()); - match l0 { - 0 => (), - _ => { - let l1 = *arg0.add(4).cast::<*mut u8>(); - let l2 = *arg0.add(8).cast::(); - _rt::cabi_dealloc(l1, l2, 1); - }, - } -} -pub trait Guest { - /// Run or List a WASM provided integration test. - /// - /// This is a single entrypoint in a wasm component, which can provide multiple tests. - /// Each test must be numbered from 0-n, with no gaps. - /// - /// test : u32 - The test number to run/list - /// run : bool - True = Run the test, False = Just list the test name. - /// - /// Returns: - /// None - There is no test at that test number. - /// test-result - The result of the test, if the test was not run, just returns the name and - /// status is True. Otherwise the test is executed, and the result is - /// the result of the test run. - fn test(test: u32,run: bool,) -> Option; - /// Run or List a WASM provided benchmark test. - /// - /// This is a single entrypoint in a wasm component, which can provide multiple benchmarks. - /// Each benchmark must be numbered from 0-n, with no gaps. - /// - /// Each time this function is called the bench function is run exactly once. - /// - /// test : u32 - The bench number to run/list - /// run : bool - True = Run the benchmark, False = Just list the test name. - /// - /// Returns: - /// None - There is no test at that test number. - /// test-result - The result of the test, if the test was not run, just returns the name and - /// status is True. Otherwise the test is executed, and the result is - /// the result of the test run. - fn bench(test: u32,run: bool,) -> Option; -} -#[doc(hidden)] - -macro_rules! __export_hermes_integration_test_event_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "hermes:integration-test/event#test"] - unsafe extern "C" fn export_test(arg0: i32,arg1: i32,) -> *mut u8 { - $($path_to_types)*::_export_test_cabi::<$ty>(arg0, arg1) - } - #[export_name = "cabi_post_hermes:integration-test/event#test"] - unsafe extern "C" fn _post_return_test(arg0: *mut u8,) { - $($path_to_types)*::__post_return_test::<$ty>(arg0) - } - #[export_name = "hermes:integration-test/event#bench"] - unsafe extern "C" fn export_bench(arg0: i32,arg1: i32,) -> *mut u8 { - $($path_to_types)*::_export_bench_cabi::<$ty>(arg0, arg1) - } - #[export_name = "cabi_post_hermes:integration-test/event#bench"] - unsafe extern "C" fn _post_return_bench(arg0: *mut u8,) { - $($path_to_types)*::__post_return_bench::<$ty>(arg0) - } - };); -} -#[doc(hidden)] -pub(crate) use __export_hermes_integration_test_event_cabi; -#[repr(align(4))] -struct _RetArea([::core::mem::MaybeUninit::; 16]); -static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 16]); - -} - -} -#[allow(dead_code)] -pub mod ipfs { - #[allow(dead_code, clippy::all)] - pub mod event { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; - use super::super::super::super::_rt; - pub type PubsubMessage = super::super::super::super::hermes::ipfs::api::PubsubMessage; - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_on_topic_cabi(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: i32,arg5: *mut u8,arg6: usize,) -> i32 {#[cfg(target_arch="wasm32")] - _rt::run_ctors_once();let len0 = arg1; - let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); - let len1 = arg3; - let result3 = T::on_topic(super::super::super::super::hermes::ipfs::api::PubsubMessage{ - topic: _rt::string_lift(bytes0), - message: _rt::Vec::from_raw_parts(arg2.cast(), len1, len1), - publisher: match arg4 { - 0 => None, - 1 => { - let e = { - let len2 = arg6; - let bytes2 = _rt::Vec::from_raw_parts(arg5.cast(), len2, len2); - - _rt::string_lift(bytes2) - }; - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }, - }); - match result3 { true => 1, false => 0 } - } - pub trait Guest { - /// Triggers when a message is received on a topic. - fn on_topic(message: PubsubMessage,) -> bool; - } - #[doc(hidden)] - - macro_rules! __export_hermes_ipfs_event_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "hermes:ipfs/event#on-topic"] - unsafe extern "C" fn export_on_topic(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: i32,arg5: *mut u8,arg6: usize,) -> i32 { - $($path_to_types)*::_export_on_topic_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5, arg6) - } - };); - } - #[doc(hidden)] - pub(crate) use __export_hermes_ipfs_event_cabi; - -} - -} -#[allow(dead_code)] -pub mod kv_store { - #[allow(dead_code, clippy::all)] - pub mod event { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; - use super::super::super::super::_rt; - pub type KvValues = super::super::super::super::hermes::kv_store::api::KvValues; - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_kv_update_cabi(arg0: *mut u8,arg1: usize,arg2: i32,arg3: ::core::mem::MaybeUninit::,arg4: usize,) {#[cfg(target_arch="wasm32")] - _rt::run_ctors_once();let len0 = arg1; - let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); - use super::super::super::super::hermes::kv_store::api::KvValues as V5; - let v5 = match arg2 { - 0 => { - let e5 = { - let len1 = arg4; - let bytes1 = _rt::Vec::from_raw_parts(arg3.as_ptr().cast::<*mut u8>().read().cast(), len1, len1); - - _rt::string_lift(bytes1) - }; - V5::KvString(e5) - } - 1 => { - let e5 = arg3.assume_init() as i64; - V5::KvS64(e5) - } - 2 => { - let e5 = arg3.assume_init() as i64 as u64; - V5::KvU64(e5) - } - 3 => { - let e5 = f64::from_bits(arg3.assume_init() as i64 as u64); - V5::KvF64(e5) - } - 4 => { - let e5 = { - let len2 = arg4; - - _rt::Vec::from_raw_parts(arg3.as_ptr().cast::<*mut u8>().read().cast(), len2, len2) - }; - V5::KvBstr(e5) - } - 5 => { - let e5 = { - let len3 = arg4; - - _rt::Vec::from_raw_parts(arg3.as_ptr().cast::<*mut u8>().read().cast(), len3, len3) - }; - V5::KvCbor(e5) - } - n => { - debug_assert_eq!(n, 6, "invalid enum discriminant"); - let e5 = { - let len4 = arg4; - let bytes4 = _rt::Vec::from_raw_parts(arg3.as_ptr().cast::<*mut u8>().read().cast(), len4, len4); - - _rt::string_lift(bytes4) - }; - V5::KvJson(e5) - } - }; - T::kv_update(_rt::string_lift(bytes0), v5); - } - pub trait Guest { - /// A Subscribed key has updated. - /// - /// This will only ever be called if the module has subscribed to updates using - /// `kv-subscribe` - /// - /// Returns: - /// Nothing. - fn kv_update(key: _rt::String,value: KvValues,); - } - #[doc(hidden)] - - macro_rules! __export_hermes_kv_store_event_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "hermes:kv-store/event#kv-update"] - unsafe extern "C" fn export_kv_update(arg0: *mut u8,arg1: usize,arg2: i32,arg3: ::core::mem::MaybeUninit::,arg4: usize,) { - $($path_to_types)*::_export_kv_update_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4) - } - };); - } - #[doc(hidden)] - pub(crate) use __export_hermes_kv_store_event_cabi; - -} - -} -} -#[allow(dead_code)] -pub mod wasi { - #[allow(dead_code)] - pub mod http { - #[allow(dead_code, clippy::all)] - pub mod incoming_handler { - #[used] - #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; - use super::super::super::super::_rt; - pub type IncomingRequest = super::super::super::super::wasi::http::types::IncomingRequest; - pub type ResponseOutparam = super::super::super::super::wasi::http::types::ResponseOutparam; - #[doc(hidden)] - #[allow(non_snake_case)] - pub unsafe fn _export_handle_cabi(arg0: i32,arg1: i32,) {#[cfg(target_arch="wasm32")] - _rt::run_ctors_once();T::handle(super::super::super::super::wasi::http::types::IncomingRequest::from_handle(arg0 as u32), super::super::super::super::wasi::http::types::ResponseOutparam::from_handle(arg1 as u32)); - } - pub trait Guest { - /// This function is invoked with an incoming HTTP Request, and a resource - /// `response-outparam` which provides the capability to reply with an HTTP - /// Response. The response is sent by calling the `response-outparam.set` - /// method, which allows execution to continue after the response has been - /// sent. This enables both streaming to the response body, and performing other - /// work. - /// - /// The implementor of this function must write a response to the - /// `response-outparam` before returning, or else the caller will respond - /// with an error on its behalf. - fn handle(request: IncomingRequest,response_out: ResponseOutparam,); - } - #[doc(hidden)] - - macro_rules! __export_wasi_http_incoming_handler_0_2_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "wasi:http/incoming-handler@0.2.0#handle"] - unsafe extern "C" fn export_handle(arg0: i32,arg1: i32,) { - $($path_to_types)*::_export_handle_cabi::<$ty>(arg0, arg1) - } - };); - } - #[doc(hidden)] - pub(crate) use __export_wasi_http_incoming_handler_0_2_0_cabi; - - } - -} -} -} -mod _rt { - pub use alloc_crate::vec::Vec; - pub use alloc_crate::string::String; - pub unsafe fn string_lift(bytes: Vec) -> String { - if cfg!(debug_assertions) { - String::from_utf8(bytes).unwrap() - } else { - String::from_utf8_unchecked(bytes) - } - } - pub unsafe fn cabi_dealloc(ptr: *mut u8, size: usize, align: usize) { - if size == 0 { - return; - } - let layout = alloc::Layout::from_size_align_unchecked(size, align); - alloc::dealloc(ptr, layout); - } - pub unsafe fn invalid_enum_discriminant() -> T { - if cfg!(debug_assertions) { - panic!("invalid enum discriminant") - } else { - core::hint::unreachable_unchecked() - } - } - - - use core::fmt; - use core::marker; - use core::sync::atomic::{AtomicU32, Ordering::Relaxed}; - - /// A type which represents a component model resource, either imported or - /// exported into this component. - /// - /// This is a low-level wrapper which handles the lifetime of the resource - /// (namely this has a destructor). The `T` provided defines the component model - /// intrinsics that this wrapper uses. - /// - /// One of the chief purposes of this type is to provide `Deref` implementations - /// to access the underlying data when it is owned. - /// - /// This type is primarily used in generated code for exported and imported - /// resources. - #[repr(transparent)] - pub struct Resource { - // NB: This would ideally be `u32` but it is not. The fact that this has - // interior mutability is not exposed in the API of this type except for the - // `take_handle` method which is supposed to in theory be private. - // - // This represents, almost all the time, a valid handle value. When it's - // invalid it's stored as `u32::MAX`. - handle: AtomicU32, - _marker: marker::PhantomData, - } - - /// A trait which all wasm resources implement, namely providing the ability to - /// drop a resource. - /// - /// This generally is implemented by generated code, not user-facing code. - #[allow(clippy::missing_safety_doc)] - pub unsafe trait WasmResource { - /// Invokes the `[resource-drop]...` intrinsic. - unsafe fn drop(handle: u32); - } - - impl Resource { - #[doc(hidden)] - pub unsafe fn from_handle(handle: u32) -> Self { - debug_assert!(handle != u32::MAX); - Self { - handle: AtomicU32::new(handle), - _marker: marker::PhantomData, - } - } - - /// Takes ownership of the handle owned by `resource`. - /// - /// Note that this ideally would be `into_handle` taking `Resource` by - /// ownership. The code generator does not enable that in all situations, - /// unfortunately, so this is provided instead. - /// - /// Also note that `take_handle` is in theory only ever called on values - /// owned by a generated function. For example a generated function might - /// take `Resource` as an argument but then call `take_handle` on a - /// reference to that argument. In that sense the dynamic nature of - /// `take_handle` should only be exposed internally to generated code, not - /// to user code. - #[doc(hidden)] - pub fn take_handle(resource: &Resource) -> u32 { - resource.handle.swap(u32::MAX, Relaxed) - } - - #[doc(hidden)] - pub fn handle(resource: &Resource) -> u32 { - resource.handle.load(Relaxed) - } - } - - impl fmt::Debug for Resource { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Resource") - .field("handle", &self.handle) - .finish() - } - } - - impl Drop for Resource { - fn drop(&mut self) { - unsafe { - match self.handle.load(Relaxed) { - // If this handle was "taken" then don't do anything in the - // destructor. - u32::MAX => {} - - // ... but otherwise do actually destroy it with the imported - // component model intrinsic as defined through `T`. - other => T::drop(other), - } - } - } - } - - pub fn as_i64(t: T) -> i64 { - t.as_i64() - } - - pub trait AsI64 { - fn as_i64(self) -> i64; - } - - impl<'a, T: Copy + AsI64> AsI64 for &'a T { - fn as_i64(self) -> i64 { - (*self).as_i64() - } - } - - impl AsI64 for i64 { - #[inline] - fn as_i64(self) -> i64 { - self as i64 - } - } - - impl AsI64 for u64 { - #[inline] - fn as_i64(self) -> i64 { - self as i64 - } - } - - pub fn as_i32(t: T) -> i32 { - t.as_i32() - } - - pub trait AsI32 { - fn as_i32(self) -> i32; - } - - impl<'a, T: Copy + AsI32> AsI32 for &'a T { - fn as_i32(self) -> i32 { - (*self).as_i32() - } - } - - impl AsI32 for i32 { - #[inline] - fn as_i32(self) -> i32 { - self as i32 - } - } - - impl AsI32 for u32 { - #[inline] - fn as_i32(self) -> i32 { - self as i32 - } - } - - impl AsI32 for i16 { - #[inline] - fn as_i32(self) -> i32 { - self as i32 - } - } - - impl AsI32 for u16 { - #[inline] - fn as_i32(self) -> i32 { - self as i32 - } - } - - impl AsI32 for i8 { - #[inline] - fn as_i32(self) -> i32 { - self as i32 - } - } - - impl AsI32 for u8 { - #[inline] - fn as_i32(self) -> i32 { - self as i32 - } - } - - impl AsI32 for char { - #[inline] - fn as_i32(self) -> i32 { - self as i32 - } - } - - impl AsI32 for usize { - #[inline] - fn as_i32(self) -> i32 { - self as i32 - } - } - 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 fn as_f64(t: T) -> f64 { - t.as_f64() - } - - pub trait AsF64 { - fn as_f64(self) -> f64; - } - - impl<'a, T: Copy + AsF64> AsF64 for &'a T { - fn as_f64(self) -> f64 { - (*self).as_f64() - } - } - - impl AsF64 for f64 { - #[inline] - fn as_f64(self) -> f64 { - self as f64 - } - } - - #[cfg(target_arch = "wasm32")] - pub fn run_ctors_once() { - wit_bindgen::rt::run_ctors_once(); - } - extern crate alloc as alloc_crate; -} - -/// Generates `#[no_mangle]` functions to export the specified type as the -/// root implementation of all generated traits. -/// -/// For more information see the documentation of `wit_bindgen::generate!`. -/// -/// ```rust -/// # macro_rules! export{ ($($t:tt)*) => (); } -/// # trait Guest {} -/// struct MyType; -/// -/// impl Guest for MyType { -/// // ... -/// } -/// -/// export!(MyType); -/// ``` -#[allow(unused_macros)] -#[doc(hidden)] - -macro_rules! __export_hermes_impl { - ($ty:ident) => (self::export!($ty with_types_in self);); - ($ty:ident with_types_in $($path_to_types_root:tt)*) => ( - $($path_to_types_root)*::exports::wasi::http::incoming_handler::__export_wasi_http_incoming_handler_0_2_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::wasi::http::incoming_handler); - $($path_to_types_root)*::exports::hermes::cardano::event_on_block::__export_hermes_cardano_event_on_block_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::cardano::event_on_block); - $($path_to_types_root)*::exports::hermes::cardano::event_on_txn::__export_hermes_cardano_event_on_txn_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::cardano::event_on_txn); - $($path_to_types_root)*::exports::hermes::cardano::event_on_rollback::__export_hermes_cardano_event_on_rollback_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::cardano::event_on_rollback); - $($path_to_types_root)*::exports::hermes::cron::event::__export_hermes_cron_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::cron::event); - $($path_to_types_root)*::exports::hermes::init::event::__export_hermes_init_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::init::event); - $($path_to_types_root)*::exports::hermes::ipfs::event::__export_hermes_ipfs_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::ipfs::event); - $($path_to_types_root)*::exports::hermes::kv_store::event::__export_hermes_kv_store_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::kv_store::event); - $($path_to_types_root)*::exports::hermes::integration_test::event::__export_hermes_integration_test_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::integration_test::event); - $($path_to_types_root)*::exports::hermes::http_gateway::event::__export_hermes_http_gateway_event_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::http_gateway::event); - $($path_to_types_root)*::exports::hermes::http_request::event_on_http_response::__export_hermes_http_request_event_on_http_response_cabi!($ty with_types_in $($path_to_types_root)*::exports::hermes::http_request::event_on_http_response); - ) -} -#[doc(inline)] -pub(crate) use __export_hermes_impl as export; - -#[cfg(target_arch = "wasm32")] -#[link_section = "component-type:wit-bindgen:0.29.0:hermes:encoded world"] -#[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 16343] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xda~\x01A\x02\x01Ak\x01\ -B\x0a\x01o\x02ss\x01p\0\x01@\0\0\x01\x04\0\x0fget-environment\x01\x02\x01ps\x01@\ -\0\0\x03\x04\0\x0dget-arguments\x01\x04\x01ks\x01@\0\0\x05\x04\0\x0binitial-cwd\x01\ -\x06\x03\x01\x1awasi:cli/environment@0.2.0\x05\0\x01B\x03\x01j\0\0\x01@\x01\x06s\ -tatus\0\x01\0\x04\0\x04exit\x01\x01\x03\x01\x13wasi:cli/exit@0.2.0\x05\x01\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\x02\x02\x03\0\x02\x05er\ -ror\x01B!\x02\x03\x02\x01\x03\x04\0\x05error\x03\0\0\x01i\x01\x01q\x02\x15last-o\ -peration-failed\x01\x02\0\x06closed\0\0\x04\0\x0cstream-error\x03\0\x03\x04\0\x0c\ -input-stream\x03\x01\x04\0\x0doutput-stream\x03\x01\x01h\x05\x01p}\x01j\x01\x08\x01\ -\x04\x01@\x02\x04self\x07\x03lenw\0\x09\x04\0\x19[method]input-stream.read\x01\x0a\ -\x04\0\"[method]input-stream.blocking-read\x01\x0a\x01j\x01w\x01\x04\x01@\x02\x04\ -self\x07\x03lenw\0\x0b\x04\0\x19[method]input-stream.skip\x01\x0c\x04\0\"[method\ -]input-stream.blocking-skip\x01\x0c\x01h\x06\x01@\x01\x04self\x0d\0\x0b\x04\0![m\ -ethod]output-stream.check-write\x01\x0e\x01j\0\x01\x04\x01@\x02\x04self\x0d\x08c\ -ontents\x08\0\x0f\x04\0\x1b[method]output-stream.write\x01\x10\x04\0.[method]out\ -put-stream.blocking-write-and-flush\x01\x10\x01@\x01\x04self\x0d\0\x0f\x04\0\x1b\ -[method]output-stream.flush\x01\x11\x04\0$[method]output-stream.blocking-flush\x01\ -\x11\x01@\x02\x04self\x0d\x03lenw\0\x0f\x04\0\"[method]output-stream.write-zeroe\ -s\x01\x12\x04\05[method]output-stream.blocking-write-zeroes-and-flush\x01\x12\x01\ -@\x03\x04self\x0d\x03src\x07\x03lenw\0\x0b\x04\0\x1c[method]output-stream.splice\ -\x01\x13\x04\0%[method]output-stream.blocking-splice\x01\x13\x03\x01\x15wasi:io/\ -streams@0.2.0\x05\x04\x02\x03\0\x03\x0cinput-stream\x01B\x05\x02\x03\x02\x01\x05\ -\x04\0\x0cinput-stream\x03\0\0\x01i\x01\x01@\0\0\x02\x04\0\x09get-stdin\x01\x03\x03\ -\x01\x14wasi:cli/stdin@0.2.0\x05\x06\x02\x03\0\x03\x0doutput-stream\x01B\x05\x02\ -\x03\x02\x01\x07\x04\0\x0doutput-stream\x03\0\0\x01i\x01\x01@\0\0\x02\x04\0\x0ag\ -et-stdout\x01\x03\x03\x01\x15wasi:cli/stdout@0.2.0\x05\x08\x01B\x05\x02\x03\x02\x01\ -\x07\x04\0\x0doutput-stream\x03\0\0\x01i\x01\x01@\0\0\x02\x04\0\x0aget-stderr\x01\ -\x03\x03\x01\x15wasi:cli/stderr@0.2.0\x05\x09\x01B\x08\x01w\x04\0\x07instant\x03\ -\0\0\x01w\x04\0\x08duration\x03\0\x02\x01@\0\0\x01\x04\0\x03now\x01\x04\x01@\0\0\ -\x03\x04\0\x0aresolution\x01\x05\x03\x01!wasi:clocks/monotonic-clock@0.2.0\x05\x0a\ -\x01B\x05\x01r\x02\x07secondsw\x0bnanosecondsy\x04\0\x08datetime\x03\0\0\x01@\0\0\ -\x01\x04\0\x03now\x01\x02\x04\0\x0aresolution\x01\x02\x03\x01\x1cwasi:clocks/wal\ -l-clock@0.2.0\x05\x0b\x02\x03\0\x03\x05error\x02\x03\0\x08\x08datetime\x01Br\x02\ -\x03\x02\x01\x05\x04\0\x0cinput-stream\x03\0\0\x02\x03\x02\x01\x07\x04\0\x0doutp\ -ut-stream\x03\0\x02\x02\x03\x02\x01\x0c\x04\0\x05error\x03\0\x04\x02\x03\x02\x01\ -\x0d\x04\0\x08datetime\x03\0\x06\x01w\x04\0\x08filesize\x03\0\x08\x01m\x08\x07un\ -known\x0cblock-device\x10character-device\x09directory\x04fifo\x0dsymbolic-link\x0c\ -regular-file\x06socket\x04\0\x0fdescriptor-type\x03\0\x0a\x01n\x06\x04read\x05wr\ -ite\x13file-integrity-sync\x13data-integrity-sync\x14requested-write-sync\x10mut\ -ate-directory\x04\0\x10descriptor-flags\x03\0\x0c\x01n\x01\x0esymlink-follow\x04\ -\0\x0apath-flags\x03\0\x0e\x01n\x04\x06create\x09directory\x09exclusive\x08trunc\ -ate\x04\0\x0aopen-flags\x03\0\x10\x01w\x04\0\x0alink-count\x03\0\x12\x01k\x07\x01\ -r\x06\x04type\x0b\x0alink-count\x13\x04size\x09\x15data-access-timestamp\x14\x1b\ -data-modification-timestamp\x14\x17status-change-timestamp\x14\x04\0\x0fdescript\ -or-stat\x03\0\x15\x01q\x03\x09no-change\0\0\x03now\0\0\x09timestamp\x01\x07\0\x04\ -\0\x0dnew-timestamp\x03\0\x17\x01r\x02\x04type\x0b\x04names\x04\0\x0fdirectory-e\ -ntry\x03\0\x19\x01m%\x06access\x0bwould-block\x07already\x0ebad-descriptor\x04bu\ -sy\x08deadlock\x05quota\x05exist\x0efile-too-large\x15illegal-byte-sequence\x0bi\ -n-progress\x0binterrupted\x07invalid\x02io\x0cis-directory\x04loop\x0etoo-many-l\ -inks\x0cmessage-size\x0dname-too-long\x09no-device\x08no-entry\x07no-lock\x13ins\ -ufficient-memory\x12insufficient-space\x0dnot-directory\x09not-empty\x0fnot-reco\ -verable\x0bunsupported\x06no-tty\x0eno-such-device\x08overflow\x0dnot-permitted\x04\ -pipe\x09read-only\x0cinvalid-seek\x0etext-file-busy\x0ccross-device\x04\0\x0aerr\ -or-code\x03\0\x1b\x01m\x06\x06normal\x0asequential\x06random\x09will-need\x09don\ -t-need\x08no-reuse\x04\0\x06advice\x03\0\x1d\x01r\x02\x05lowerw\x05upperw\x04\0\x13\ -metadata-hash-value\x03\0\x1f\x04\0\x0adescriptor\x03\x01\x04\0\x16directory-ent\ -ry-stream\x03\x01\x01h!\x01i\x01\x01j\x01$\x01\x1c\x01@\x02\x04self#\x06offset\x09\ -\0%\x04\0\"[method]descriptor.read-via-stream\x01&\x01i\x03\x01j\x01'\x01\x1c\x01\ -@\x02\x04self#\x06offset\x09\0(\x04\0#[method]descriptor.write-via-stream\x01)\x01\ -@\x01\x04self#\0(\x04\0$[method]descriptor.append-via-stream\x01*\x01j\0\x01\x1c\ -\x01@\x04\x04self#\x06offset\x09\x06length\x09\x06advice\x1e\0+\x04\0\x19[method\ -]descriptor.advise\x01,\x01@\x01\x04self#\0+\x04\0\x1c[method]descriptor.sync-da\ -ta\x01-\x01j\x01\x0d\x01\x1c\x01@\x01\x04self#\0.\x04\0\x1c[method]descriptor.ge\ -t-flags\x01/\x01j\x01\x0b\x01\x1c\x01@\x01\x04self#\00\x04\0\x1b[method]descript\ -or.get-type\x011\x01@\x02\x04self#\x04size\x09\0+\x04\0\x1b[method]descriptor.se\ -t-size\x012\x01@\x03\x04self#\x15data-access-timestamp\x18\x1bdata-modification-\ -timestamp\x18\0+\x04\0\x1c[method]descriptor.set-times\x013\x01p}\x01o\x024\x7f\x01\ -j\x015\x01\x1c\x01@\x03\x04self#\x06length\x09\x06offset\x09\06\x04\0\x17[method\ -]descriptor.read\x017\x01j\x01\x09\x01\x1c\x01@\x03\x04self#\x06buffer4\x06offse\ -t\x09\08\x04\0\x18[method]descriptor.write\x019\x01i\"\x01j\x01:\x01\x1c\x01@\x01\ -\x04self#\0;\x04\0![method]descriptor.read-directory\x01<\x04\0\x17[method]descr\ -iptor.sync\x01-\x01@\x02\x04self#\x04paths\0+\x04\0&[method]descriptor.create-di\ -rectory-at\x01=\x01j\x01\x16\x01\x1c\x01@\x01\x04self#\0>\x04\0\x17[method]descr\ -iptor.stat\x01?\x01@\x03\x04self#\x0apath-flags\x0f\x04paths\0>\x04\0\x1a[method\ -]descriptor.stat-at\x01@\x01@\x05\x04self#\x0apath-flags\x0f\x04paths\x15data-ac\ -cess-timestamp\x18\x1bdata-modification-timestamp\x18\0+\x04\0\x1f[method]descri\ -ptor.set-times-at\x01A\x01@\x05\x04self#\x0eold-path-flags\x0f\x08old-paths\x0en\ -ew-descriptor#\x08new-paths\0+\x04\0\x1a[method]descriptor.link-at\x01B\x01i!\x01\ -j\x01\xc3\0\x01\x1c\x01@\x05\x04self#\x0apath-flags\x0f\x04paths\x0aopen-flags\x11\ -\x05flags\x0d\0\xc4\0\x04\0\x1a[method]descriptor.open-at\x01E\x01j\x01s\x01\x1c\ -\x01@\x02\x04self#\x04paths\0\xc6\0\x04\0\x1e[method]descriptor.readlink-at\x01G\ -\x04\0&[method]descriptor.remove-directory-at\x01=\x01@\x04\x04self#\x08old-path\ -s\x0enew-descriptor#\x08new-paths\0+\x04\0\x1c[method]descriptor.rename-at\x01H\x01\ -@\x03\x04self#\x08old-paths\x08new-paths\0+\x04\0\x1d[method]descriptor.symlink-\ -at\x01I\x04\0![method]descriptor.unlink-file-at\x01=\x01@\x02\x04self#\x05other#\ -\0\x7f\x04\0![method]descriptor.is-same-object\x01J\x01j\x01\x20\x01\x1c\x01@\x01\ -\x04self#\0\xcb\0\x04\0\x20[method]descriptor.metadata-hash\x01L\x01@\x03\x04sel\ -f#\x0apath-flags\x0f\x04paths\0\xcb\0\x04\0#[method]descriptor.metadata-hash-at\x01\ -M\x01h\"\x01k\x1a\x01j\x01\xcf\0\x01\x1c\x01@\x01\x04self\xce\0\0\xd0\0\x04\03[m\ -ethod]directory-entry-stream.read-directory-entry\x01Q\x01h\x05\x01k\x1c\x01@\x01\ -\x03err\xd2\0\0\xd3\0\x04\0\x15filesystem-error-code\x01T\x03\x01\x1bwasi:filesy\ -stem/types@0.2.0\x05\x0e\x02\x03\0\x09\x0adescriptor\x01B\x07\x02\x03\x02\x01\x0f\ -\x04\0\x0adescriptor\x03\0\0\x01i\x01\x01o\x02\x02s\x01p\x03\x01@\0\0\x04\x04\0\x0f\ -get-directories\x01\x05\x03\x01\x1ewasi:filesystem/preopens@0.2.0\x05\x10\x01B\x05\ -\x01p}\x01@\x01\x03lenw\0\0\x04\0\x10get-random-bytes\x01\x01\x01@\0\0w\x04\0\x0e\ -get-random-u64\x01\x02\x03\x01\x18wasi:random/random@0.2.0\x05\x11\x01B\x05\x01p\ -}\x01@\x01\x03lenw\0\0\x04\0\x19get-insecure-random-bytes\x01\x01\x01@\0\0w\x04\0\ -\x17get-insecure-random-u64\x01\x02\x03\x01\x1awasi:random/insecure@0.2.0\x05\x12\ -\x01B\x03\x01o\x02ww\x01@\0\0\0\x04\0\x0dinsecure-seed\x01\x01\x03\x01\x1fwasi:r\ -andom/insecure-seed@0.2.0\x05\x13\x02\x03\0\x07\x08duration\x01B\xb9\x01\x02\x03\ -\x02\x01\x14\x04\0\x08duration\x03\0\0\x02\x03\x02\x01\x05\x04\0\x0cinput-stream\ -\x03\0\x02\x02\x03\x02\x01\x07\x04\0\x0doutput-stream\x03\0\x04\x02\x03\x02\x01\x03\ -\x04\0\x08io-error\x03\0\x06\x01q\x0a\x03get\0\0\x04head\0\0\x04post\0\0\x03put\0\ -\0\x06delete\0\0\x07connect\0\0\x07options\0\0\x05trace\0\0\x05patch\0\0\x05othe\ -r\x01s\0\x04\0\x06method\x03\0\x08\x01q\x03\x04HTTP\0\0\x05HTTPS\0\0\x05other\x01\ -s\0\x04\0\x06scheme\x03\0\x0a\x01ks\x01k{\x01r\x02\x05rcode\x0c\x09info-code\x0d\ -\x04\0\x11DNS-error-payload\x03\0\x0e\x01k}\x01r\x02\x08alert-id\x10\x0dalert-me\ -ssage\x0c\x04\0\x1aTLS-alert-received-payload\x03\0\x11\x01ky\x01r\x02\x0afield-\ -name\x0c\x0afield-size\x13\x04\0\x12field-size-payload\x03\0\x14\x01kw\x01k\x15\x01\ -q'\x0bDNS-timeout\0\0\x09DNS-error\x01\x0f\0\x15destination-not-found\0\0\x17des\ -tination-unavailable\0\0\x19destination-IP-prohibited\0\0\x19destination-IP-unro\ -utable\0\0\x12connection-refused\0\0\x15connection-terminated\0\0\x12connection-\ -timeout\0\0\x17connection-read-timeout\0\0\x18connection-write-timeout\0\0\x18co\ -nnection-limit-reached\0\0\x12TLS-protocol-error\0\0\x15TLS-certificate-error\0\0\ -\x12TLS-alert-received\x01\x12\0\x13HTTP-request-denied\0\0\x1cHTTP-request-leng\ -th-required\0\0\x16HTTP-request-body-size\x01\x16\0\x1bHTTP-request-method-inval\ -id\0\0\x18HTTP-request-URI-invalid\0\0\x19HTTP-request-URI-too-long\0\0\x20HTTP-\ -request-header-section-size\x01\x13\0\x18HTTP-request-header-size\x01\x17\0!HTTP\ --request-trailer-section-size\x01\x13\0\x19HTTP-request-trailer-size\x01\x15\0\x18\ -HTTP-response-incomplete\0\0!HTTP-response-header-section-size\x01\x13\0\x19HTTP\ --response-header-size\x01\x15\0\x17HTTP-response-body-size\x01\x16\0\"HTTP-respo\ -nse-trailer-section-size\x01\x13\0\x1aHTTP-response-trailer-size\x01\x15\0\x1dHT\ -TP-response-transfer-coding\x01\x0c\0\x1cHTTP-response-content-coding\x01\x0c\0\x15\ -HTTP-response-timeout\0\0\x13HTTP-upgrade-failed\0\0\x13HTTP-protocol-error\0\0\x0d\ -loop-detected\0\0\x13configuration-error\0\0\x0einternal-error\x01\x0c\0\x04\0\x0a\ -error-code\x03\0\x18\x01q\x03\x0einvalid-syntax\0\0\x09forbidden\0\0\x09immutabl\ -e\0\0\x04\0\x0cheader-error\x03\0\x1a\x01s\x04\0\x09field-key\x03\0\x1c\x01p}\x04\ -\0\x0bfield-value\x03\0\x1e\x04\0\x06fields\x03\x01\x04\0\x07headers\x03\0\x20\x04\ -\0\x08trailers\x03\0\x20\x04\0\x10incoming-request\x03\x01\x04\0\x10outgoing-req\ -uest\x03\x01\x04\0\x0frequest-options\x03\x01\x04\0\x11response-outparam\x03\x01\ -\x01{\x04\0\x0bstatus-code\x03\0'\x04\0\x11incoming-response\x03\x01\x04\0\x0din\ -coming-body\x03\x01\x04\0\x0ffuture-trailers\x03\x01\x04\0\x11outgoing-response\x03\ -\x01\x04\0\x0doutgoing-body\x03\x01\x04\0\x18future-incoming-response\x03\x01\x01\ -i\x20\x01@\0\0/\x04\0\x13[constructor]fields\x010\x01o\x02\x1d\x1f\x01p1\x01j\x01\ -/\x01\x1b\x01@\x01\x07entries2\03\x04\0\x18[static]fields.from-list\x014\x01h\x20\ -\x01p\x1f\x01@\x02\x04self5\x04name\x1d\06\x04\0\x12[method]fields.get\x017\x01@\ -\x02\x04self5\x04name\x1d\0\x7f\x04\0\x12[method]fields.has\x018\x01j\0\x01\x1b\x01\ -@\x03\x04self5\x04name\x1d\x05value6\09\x04\0\x12[method]fields.set\x01:\x01@\x02\ -\x04self5\x04name\x1d\09\x04\0\x15[method]fields.delete\x01;\x01@\x03\x04self5\x04\ -name\x1d\x05value\x1f\09\x04\0\x15[method]fields.append\x01<\x01@\x01\x04self5\0\ -2\x04\0\x16[method]fields.entries\x01=\x01@\x01\x04self5\0/\x04\0\x14[method]fie\ -lds.clone\x01>\x01h#\x01@\x01\x04self?\0\x09\x04\0\x1f[method]incoming-request.m\ -ethod\x01@\x01@\x01\x04self?\0\x0c\x04\0([method]incoming-request.path-with-quer\ -y\x01A\x01k\x0b\x01@\x01\x04self?\0\xc2\0\x04\0\x1f[method]incoming-request.sche\ -me\x01C\x04\0\"[method]incoming-request.authority\x01A\x01i!\x01@\x01\x04self?\0\ -\xc4\0\x04\0\x20[method]incoming-request.headers\x01E\x01i*\x01j\x01\xc6\0\0\x01\ -@\x01\x04self?\0\xc7\0\x04\0\x20[method]incoming-request.consume\x01H\x01i$\x01@\ -\x01\x07headers\xc4\0\0\xc9\0\x04\0\x1d[constructor]outgoing-request\x01J\x01h$\x01\ -i-\x01j\x01\xcc\0\0\x01@\x01\x04self\xcb\0\0\xcd\0\x04\0\x1d[method]outgoing-req\ -uest.body\x01N\x01@\x01\x04self\xcb\0\0\x09\x04\0\x1f[method]outgoing-request.me\ -thod\x01O\x01j\0\0\x01@\x02\x04self\xcb\0\x06method\x09\0\xd0\0\x04\0#[method]ou\ -tgoing-request.set-method\x01Q\x01@\x01\x04self\xcb\0\0\x0c\x04\0([method]outgoi\ -ng-request.path-with-query\x01R\x01@\x02\x04self\xcb\0\x0fpath-with-query\x0c\0\xd0\ -\0\x04\0,[method]outgoing-request.set-path-with-query\x01S\x01@\x01\x04self\xcb\0\ -\0\xc2\0\x04\0\x1f[method]outgoing-request.scheme\x01T\x01@\x02\x04self\xcb\0\x06\ -scheme\xc2\0\0\xd0\0\x04\0#[method]outgoing-request.set-scheme\x01U\x04\0\"[meth\ -od]outgoing-request.authority\x01R\x01@\x02\x04self\xcb\0\x09authority\x0c\0\xd0\ -\0\x04\0&[method]outgoing-request.set-authority\x01V\x01@\x01\x04self\xcb\0\0\xc4\ -\0\x04\0\x20[method]outgoing-request.headers\x01W\x01i%\x01@\0\0\xd8\0\x04\0\x1c\ -[constructor]request-options\x01Y\x01h%\x01k\x01\x01@\x01\x04self\xda\0\0\xdb\0\x04\ -\0'[method]request-options.connect-timeout\x01\\\x01@\x02\x04self\xda\0\x08durat\ -ion\xdb\0\0\xd0\0\x04\0+[method]request-options.set-connect-timeout\x01]\x04\0*[\ -method]request-options.first-byte-timeout\x01\\\x04\0.[method]request-options.se\ -t-first-byte-timeout\x01]\x04\0-[method]request-options.between-bytes-timeout\x01\ -\\\x04\01[method]request-options.set-between-bytes-timeout\x01]\x01i&\x01i,\x01j\ -\x01\xdf\0\x01\x19\x01@\x02\x05param\xde\0\x08response\xe0\0\x01\0\x04\0\x1d[sta\ -tic]response-outparam.set\x01a\x01h)\x01@\x01\x04self\xe2\0\0(\x04\0\x20[method]\ -incoming-response.status\x01c\x01@\x01\x04self\xe2\0\0\xc4\0\x04\0![method]incom\ -ing-response.headers\x01d\x01@\x01\x04self\xe2\0\0\xc7\0\x04\0![method]incoming-\ -response.consume\x01e\x01h*\x01i\x03\x01j\x01\xe7\0\0\x01@\x01\x04self\xe6\0\0\xe8\ -\0\x04\0\x1c[method]incoming-body.stream\x01i\x01i+\x01@\x01\x04this\xc6\0\0\xea\ -\0\x04\0\x1c[static]incoming-body.finish\x01k\x01h+\x01i\"\x01k\xed\0\x01j\x01\xee\ -\0\x01\x19\x01j\x01\xef\0\0\x01k\xf0\0\x01@\x01\x04self\xec\0\0\xf1\0\x04\0\x1b[\ -method]future-trailers.get\x01r\x01@\x01\x07headers\xc4\0\0\xdf\0\x04\0\x1e[cons\ -tructor]outgoing-response\x01s\x01h,\x01@\x01\x04self\xf4\0\0(\x04\0%[method]out\ -going-response.status-code\x01u\x01@\x02\x04self\xf4\0\x0bstatus-code(\0\xd0\0\x04\ -\0)[method]outgoing-response.set-status-code\x01v\x01@\x01\x04self\xf4\0\0\xc4\0\ -\x04\0![method]outgoing-response.headers\x01w\x01@\x01\x04self\xf4\0\0\xcd\0\x04\ -\0\x1e[method]outgoing-response.body\x01x\x01h-\x01i\x05\x01j\x01\xfa\0\0\x01@\x01\ -\x04self\xf9\0\0\xfb\0\x04\0\x1b[method]outgoing-body.write\x01|\x01j\0\x01\x19\x01\ -@\x02\x04this\xcc\0\x08trailers\xee\0\0\xfd\0\x04\0\x1c[static]outgoing-body.fin\ -ish\x01~\x01h.\x01i)\x01j\x01\x80\x01\x01\x19\x01j\x01\x81\x01\0\x01k\x82\x01\x01\ -@\x01\x04self\xff\0\0\x83\x01\x04\0$[method]future-incoming-response.get\x01\x84\ -\x01\x01h\x07\x01k\x19\x01@\x01\x03err\x85\x01\0\x86\x01\x04\0\x0fhttp-error-cod\ -e\x01\x87\x01\x03\x01\x15wasi:http/types@0.2.0\x05\x15\x02\x03\0\x0e\x10outgoing\ --request\x02\x03\0\x0e\x0frequest-options\x02\x03\0\x0e\x18future-incoming-respo\ -nse\x02\x03\0\x0e\x0aerror-code\x01B\x0f\x02\x03\x02\x01\x16\x04\0\x10outgoing-r\ -equest\x03\0\0\x02\x03\x02\x01\x17\x04\0\x0frequest-options\x03\0\x02\x02\x03\x02\ -\x01\x18\x04\0\x18future-incoming-response\x03\0\x04\x02\x03\x02\x01\x19\x04\0\x0a\ -error-code\x03\0\x06\x01i\x01\x01i\x03\x01k\x09\x01i\x05\x01j\x01\x0b\x01\x07\x01\ -@\x02\x07request\x08\x07options\x0a\0\x0c\x04\0\x06handle\x01\x0d\x03\x01\x20was\ -i:http/outgoing-handler@0.2.0\x05\x1a\x01B\x08\x01p}\x04\0\x04bstr\x03\0\0\x01o\x02\ -ww\x04\0\x04b128\x03\0\x02\x01o\x04wwww\x04\0\x04b256\x03\0\x04\x01o\x08wwwwwwww\ -\x04\0\x04b512\x03\0\x06\x03\x01\x11hermes:binary/api\x05\x1b\x02\x03\0\x10\x04b\ -str\x01B\x03\x02\x03\x02\x01\x1c\x04\0\x04bstr\x03\0\0\x04\0\x04cbor\x03\0\x01\x03\ -\x01\x0fhermes:cbor/api\x05\x1d\x02\x03\0\x11\x04cbor\x01B$\x02\x03\x02\x01\x1c\x04\ -\0\x04bstr\x03\0\0\x02\x03\x02\x01\x1e\x04\0\x04cbor\x03\0\x02\x04\0\x0dcardano-\ -block\x03\0\x03\x04\0\x0bcardano-txn\x03\0\x03\x01m\x04\x07mainnet\x07preprod\x07\ -preview\x15local-test-blockchain\x04\0\x15cardano-blockchain-id\x03\0\x06\x01n\x03\ -\x03tip\x04node\x07mithril\x04\0\x09block-src\x03\0\x08\x01o\x02w\x01\x01q\x04\x07\ -genesis\0\0\x05point\x01\x0a\0\x03tip\0\0\x08continue\0\0\x04\0\x04slot\x03\0\x0b\ -\x01m\x02\x18blockchain-not-available\x0cinvalid-slot\x04\0\x0bfetch-error\x03\0\ -\x0d\x01m\x03\x18blockchain-not-available\x15malformed-transaction\x14post-txn-n\ -ot-allowed\x04\0\x09txn-error\x03\0\x0f\x01n\x04\x05block\x0btransaction\x08roll\ -back\x04stop\x04\0\x13unsubscribe-options\x03\0\x11\x01j\x01w\x01\x0e\x01@\x02\x03\ -net\x07\x06whence\x0c\0\x13\x04\0\x10subscribe-blocks\x01\x14\x01@\x02\x03net\x07\ -\x04opts\x12\x01\0\x04\0\x0bunsubscribe\x01\x15\x01@\x01\x03net\x07\x01\0\x04\0\x0d\ -subscribe-txn\x01\x16\x04\0\x12subscribe-rollback\x01\x16\x01j\x01\x04\x01\x0e\x01\ -@\x02\x03net\x07\x06whence\x0c\0\x17\x04\0\x0bfetch-block\x01\x18\x01p\x05\x01@\x01\ -\x05block\x04\0\x19\x04\0\x08get-txns\x01\x1a\x01j\0\x01\x10\x01@\x02\x03net\x07\ -\x03txn\x05\0\x1b\x04\0\x08post-txn\x01\x1c\x03\x01\x12hermes:cardano/api\x05\x1f\ -\x02\x03\0\x07\x07instant\x01B\x1a\x02\x03\x02\x01\x20\x04\0\x07instant\x03\0\0\x01\ -s\x04\0\x0ecron-event-tag\x03\0\x02\x01s\x04\0\x0acron-sched\x03\0\x04\x01r\x02\x04\ -when\x05\x03tag\x03\x04\0\x0bcron-tagged\x03\0\x06\x01o\x02}}\x01q\x03\x03all\0\0\ -\x02at\x01}\0\x05range\x01\x08\0\x04\0\x0ecron-component\x03\0\x09\x01p\x0a\x04\0\ -\x09cron-time\x03\0\x0b\x01@\x02\x05entry\x07\x09retrigger\x7f\0\x7f\x04\0\x03ad\ -d\x01\x0d\x01@\x02\x08duration\x01\x03tag\x03\0\x7f\x04\0\x05delay\x01\x0e\x01k\x03\ -\x01o\x02\x07\x7f\x01p\x10\x01@\x01\x03tag\x0f\0\x11\x04\0\x02ls\x01\x12\x01@\x01\ -\x05entry\x07\0\x7f\x04\0\x02rm\x01\x13\x01@\x05\x03dow\x0c\x05month\x0c\x03day\x0c\ -\x04hour\x0c\x06minute\x0c\0\x05\x04\0\x06mkcron\x01\x14\x03\x01\x0fhermes:cron/\ -api\x05!\x02\x03\0\x10\x04b256\x02\x03\0\x10\x04b512\x01B&\x02\x03\x02\x01\x1c\x04\ -\0\x04bstr\x03\0\0\x02\x03\x02\x01\"\x04\0\x04b256\x03\0\x02\x02\x03\x02\x01#\x04\ -\0\x04b512\x03\0\x04\x01m\x07\x0fprefix-too-long\x17invalid-mnemonic-length\x0ew\ -ord-not-found\x10invalid-mnemonic\x19invalid-derivational-path\x17generate-entro\ -py-failed\x14unsupported-language\x04\0\x05errno\x03\0\x06\x04\0\x19bip32-ed2551\ -9-private-key\x03\0\x03\x04\0\"bip32-ed25519-extended-private-key\x03\0\x05\x04\0\ -\x18bip32-ed25519-public-key\x03\0\x03\x04\0\x17bip32-ed25519-signature\x03\0\x05\ -\x01ps\x04\0\x0fmnemonic-phrase\x03\0\x0c\x01ps\x04\0\x0apassphrase\x03\0\x0e\x01\ -s\x04\0\x04path\x03\0\x10\x01ps\x04\0\x06prefix\x03\0\x12\x04\0\x0dbip32-ed25519\ -\x03\x01\x01k\x0f\x01i\x14\x01@\x02\x08mnemonic\x0d\x0apassphrase\x15\0\x16\x04\0\ -\x1a[constructor]bip32-ed25519\x01\x17\x01h\x14\x01@\x01\x04self\x18\0\x0a\x04\0\ -\x20[method]bip32-ed25519.public-key\x01\x19\x01@\x02\x04self\x18\x04data\x01\0\x0b\ -\x04\0\x1f[method]bip32-ed25519.sign-data\x01\x1a\x01@\x03\x04self\x18\x04data\x01\ -\x03sig\x0b\0\x7f\x04\0\x1f[method]bip32-ed25519.check-sig\x01\x1b\x01@\x02\x04s\ -elf\x18\x04path\x11\0\x16\x04\0\x1c[method]bip32-ed25519.derive\x01\x1c\x01ks\x01\ -j\x01\x0d\x01\x07\x01@\x03\x04size}\x06prefix\x13\x08language\x1d\0\x1e\x04\0\x11\ -generate-mnemonic\x01\x1f\x03\x01\x11hermes:crypto/api\x05$\x01B\x0f\x02\x03\x02\ -\x01\x1c\x04\0\x04bstr\x03\0\0\x01m\x05\x0bkey-too-big\x0chash-too-big\x0csalt-t\ -oo-big\x10personal-too-big\x1ainvalid-digest-byte-length\x04\0\x05errno\x03\0\x02\ -\x01k}\x01j\x01\x01\x01\x03\x01@\x02\x03buf\x01\x06outlen\x04\0\x05\x04\0\x07bla\ -ke2s\x01\x06\x01k\x01\x01@\x05\x03buf\x01\x06outlen\x04\x03key\x01\x04salt\x07\x08\ -personal\x07\0\x05\x04\0\x0ablake2smac\x01\x08\x04\0\x07blake2b\x01\x06\x04\0\x0a\ -blake2bmac\x01\x08\x01@\x03\x03buf\x01\x06outlen\x04\x03key\x07\0\x05\x04\0\x06b\ -lake3\x01\x09\x03\x01\x0fhermes:hash/api\x05%\x01B1\x01p}\x04\0\x07dht-key\x03\0\ -\0\x01p}\x04\0\x09dht-value\x03\0\x02\x01p}\x04\0\x09ipfs-file\x03\0\x04\x01s\x04\ -\0\x09ipfs-path\x03\0\x06\x01p}\x04\0\x0cmessage-data\x03\0\x08\x01p}\x04\0\x0am\ -essage-id\x03\0\x0a\x01s\x04\0\x07peer-id\x03\0\x0c\x01s\x04\0\x0cpubsub-topic\x03\ -\0\x0e\x01o\x02\x01\x03\x01o\x02\x0f\x09\x01q\x02\x03dht\x01\x10\0\x06pubsub\x01\ -\x11\0\x04\0\x0cipfs-content\x03\0\x12\x01k\x0d\x01r\x03\x05topic\x0f\x07message\ -\x09\x09publisher\x14\x04\0\x0epubsub-message\x03\0\x15\x01m\x0f\x0ddht-get-erro\ -r\x0ddht-put-error\x0efile-add-error\x0efile-get-error\x0efile-pin-error\x0binva\ -lid-cid\x0finvalid-dht-key\x11invalid-dht-value\x11invalid-ipfs-path\x0finvalid-\ -peer-id\x16invalid-pubsub-message\x13peer-eviction-error\x14pubsub-publish-error\ -\x16pubsub-subscribe-error\x13service-unavailable\x04\0\x05errno\x03\0\x17\x01j\x01\ -\x7f\x01\x18\x01@\x02\x03key\x01\x05value\x03\0\x19\x04\0\x07dht-put\x01\x1a\x01\ -j\x01\x03\x01\x18\x01@\x01\x03key\x01\0\x1b\x04\0\x07dht-get\x01\x1c\x01@\x01\x07\ -content\x13\0\x19\x04\0\x15ipfs-content-validate\x01\x1d\x01j\x01\x07\x01\x18\x01\ -@\x01\x08contents\x05\0\x1e\x04\0\x08file-add\x01\x1f\x01j\x01\x05\x01\x18\x01@\x01\ -\x04path\x07\0\x20\x04\0\x08file-get\x01!\x01@\x01\x04path\x07\0\x19\x04\0\x08fi\ -le-pin\x01\"\x04\0\x0afile-unpin\x01\"\x01@\x01\x04peer\x0d\0\x19\x04\0\x0apeer-\ -evict\x01#\x01j\x01\x0b\x01\x18\x01@\x02\x05topic\x0f\x07message\x09\0$\x04\0\x0e\ -pubsub-publish\x01%\x01@\x01\x05topic\x0f\0\x19\x04\0\x10pubsub-subscribe\x01&\x03\ -\x01\x0fhermes:ipfs/api\x05&\x01B\x02\x01s\x04\0\x04json\x03\0\0\x03\x01\x0fherm\ -es:json/api\x05'\x02\x03\0\x17\x04json\x01B\x16\x02\x03\x02\x01\x1c\x04\0\x04bst\ -r\x03\0\0\x02\x03\x02\x01\x1e\x04\0\x04cbor\x03\0\x02\x02\x03\x02\x01(\x04\0\x04\ -json\x03\0\x04\x01q\x07\x09kv-string\x01s\0\x06kv-s64\x01x\0\x06kv-u64\x01w\0\x06\ -kv-f64\x01u\0\x07kv-bstr\x01\x01\0\x07kv-cbor\x01\x03\0\x07kv-json\x01\x05\0\x04\ -\0\x09kv-values\x03\0\x06\x01k\x07\x01@\x02\x03keys\x05value\x08\x01\0\x04\0\x06\ -kv-set\x01\x09\x01@\x02\x03keys\x07default\x08\0\x08\x04\0\x0ekv-get-default\x01\ -\x0a\x01@\x01\x03keys\0\x08\x04\0\x06kv-get\x01\x0b\x01@\x02\x03keys\x05value\x08\ -\0\x08\x04\0\x0akv-get-set\x01\x0c\x04\0\x06kv-add\x01\x0c\x01@\x03\x03keys\x04t\ -est\x08\x05value\x08\0\x08\x04\0\x06kv-cas\x01\x0d\x04\0\x0ckv-subscribe\x01\x0b\ -\x04\0\x0ekv-unsubscribe\x01\x0b\x03\x01\x13hermes:kv-store/api\x05)\x01B\x12\x02\ -\x03\x02\x01\x0d\x04\0\x08datetime\x03\0\0\x01s\x04\0\x08timezone\x03\0\x02\x01r\ -\x09\x04yearw\x05month}\x03dow}\x03day}\x02hh}\x02mm}\x02ss}\x02nsy\x02tz\x03\x04\ -\0\x09localtime\x03\0\x04\x01m\x03\x11invalid-localtime\x10unknown-timezone\x11y\ -ear-out-of-range\x04\0\x05errno\x03\0\x06\x01k\x01\x01k\x03\x01j\x01\x05\x01\x07\ -\x01@\x02\x04when\x08\x02tz\x09\0\x0a\x04\0\x0dget-localtime\x01\x0b\x01@\x02\x04\ -time\x05\x02tz\x09\0\x0a\x04\0\x0dalt-localtime\x01\x0c\x01j\x01\x01\x01\x07\x01\ -@\x01\x04time\x05\0\x0d\x04\0\x0cget-datetime\x01\x0e\x03\x01\x14hermes:localtim\ -e/api\x05*\x01B\x09\x02\x03\x02\x01(\x04\0\x04json\x03\0\0\x01m\x05\x05debug\x05\ -trace\x04info\x04warn\x05error\x04\0\x05level\x03\0\x02\x01ks\x01ky\x01k\x01\x01\ -@\x08\x05level\x03\x04file\x04\x08function\x04\x04line\x05\x03col\x05\x03ctx\x04\ -\x03msgs\x04data\x06\x01\0\x04\0\x03log\x01\x07\x03\x01\x12hermes:logging/api\x05\ -+\x01B#\x01r\x02\x04codez\x07messages\x04\0\x0aerror-info\x03\0\0\x01q\x0b\x06sq\ -lite\x01z\0\x13converting-c-string\0\0\x18invalid-in-memory-config\0\0\x19invali\ -d-persistent-config\0\0+missing-database-name-for-persistent-config\0\0\x17faile\ -d-opening-database\0\0\x1cfailed-setting-database-size\0\0\x13unknown-column-typ\ -e\0\0\x18forbidden-pragma-command\0\0\x15returned-null-pointer\0\0\x12converting\ --numeric\0\0\x04\0\x05errno\x03\0\x02\x01p}\x01q\x06\x04blob\x01\x04\0\x06double\ -\x01u\0\x05int32\x01z\0\x05int64\x01x\0\x04null\0\0\x04text\x01s\0\x04\0\x05valu\ -e\x03\0\x05\x04\0\x06sqlite\x03\x01\x04\0\x09statement\x03\x01\x01h\x07\x01j\0\x01\ -\x03\x01@\x01\x04self\x09\0\x0a\x04\0\x14[method]sqlite.close\x01\x0b\x01k\x01\x01\ -@\x01\x04self\x09\0\x0c\x04\0\x16[method]sqlite.errcode\x01\x0d\x01i\x08\x01j\x01\ -\x0e\x01\x03\x01@\x02\x04self\x09\x03sqls\0\x0f\x04\0\x16[method]sqlite.prepare\x01\ -\x10\x01@\x02\x04self\x09\x03sqls\0\x0a\x04\0\x16[method]sqlite.execute\x01\x11\x01\ -h\x08\x01@\x03\x04self\x12\x05indexy\x05value\x06\0\x0a\x04\0\x16[method]stateme\ -nt.bind\x01\x13\x01@\x01\x04self\x12\0\x0a\x04\0\x16[method]statement.step\x01\x14\ -\x01j\x01\x06\x01\x03\x01@\x02\x04self\x12\x05indexy\0\x15\x04\0\x18[method]stat\ -ement.column\x01\x16\x04\0\x1a[method]statement.finalize\x01\x14\x01i\x07\x01j\x01\ -\x17\x01\x03\x01@\x02\x08readonly\x7f\x06memory\x7f\0\x18\x04\0\x04open\x01\x19\x03\ -\x01\x11hermes:sqlite/api\x05,\x01B\x09\x01m\x01\x08internal\x04\0\x0aerror-code\ -\x03\0\0\x01p}\x01ks\x01r\x04\x08host-uris\x04port{\x04body\x02\x0arequest-id\x03\ -\x04\0\x07payload\x03\0\x04\x01j\0\x01\x01\x01@\x01\x01p\x05\0\x06\x04\0\x04send\ -\x01\x07\x03\x01\x17hermes:http-request/api\x05-\x02\x03\0\x0e\x10incoming-reque\ -st\x02\x03\0\x0e\x11response-outparam\x01B\x08\x02\x03\x02\x01.\x04\0\x10incomin\ -g-request\x03\0\0\x02\x03\x02\x01/\x04\0\x11response-outparam\x03\0\x02\x01i\x01\ -\x01i\x03\x01@\x02\x07request\x04\x0cresponse-out\x05\x01\0\x04\0\x06handle\x01\x06\ -\x04\x01\x20wasi:http/incoming-handler@0.2.0\x050\x02\x03\0\x12\x15cardano-block\ -chain-id\x02\x03\0\x12\x0dcardano-block\x02\x03\0\x12\x09block-src\x01B\x08\x02\x03\ -\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\x02\x03\x02\x012\x04\0\x0dcarda\ -no-block\x03\0\x02\x02\x03\x02\x013\x04\0\x09block-src\x03\0\x04\x01@\x03\x0ablo\ -ckchain\x01\x05block\x03\x06source\x05\x01\0\x04\0\x10on-cardano-block\x01\x06\x04\ -\x01\x1dhermes:cardano/event-on-block\x054\x02\x03\0\x12\x0bcardano-txn\x01B\x06\ -\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\x02\x03\x02\x015\x04\0\x0b\ -cardano-txn\x03\0\x02\x01@\x04\x0ablockchain\x01\x04slotw\x09txn-indexy\x03txn\x03\ -\x01\0\x04\0\x0eon-cardano-txn\x01\x04\x04\x01\x1bhermes:cardano/event-on-txn\x05\ -6\x01B\x04\x02\x03\x02\x011\x04\0\x15cardano-blockchain-id\x03\0\0\x01@\x02\x0ab\ -lockchain\x01\x04slotw\x01\0\x04\0\x13on-cardano-rollback\x01\x02\x04\x01\x20her\ -mes:cardano/event-on-rollback\x057\x02\x03\0\x13\x0ecron-event-tag\x02\x03\0\x13\ -\x0bcron-tagged\x01B\x06\x02\x03\x02\x018\x04\0\x0ecron-event-tag\x03\0\0\x02\x03\ -\x02\x019\x04\0\x0bcron-tagged\x03\0\x02\x01@\x02\x05event\x03\x04last\x7f\0\x7f\ -\x04\0\x07on-cron\x01\x04\x04\x01\x11hermes:cron/event\x05:\x01B\x02\x01@\0\0\x7f\ -\x04\0\x04init\x01\0\x04\x01\x11hermes:init/event\x05;\x02\x03\0\x16\x0epubsub-m\ -essage\x01B\x04\x02\x03\x02\x01<\x04\0\x0epubsub-message\x03\0\0\x01@\x01\x07mes\ -sage\x01\0\x7f\x04\0\x08on-topic\x01\x02\x04\x01\x11hermes:ipfs/event\x05=\x02\x03\ -\0\x18\x09kv-values\x01B\x04\x02\x03\x02\x01>\x04\0\x09kv-values\x03\0\0\x01@\x02\ -\x03keys\x05value\x01\x01\0\x04\0\x09kv-update\x01\x02\x04\x01\x15hermes:kv-stor\ -e/event\x05?\x01B\x06\x01r\x02\x04names\x06status\x7f\x04\0\x0btest-result\x03\0\ -\0\x01k\x01\x01@\x02\x04testy\x03run\x7f\0\x02\x04\0\x04test\x01\x03\x04\0\x05be\ -nch\x01\x03\x04\x01\x1dhermes:integration-test/event\x05@\x01B\x0c\x02\x03\x02\x01\ -\x1c\x04\0\x04bstr\x03\0\0\x01ps\x01o\x02s\x02\x04\0\x06header\x03\0\x03\x01p\x04\ -\x04\0\x07headers\x03\0\x05\x01r\x03\x04code{\x07headers\x06\x04body\x01\x04\0\x0d\ -http-response\x03\0\x07\x01k\x08\x01@\x04\x04body\x01\x07headers\x06\x04paths\x06\ -methods\0\x09\x04\0\x05reply\x01\x0a\x04\x01\x19hermes:http-gateway/event\x05A\x01\ -B\x02\x01@\x02\x0arequest-ids\x08responses\x01\0\x04\0\x10on-http-response\x01\0\ -\x04\x01*hermes:http-request/event-on-http-response\x05B\x04\x01\x12hermes:wasi/\ -hermes\x04\0\x0b\x0c\x01\0\x06hermes\x03\0\0\0G\x09producers\x01\x0cprocessed-by\ -\x02\x0dwit-component\x070.215.0\x10wit-bindgen-rust\x060.29.0"; - -#[inline(never)] -#[doc(hidden)] -#[cfg(target_arch = "wasm32")] -pub fn __link_custom_section_describing_imports() { - wit_bindgen::rt::maybe_link_cabi_realloc(); -} - From 612282cd1411e84e60b61e6e06969f76df7803e2 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Wed, 9 Jul 2025 10:46:12 +0200 Subject: [PATCH 10/45] Request id is now `u64` --- .../bin/src/runtime_extensions/hermes/http_request/event.rs | 4 ++-- .../hermes/http_request/tokio_runtime_task.rs | 6 ++---- wasm/wasi/Earthfile | 2 +- wasm/wasi/wit/deps/hermes-http-request/api.wit | 2 +- wasm/wasi/wit/deps/hermes-http-request/event.wit | 2 +- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/event.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/event.rs index bb957c50a5..00f28efb76 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/event.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/event.rs @@ -1,7 +1,7 @@ use crate::event::HermesEventPayload; pub(super) struct OnHttpResponseEvent { - pub(super) request_id: String, + pub(super) request_id: u64, pub(super) response: String, } @@ -14,7 +14,7 @@ impl HermesEventPayload for OnHttpResponseEvent { module .instance .hermes_http_request_event_on_http_response() - .call_on_http_response(&mut module.store, &self.request_id, &self.response)?; + .call_on_http_response(&mut module.store, self.request_id, &self.response)?; Ok(()) } } diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 6f0f7d85de..0ae6056c14 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -58,7 +58,7 @@ pub(crate) struct ParsedPayload { pub(crate) body_str: String, pub(crate) request_line: String, pub(crate) url: String, - pub(crate) request_id: String, + pub(crate) request_id: u64, } pub(crate) fn parse_payload(payload: Payload) -> ParsedPayload { @@ -97,7 +97,7 @@ pub(crate) fn parse_payload(payload: Payload) -> ParsedPayload { } -fn send_request_in_background(request_id: String, body_str: String, request_line: String, url: String) -> bool { +fn send_request_in_background(request_id: u64, body_str: String, request_line: String, url: String) -> bool { // TODO[RC]: Make sure there are no stray threads left running std::thread::spawn(move || { let client = reqwest::blocking::Client::new(); // TODO: Reuse client @@ -134,8 +134,6 @@ fn send_request_in_background(request_id: String, body_str: String, request_line fn executor(mut cmd_rx: CommandReceiver) { let res = tokio::runtime::Builder::new_current_thread() - .enable_io() - .enable_time() .build(); let rt = match res { diff --git a/wasm/wasi/Earthfile b/wasm/wasi/Earthfile index 12e6ec53b2..1c99cb24ac 100644 --- a/wasm/wasi/Earthfile +++ b/wasm/wasi/Earthfile @@ -80,7 +80,7 @@ build-rust-bindings: RUN wit-bindgen rust --generate-all -w hermes:wasi/hermes ../wasi/wit SAVE ARTIFACT hermes.rs - SAVE ARTIFACT hermes.rs AS LOCAL hermes_bindings.rs +# SAVE ARTIFACT hermes.rs AS LOCAL hermes_bindings.rs # build-go-bindings - Generate tinygo bindings build-go-bindings: diff --git a/wasm/wasi/wit/deps/hermes-http-request/api.wit b/wasm/wasi/wit/deps/hermes-http-request/api.wit index e8b37a3cbf..4cc66fc235 100644 --- a/wasm/wasi/wit/deps/hermes-http-request/api.wit +++ b/wasm/wasi/wit/deps/hermes-http-request/api.wit @@ -18,7 +18,7 @@ interface api { /// Raw HTTP request (including method, path, headers, and body) body: list, /// Optional request identifier for tracking - request-id: option, + request-id: option, } /// Send an HTTP request. diff --git a/wasm/wasi/wit/deps/hermes-http-request/event.wit b/wasm/wasi/wit/deps/hermes-http-request/event.wit index a40fc323be..6d3c3db47e 100644 --- a/wasm/wasi/wit/deps/hermes-http-request/event.wit +++ b/wasm/wasi/wit/deps/hermes-http-request/event.wit @@ -1,5 +1,5 @@ interface event-on-http-response { - on-http-response: func(request-id: string, response: string); + on-http-response: func(request-id: u64, response: string); } world http-request-events { From 59ae21aba2171e3b67c7e4ddef84cba8142ce1f0 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Wed, 9 Jul 2025 12:48:45 +0200 Subject: [PATCH 11/45] Scaffolding for HTTP connection --- hermes/bin/Cargo.toml | 3 + .../hermes/http_request/host.rs | 5 +- .../hermes/http_request/tokio_runtime_task.rs | 169 +++++++++--------- .../wasi/wit/deps/hermes-http-request/api.wit | 2 + 4 files changed, 94 insertions(+), 85 deletions(-) diff --git a/hermes/bin/Cargo.toml b/hermes/bin/Cargo.toml index 19b888a150..dca2cb29c7 100644 --- a/hermes/bin/Cargo.toml +++ b/hermes/bin/Cargo.toml @@ -85,6 +85,9 @@ rust-ipfs = "0.14.1" dirs = "6.0.0" regex = "1.11.0" reqwest = "0.12.22" +rustls = "0.23.28" +webpki-roots = "1.0.1" +webpki = "0.22.4" [build-dependencies] build-info-build = "0.0.40" diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs index 985ca6ef63..8937e22617 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs @@ -4,10 +4,7 @@ use crate::{ runtime_context::HermesRuntimeContext, runtime_extensions::{ bindings::hermes::http_request::api::{ErrorCode, Host, Payload}, - hermes::http_request::{ - tokio_runtime_task::{parse_payload, ParsedPayload}, - STATE, - }, + hermes::http_request::STATE, }, }; diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 0ae6056c14..f5ca2690ad 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -1,15 +1,27 @@ +use std::{net::TcpStream, sync::Arc}; + +use rustls::{pki_types::ServerName, ClientConfig, ClientConnection, RootCertStore, StreamOwned}; +use thiserror::Error; use tokio::sync::{mpsc, oneshot}; use tracing::{error, trace}; -use thiserror::Error; +use webpki_roots::TLS_SERVER_ROOTS; -use crate::{event::{HermesEvent, HermesEventPayload, TargetApp, TargetModule}, runtime_extensions::bindings::hermes::http_request::api::{Payload, ErrorCode}}; +use crate::{ + event::{HermesEvent, HermesEventPayload, TargetApp, TargetModule}, + runtime_extensions::bindings::hermes::http_request::api::{ErrorCode, Payload}, +}; + +const HTTP: &str = "http://"; +const HTTPS: &str = "https://"; pub enum Command { - Send { payload: Payload, sender: oneshot::Sender }, + Send { + payload: Payload, + sender: oneshot::Sender, + }, } type CommandSender = tokio::sync::mpsc::Sender; - type CommandReceiver = tokio::sync::mpsc::Receiver; pub struct TokioTaskHandle { @@ -27,19 +39,21 @@ pub enum RequestSendingError { impl From for ErrorCode { fn from(value: RequestSendingError) -> Self { match value { - // We map all "internal" errors to `ErrorCode::Internal` to not expose implementation details to the user. Detailed information will be available in logs. - RequestSendingError::ChannelSend(_)|RequestSendingError::ResponseReceive(_) => ErrorCode::Internal, + // We map all "internal" errors to `ErrorCode::Internal` to not expose implementation + // details to the user. Detailed information will be available in logs. + RequestSendingError::ChannelSend(_) | RequestSendingError::ResponseReceive(_) => { + ErrorCode::Internal + }, } } } impl TokioTaskHandle { /// Sends a command to the Tokio runtime task. - pub fn send( - &self, payload: Payload, - ) -> Result<(), RequestSendingError> { + pub fn send(&self, payload: Payload) -> Result<(), RequestSendingError> { let (sender, receiver) = tokio::sync::oneshot::channel(); - self.cmd_tx.blocking_send(Command::Send { payload, sender })?; + self.cmd_tx + .blocking_send(Command::Send { payload, sender })?; receiver.blocking_recv()?; Ok(()) } @@ -54,87 +68,90 @@ pub fn spawn() -> TokioTaskHandle { TokioTaskHandle { cmd_tx } } -pub(crate) struct ParsedPayload { - pub(crate) body_str: String, - pub(crate) request_line: String, - pub(crate) url: String, - pub(crate) request_id: u64, +// TODO[RC]: Use Tokio here +enum Connection { + Http(TcpStream), + Https(StreamOwned), } -pub(crate) fn parse_payload(payload: Payload) -> ParsedPayload { - let body_str = String::from_utf8(payload.body).unwrap(); - let request_line = body_str - .lines() - .next() - .ok_or("Empty HTTP body") - .unwrap() - .to_string(); - - let parts: Vec<&str> = request_line.split_whitespace().collect(); - if parts.len() < 2 { - tracing::error!("E1"); - } - let path = parts[1]; - - let scheme = if payload.host_uri.starts_with("https") { - "https" - } else { - "http" - }; - let domain = payload - .host_uri - .trim_start_matches("http://") - .trim_start_matches("https://"); - - let url = format!("{}://{}:{}{}", scheme, domain, payload.port, path); - tracing::error!("Full URL: {}", url); - ParsedPayload { - body_str, - request_line, - url, - request_id: payload.request_id.clone().unwrap(), +impl Connection { + fn new(addr: S, port: u16) -> Result + where S: AsRef + Into + core::fmt::Display { + if addr.as_ref().starts_with(HTTP) { + let stream = TcpStream::connect((addr.as_ref(), port)).unwrap(); + return Ok(Connection::Http(stream)); + } else if addr.as_ref().starts_with(HTTPS) { + // TODO[RC]: No need to configure RootCertStore for every connection + let mut root_store = RootCertStore::empty(); + root_store.extend(TLS_SERVER_ROOTS.iter().cloned()); + let config = ClientConfig::builder() + .with_root_certificates(root_store) + .with_no_client_auth(); + let config = Arc::new(config); + let server_name = ServerName::try_from(addr.to_string()).unwrap(); + let tcp = TcpStream::connect((addr.as_ref(), port)).unwrap(); + let conn = ClientConnection::new(config, server_name).unwrap(); + let mut stream = StreamOwned::new(conn, tcp); + return Ok(Connection::Https(stream)); + } else { + tracing::debug!(%addr, "missing scheme"); + return Err(ErrorCode::MissingScheme); + } } } +fn connect(host_uri: S, port: u16) -> Result +where S: AsRef + Into + core::fmt::Display { + // TODO[RC]: Implement connection logic + let connection = Connection::new(host_uri, port); + + todo!() +} -fn send_request_in_background(request_id: u64, body_str: String, request_line: String, url: String) -> bool { +fn send_request_in_background(payload: &Payload) -> bool { // TODO[RC]: Make sure there are no stray threads left running + let host_uri = payload.host_uri.clone(); + let port = payload.port; std::thread::spawn(move || { - let client = reqwest::blocking::Client::new(); // TODO: Reuse client - let response = if request_line.starts_with("POST") { - let body_content = body_str.split("\r\n\r\n").last().unwrap_or(""); - client - .post(&url) - .body(body_content.to_string()) - .send() - .unwrap() - } else { - client.get(&url).send().unwrap() - }; - - let response_text = response - .text() - .unwrap_or_else(|_| "Failed to read response".to_string()); + let x = connect(host_uri, port); + // let client = reqwest::blocking::Client::new(); // TODO: Reuse client + // let response = if request_line.starts_with("POST") { + // let body_content = body_str.split("\r\n\r\n").last().unwrap_or(""); + // client + // .post(&url) + // .body(body_content.to_string()) + // .send() + // .unwrap() + // } else { + // client.get(&url).send().unwrap() + // }; + + // let response_text = response + // .text() + // .unwrap_or_else(|_| "Failed to read response".to_string()); + + // let on_http_response_event = super::event::OnHttpResponseEvent { + // request_id, + // response: response_text, + // }; let on_http_response_event = super::event::OnHttpResponseEvent { - request_id, - response: response_text, + request_id: 42, + response: "abc".to_string(), }; - + crate::event::queue::send(HermesEvent::new( on_http_response_event, TargetApp::All, TargetModule::All, )); - } - ); + }); true } fn executor(mut cmd_rx: CommandReceiver) { - let res = tokio::runtime::Builder::new_current_thread() - .build(); + let res = tokio::runtime::Builder::new_current_thread().build(); let rt = match res { Ok(rt) => rt, @@ -150,17 +167,7 @@ fn executor(mut cmd_rx: CommandReceiver) { while let Some(cmd) = cmd_rx.recv().await { match cmd { Command::Send { payload, sender } => { - let ParsedPayload { - body_str, - request_line, - url, - request_id, - } = parse_payload(payload); - error!(body_str = %body_str, request_line = %request_line, url = %url, request_id = %request_id, "Parsed payload"); - - let sending_result = send_request_in_background(request_id, body_str, - request_line, - url); + let sending_result = send_request_in_background(&payload); let _ = sender.send(sending_result); }, } diff --git a/wasm/wasi/wit/deps/hermes-http-request/api.wit b/wasm/wasi/wit/deps/hermes-http-request/api.wit index 4cc66fc235..f1892835ec 100644 --- a/wasm/wasi/wit/deps/hermes-http-request/api.wit +++ b/wasm/wasi/wit/deps/hermes-http-request/api.wit @@ -6,6 +6,8 @@ interface api { enum error-code { /// Internal error when trying to send the request internal, + /// Either `http://` or `https://` scheme is required + missing-scheme, } /// HTTP request payload (caller manages full body formatting) From 1bb5aa2db0ed5dd8bf38b5a9174f12356162e059 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Wed, 9 Jul 2025 14:37:22 +0200 Subject: [PATCH 12/45] Sending over HTTP(s) --- .../hermes/http_request/tokio_runtime_task.rs | 45 ++++++++++++------- .../wasi/wit/deps/hermes-http-request/api.wit | 8 ++++ 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index f5ca2690ad..4dc0b00040 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -1,4 +1,4 @@ -use std::{net::TcpStream, sync::Arc}; +use std::{io::Write, net::TcpStream, sync::Arc}; use rustls::{pki_types::ServerName, ClientConfig, ClientConnection, RootCertStore, StreamOwned}; use thiserror::Error; @@ -78,7 +78,8 @@ impl Connection { fn new(addr: S, port: u16) -> Result where S: AsRef + Into + core::fmt::Display { if addr.as_ref().starts_with(HTTP) { - let stream = TcpStream::connect((addr.as_ref(), port)).unwrap(); + let stream = TcpStream::connect((addr.as_ref(), port)) + .map_err(|_| ErrorCode::HttpConnectionFailed)?; return Ok(Connection::Http(stream)); } else if addr.as_ref().starts_with(HTTPS) { // TODO[RC]: No need to configure RootCertStore for every connection @@ -88,9 +89,12 @@ impl Connection { .with_root_certificates(root_store) .with_no_client_auth(); let config = Arc::new(config); - let server_name = ServerName::try_from(addr.to_string()).unwrap(); - let tcp = TcpStream::connect((addr.as_ref(), port)).unwrap(); - let conn = ClientConnection::new(config, server_name).unwrap(); + let server_name = ServerName::try_from(addr.to_string()) + .map_err(|_| ErrorCode::HttpsConnectionFailed)?; + let tcp = TcpStream::connect((addr.as_ref(), port)) + .map_err(|_| ErrorCode::HttpsConnectionFailed)?; + let conn = ClientConnection::new(config, server_name) + .map_err(|_| ErrorCode::HttpsConnectionFailed)?; let mut stream = StreamOwned::new(conn, tcp); return Ok(Connection::Https(stream)); } else { @@ -98,22 +102,29 @@ impl Connection { return Err(ErrorCode::MissingScheme); } } -} - -fn connect(host_uri: S, port: u16) -> Result -where S: AsRef + Into + core::fmt::Display { - // TODO[RC]: Implement connection logic - let connection = Connection::new(host_uri, port); - todo!() + fn send(&mut self, body: &[u8]) -> Result<(), ErrorCode> { + match self { + Connection::Http(ref mut tcp_stream) => { + tcp_stream + .write_all(body) + .map_err(|_| ErrorCode::HttpSendFailed)?; + }, + Connection::Https(tls_stream) => { + tls_stream + .write_all(body) + .map_err(|_| ErrorCode::HttpsSendFailed)?; + }, + } + Ok(()) + } } -fn send_request_in_background(payload: &Payload) -> bool { +fn send_request_in_background(payload: Payload) -> bool { // TODO[RC]: Make sure there are no stray threads left running - let host_uri = payload.host_uri.clone(); - let port = payload.port; std::thread::spawn(move || { - let x = connect(host_uri, port); + let mut conn = Connection::new(payload.host_uri, payload.port).unwrap(); + let send_result = conn.send(&payload.body); // let client = reqwest::blocking::Client::new(); // TODO: Reuse client // let response = if request_line.starts_with("POST") { // let body_content = body_str.split("\r\n\r\n").last().unwrap_or(""); @@ -167,7 +178,7 @@ fn executor(mut cmd_rx: CommandReceiver) { while let Some(cmd) = cmd_rx.recv().await { match cmd { Command::Send { payload, sender } => { - let sending_result = send_request_in_background(&payload); + let sending_result = send_request_in_background(payload); let _ = sender.send(sending_result); }, } diff --git a/wasm/wasi/wit/deps/hermes-http-request/api.wit b/wasm/wasi/wit/deps/hermes-http-request/api.wit index f1892835ec..4c02bc04e2 100644 --- a/wasm/wasi/wit/deps/hermes-http-request/api.wit +++ b/wasm/wasi/wit/deps/hermes-http-request/api.wit @@ -8,6 +8,14 @@ interface api { internal, /// Either `http://` or `https://` scheme is required missing-scheme, + /// HTTP connection failed + http-connection-failed, + /// HTTPs connection failed + https-connection-failed, + /// HTTP send failed + http-send-failed, + /// HTTPs send failed + https-send-failed, } /// HTTP request payload (caller manages full body formatting) From fd1a45a27bd9cafccdec56d530e6420d0edfce89 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Wed, 9 Jul 2025 15:52:41 +0200 Subject: [PATCH 13/45] Native HTTP sending --- .../hermes/http_request/event.rs | 4 +- .../hermes/http_request/tokio_runtime_task.rs | 91 ++++++++++--------- .../wit/deps/hermes-http-request/event.wit | 2 +- 3 files changed, 53 insertions(+), 44 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/event.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/event.rs index 00f28efb76..4fcea0f5d2 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/event.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/event.rs @@ -1,8 +1,8 @@ use crate::event::HermesEventPayload; pub(super) struct OnHttpResponseEvent { - pub(super) request_id: u64, - pub(super) response: String, + pub(super) request_id: Option, + pub(super) response: Vec, } impl HermesEventPayload for OnHttpResponseEvent { diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 4dc0b00040..3c003a3d9a 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -1,4 +1,8 @@ -use std::{io::Write, net::TcpStream, sync::Arc}; +use std::{ + io::{Read, Write}, + net::TcpStream, + sync::Arc, +}; use rustls::{pki_types::ServerName, ClientConfig, ClientConnection, RootCertStore, StreamOwned}; use thiserror::Error; @@ -77,46 +81,69 @@ enum Connection { impl Connection { fn new(addr: S, port: u16) -> Result where S: AsRef + Into + core::fmt::Display { + tracing::error!("XXXXX - getting new connection"); if addr.as_ref().starts_with(HTTP) { - let stream = TcpStream::connect((addr.as_ref(), port)) - .map_err(|_| ErrorCode::HttpConnectionFailed)?; + let sliced_addr = &addr.as_ref()[HTTP.len()..]; + let stream = TcpStream::connect((sliced_addr, port)).map_err(|err| { + // TODO[RC]: These should be debug!, but debug do not show up even with + // RUST_LOG=debug - to be investigated. + tracing::error!(%err, %sliced_addr, "Failed to connect to HTTP server"); + ErrorCode::HttpConnectionFailed + })?; + tracing::error!("XXXXX - have connection"); return Ok(Connection::Http(stream)); } else if addr.as_ref().starts_with(HTTPS) { // TODO[RC]: No need to configure RootCertStore for every connection + let sliced_addr = &addr.as_ref()[HTTPS.len()..]; let mut root_store = RootCertStore::empty(); root_store.extend(TLS_SERVER_ROOTS.iter().cloned()); let config = ClientConfig::builder() .with_root_certificates(root_store) .with_no_client_auth(); let config = Arc::new(config); - let server_name = ServerName::try_from(addr.to_string()) - .map_err(|_| ErrorCode::HttpsConnectionFailed)?; - let tcp = TcpStream::connect((addr.as_ref(), port)) - .map_err(|_| ErrorCode::HttpsConnectionFailed)?; - let conn = ClientConnection::new(config, server_name) - .map_err(|_| ErrorCode::HttpsConnectionFailed)?; + let server_name = ServerName::try_from(sliced_addr.to_string()).map_err(|err| { + tracing::error!(%err, %sliced_addr, "Failed to connect to HTTPs server"); + ErrorCode::HttpsConnectionFailed + })?; + let tcp = TcpStream::connect((addr.as_ref(), port)).map_err(|err| { + tracing::error!(%err, %sliced_addr, "Failed to connect to HTTPs server"); + ErrorCode::HttpsConnectionFailed + })?; + let conn = ClientConnection::new(config, server_name).map_err(|err| { + tracing::error!(%err, %sliced_addr, "Failed to connect to HTTPs server"); + ErrorCode::HttpsConnectionFailed + })?; let mut stream = StreamOwned::new(conn, tcp); return Ok(Connection::Https(stream)); } else { - tracing::debug!(%addr, "missing scheme"); + tracing::error!(%addr, "missing scheme"); return Err(ErrorCode::MissingScheme); } } - fn send(&mut self, body: &[u8]) -> Result<(), ErrorCode> { + // TODO[RC]: Timeout needed here, but maybe first switch to Tokio + fn send(&mut self, body: &[u8]) -> Result, ErrorCode> { + let mut response = Vec::new(); match self { Connection::Http(ref mut tcp_stream) => { - tcp_stream - .write_all(body) - .map_err(|_| ErrorCode::HttpSendFailed)?; + tcp_stream.write_all(body).map_err(|err| { + error!("Failed to send HTTP request: {err}"); + ErrorCode::HttpSendFailed + })?; + tracing::error!("XXXXX - reading to end 1"); + tcp_stream.read_to_end(&mut response).unwrap(); + tracing::error!("XXXXX - got the response"); }, Connection::Https(tls_stream) => { - tls_stream - .write_all(body) - .map_err(|_| ErrorCode::HttpsSendFailed)?; + tls_stream.write_all(body).map_err(|err| { + tracing::error!(%err, "Failed to connect to HTTPs server"); + ErrorCode::HttpsSendFailed + })?; + tracing::error!("XXXXX - reading to end 2"); + tls_stream.read_to_end(&mut response).unwrap(); }, } - Ok(()) + Ok(response) } } @@ -124,31 +151,13 @@ fn send_request_in_background(payload: Payload) -> bool { // TODO[RC]: Make sure there are no stray threads left running std::thread::spawn(move || { let mut conn = Connection::new(payload.host_uri, payload.port).unwrap(); - let send_result = conn.send(&payload.body); - // let client = reqwest::blocking::Client::new(); // TODO: Reuse client - // let response = if request_line.starts_with("POST") { - // let body_content = body_str.split("\r\n\r\n").last().unwrap_or(""); - // client - // .post(&url) - // .body(body_content.to_string()) - // .send() - // .unwrap() - // } else { - // client.get(&url).send().unwrap() - // }; - - // let response_text = response - // .text() - // .unwrap_or_else(|_| "Failed to read response".to_string()); - - // let on_http_response_event = super::event::OnHttpResponseEvent { - // request_id, - // response: response_text, - // }; + tracing::error!("XXXXX - send_request_in_background 1"); + let response = conn.send(&payload.body).unwrap(); + tracing::error!("XXXXX - send_request_in_background 2"); let on_http_response_event = super::event::OnHttpResponseEvent { - request_id: 42, - response: "abc".to_string(), + request_id: payload.request_id, + response, }; crate::event::queue::send(HermesEvent::new( diff --git a/wasm/wasi/wit/deps/hermes-http-request/event.wit b/wasm/wasi/wit/deps/hermes-http-request/event.wit index 6d3c3db47e..4c49feb330 100644 --- a/wasm/wasi/wit/deps/hermes-http-request/event.wit +++ b/wasm/wasi/wit/deps/hermes-http-request/event.wit @@ -1,5 +1,5 @@ interface event-on-http-response { - on-http-response: func(request-id: u64, response: string); + on-http-response: func(request-id: option, response: list); } world http-request-events { From d57e82a80cd36f366840f8e3267b4cf9922f8ddc Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Thu, 10 Jul 2025 10:41:40 +0200 Subject: [PATCH 14/45] Cleanup HTTP connection part --- .../hermes/http_request/tokio_runtime_task.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 3c003a3d9a..6aaea76473 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -81,7 +81,6 @@ enum Connection { impl Connection { fn new(addr: S, port: u16) -> Result where S: AsRef + Into + core::fmt::Display { - tracing::error!("XXXXX - getting new connection"); if addr.as_ref().starts_with(HTTP) { let sliced_addr = &addr.as_ref()[HTTP.len()..]; let stream = TcpStream::connect((sliced_addr, port)).map_err(|err| { @@ -90,7 +89,7 @@ impl Connection { tracing::error!(%err, %sliced_addr, "Failed to connect to HTTP server"); ErrorCode::HttpConnectionFailed })?; - tracing::error!("XXXXX - have connection"); + tracing::debug!(%addr, port, "connected over HTTP"); return Ok(Connection::Http(stream)); } else if addr.as_ref().starts_with(HTTPS) { // TODO[RC]: No need to configure RootCertStore for every connection @@ -127,16 +126,16 @@ impl Connection { match self { Connection::Http(ref mut tcp_stream) => { tcp_stream.write_all(body).map_err(|err| { - error!("Failed to send HTTP request: {err}"); + error!("failed to send HTTP request: {err}"); ErrorCode::HttpSendFailed })?; - tracing::error!("XXXXX - reading to end 1"); + tracing::debug!("request sent, awaiting response"); tcp_stream.read_to_end(&mut response).unwrap(); - tracing::error!("XXXXX - got the response"); + tracing::debug!(length_bytes = response.len(), "got response"); }, Connection::Https(tls_stream) => { tls_stream.write_all(body).map_err(|err| { - tracing::error!(%err, "Failed to connect to HTTPs server"); + tracing::error!(%err, "failed to connect to HTTPs server"); ErrorCode::HttpsSendFailed })?; tracing::error!("XXXXX - reading to end 2"); @@ -151,9 +150,7 @@ fn send_request_in_background(payload: Payload) -> bool { // TODO[RC]: Make sure there are no stray threads left running std::thread::spawn(move || { let mut conn = Connection::new(payload.host_uri, payload.port).unwrap(); - tracing::error!("XXXXX - send_request_in_background 1"); let response = conn.send(&payload.body).unwrap(); - tracing::error!("XXXXX - send_request_in_background 2"); let on_http_response_event = super::event::OnHttpResponseEvent { request_id: payload.request_id, From 61529254f8a07bd9e421a0e734b3494be050591e Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Thu, 10 Jul 2025 11:23:41 +0200 Subject: [PATCH 15/45] Support HTTPs requests --- hermes/bin/src/main.rs | 5 ++ .../hermes/http_request/tokio_runtime_task.rs | 62 +++++++++++++------ 2 files changed, 49 insertions(+), 18 deletions(-) diff --git a/hermes/bin/src/main.rs b/hermes/bin/src/main.rs index 9972d16711..faafe86dc6 100644 --- a/hermes/bin/src/main.rs +++ b/hermes/bin/src/main.rs @@ -25,5 +25,10 @@ pub use wasm::module::bench::{ fn main() { use clap::Parser; + // TODO[RC]: Do this lazily at the first HTTPs request. + rustls::crypto::ring::default_provider() + .install_default() + .expect("Failed to install rustls crypto provider"); + cli::Cli::parse().exec(); } diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 6aaea76473..e9f734d415 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -100,11 +100,11 @@ impl Connection { .with_root_certificates(root_store) .with_no_client_auth(); let config = Arc::new(config); - let server_name = ServerName::try_from(sliced_addr.to_string()).map_err(|err| { + let tcp = TcpStream::connect((sliced_addr.as_ref(), port)).map_err(|err| { tracing::error!(%err, %sliced_addr, "Failed to connect to HTTPs server"); ErrorCode::HttpsConnectionFailed })?; - let tcp = TcpStream::connect((addr.as_ref(), port)).map_err(|err| { + let server_name = ServerName::try_from(sliced_addr.to_string()).map_err(|err| { tracing::error!(%err, %sliced_addr, "Failed to connect to HTTPs server"); ErrorCode::HttpsConnectionFailed })?; @@ -113,9 +113,10 @@ impl Connection { ErrorCode::HttpsConnectionFailed })?; let mut stream = StreamOwned::new(conn, tcp); + tracing::debug!(%addr, port, "connected over HTTPs"); return Ok(Connection::Https(stream)); } else { - tracing::error!(%addr, "missing scheme"); + tracing::debug!(%addr, "missing scheme"); return Err(ErrorCode::MissingScheme); } } @@ -130,7 +131,10 @@ impl Connection { ErrorCode::HttpSendFailed })?; tracing::debug!("request sent, awaiting response"); - tcp_stream.read_to_end(&mut response).unwrap(); + read_to_end_ignoring_unexpected_eof(tcp_stream, &mut response).map_err(|err| { + tracing::debug!(%err, "failed to read from HTTP server"); + ErrorCode::HttpsSendFailed + }); tracing::debug!(length_bytes = response.len(), "got response"); }, Connection::Https(tls_stream) => { @@ -138,30 +142,52 @@ impl Connection { tracing::error!(%err, "failed to connect to HTTPs server"); ErrorCode::HttpsSendFailed })?; - tracing::error!("XXXXX - reading to end 2"); - tls_stream.read_to_end(&mut response).unwrap(); + read_to_end_ignoring_unexpected_eof(tls_stream, &mut response).map_err(|err| { + tracing::debug!(%err, "failed to read from HTTPs server"); + ErrorCode::HttpsSendFailed + }); + tracing::debug!(length_bytes = response.len(), "got response"); }, } Ok(response) } } +fn read_to_end_ignoring_unexpected_eof( + reader: &mut R, buf: &mut Vec, +) -> std::io::Result +where R: Read { + match reader.read_to_end(buf) { + Ok(0) => Ok(0), + Ok(n) => Ok(n), + Err(e) if e.kind() == std::io::ErrorKind::UnexpectedEof => { + tracing::debug!("HTTPs connection closed unexpectedly, but no big deal"); + Ok(buf.len()) + }, + Err(e) => Err(e), + } +} + fn send_request_in_background(payload: Payload) -> bool { // TODO[RC]: Make sure there are no stray threads left running std::thread::spawn(move || { let mut conn = Connection::new(payload.host_uri, payload.port).unwrap(); - let response = conn.send(&payload.body).unwrap(); - - let on_http_response_event = super::event::OnHttpResponseEvent { - request_id: payload.request_id, - response, - }; - - crate::event::queue::send(HermesEvent::new( - on_http_response_event, - TargetApp::All, - TargetModule::All, - )); + let response = conn.send(&payload.body); + match response { + Ok(response) => { + let on_http_response_event = super::event::OnHttpResponseEvent { + request_id: payload.request_id, + response, + }; + + crate::event::queue::send(HermesEvent::new( + on_http_response_event, + TargetApp::All, + TargetModule::All, + )); + }, + Err(err) => tracing::debug!(%err, "error sending request"), + } }); true From 33fceb763d611b5361780bd31556e2cb54e44b7c Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Thu, 10 Jul 2025 12:12:33 +0200 Subject: [PATCH 16/45] Switch to async --- hermes/bin/Cargo.toml | 1 + .../hermes/http_request/tokio_runtime_task.rs | 137 ++++++++++-------- 2 files changed, 77 insertions(+), 61 deletions(-) diff --git a/hermes/bin/Cargo.toml b/hermes/bin/Cargo.toml index dca2cb29c7..19d07ba7af 100644 --- a/hermes/bin/Cargo.toml +++ b/hermes/bin/Cargo.toml @@ -88,6 +88,7 @@ reqwest = "0.12.22" rustls = "0.23.28" webpki-roots = "1.0.1" webpki = "0.22.4" +tokio-rustls = "0.26.2" [build-dependencies] build-info-build = "0.0.40" diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index e9f734d415..1b3b8b2955 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -1,12 +1,13 @@ -use std::{ - io::{Read, Write}, - net::TcpStream, - sync::Arc, -}; +use std::sync::Arc; use rustls::{pki_types::ServerName, ClientConfig, ClientConnection, RootCertStore, StreamOwned}; use thiserror::Error; -use tokio::sync::{mpsc, oneshot}; +use tokio::{ + io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}, + net::TcpStream, + sync::{mpsc, oneshot}, +}; +use tokio_rustls::{client, TlsConnector, TlsStream}; use tracing::{error, trace}; use webpki_roots::TLS_SERVER_ROOTS; @@ -75,45 +76,51 @@ pub fn spawn() -> TokioTaskHandle { // TODO[RC]: Use Tokio here enum Connection { Http(TcpStream), - Https(StreamOwned), + Https(client::TlsStream), } impl Connection { - fn new(addr: S, port: u16) -> Result + async fn new(addr: S, port: u16) -> Result where S: AsRef + Into + core::fmt::Display { if addr.as_ref().starts_with(HTTP) { let sliced_addr = &addr.as_ref()[HTTP.len()..]; - let stream = TcpStream::connect((sliced_addr, port)).map_err(|err| { - // TODO[RC]: These should be debug!, but debug do not show up even with - // RUST_LOG=debug - to be investigated. - tracing::error!(%err, %sliced_addr, "Failed to connect to HTTP server"); - ErrorCode::HttpConnectionFailed - })?; - tracing::debug!(%addr, port, "connected over HTTP"); + let stream = TcpStream::connect((sliced_addr, port)) + .await + .map_err(|err| { + tracing::debug!(%err, %sliced_addr, "Failed to connect to HTTP server"); + ErrorCode::HttpConnectionFailed + })?; + tracing::trace!(%addr, port, "connected over HTTP"); return Ok(Connection::Http(stream)); } else if addr.as_ref().starts_with(HTTPS) { // TODO[RC]: No need to configure RootCertStore for every connection let sliced_addr = &addr.as_ref()[HTTPS.len()..]; let mut root_store = RootCertStore::empty(); root_store.extend(TLS_SERVER_ROOTS.iter().cloned()); + let config = ClientConfig::builder() .with_root_certificates(root_store) .with_no_client_auth(); let config = Arc::new(config); - let tcp = TcpStream::connect((sliced_addr.as_ref(), port)).map_err(|err| { - tracing::error!(%err, %sliced_addr, "Failed to connect to HTTPs server"); - ErrorCode::HttpsConnectionFailed - })?; + let connector = TlsConnector::from(config); + let tcp = TcpStream::connect((sliced_addr, port)) + .await + .map_err(|err| { + tracing::debug!(%err, %sliced_addr, "tcp stream to HTTPs server"); + ErrorCode::HttpsConnectionFailed + })?; + let server_name = ServerName::try_from(sliced_addr.to_string()).map_err(|err| { - tracing::error!(%err, %sliced_addr, "Failed to connect to HTTPs server"); + tracing::debug!(%err, %sliced_addr, "invalid server name when connecting to HTTPs server"); ErrorCode::HttpsConnectionFailed })?; - let conn = ClientConnection::new(config, server_name).map_err(|err| { - tracing::error!(%err, %sliced_addr, "Failed to connect to HTTPs server"); + + let stream = connector.connect(server_name, tcp).await.map_err(|err| { + tracing::debug!(%err, %sliced_addr, "TLS handshake failed"); ErrorCode::HttpsConnectionFailed })?; - let mut stream = StreamOwned::new(conn, tcp); - tracing::debug!(%addr, port, "connected over HTTPs"); + + tracing::trace!(%addr, port, "connected over HTTPs"); return Ok(Connection::Https(stream)); } else { tracing::debug!(%addr, "missing scheme"); @@ -122,30 +129,34 @@ impl Connection { } // TODO[RC]: Timeout needed here, but maybe first switch to Tokio - fn send(&mut self, body: &[u8]) -> Result, ErrorCode> { + async fn send(&mut self, body: &[u8]) -> Result, ErrorCode> { let mut response = Vec::new(); match self { Connection::Http(ref mut tcp_stream) => { - tcp_stream.write_all(body).map_err(|err| { + tcp_stream.write_all(body).await.map_err(|err| { error!("failed to send HTTP request: {err}"); ErrorCode::HttpSendFailed })?; tracing::debug!("request sent, awaiting response"); - read_to_end_ignoring_unexpected_eof(tcp_stream, &mut response).map_err(|err| { - tracing::debug!(%err, "failed to read from HTTP server"); - ErrorCode::HttpsSendFailed - }); + read_to_end_ignoring_unexpected_eof(tcp_stream, &mut response) + .await + .map_err(|err| { + tracing::debug!(%err, "failed to read from HTTP server"); + ErrorCode::HttpsSendFailed + }); tracing::debug!(length_bytes = response.len(), "got response"); }, Connection::Https(tls_stream) => { - tls_stream.write_all(body).map_err(|err| { + tls_stream.write_all(body).await.map_err(|err| { tracing::error!(%err, "failed to connect to HTTPs server"); ErrorCode::HttpsSendFailed })?; - read_to_end_ignoring_unexpected_eof(tls_stream, &mut response).map_err(|err| { - tracing::debug!(%err, "failed to read from HTTPs server"); - ErrorCode::HttpsSendFailed - }); + read_to_end_ignoring_unexpected_eof(tls_stream, &mut response) + .await + .map_err(|err| { + tracing::debug!(%err, "failed to read from HTTPs server"); + ErrorCode::HttpsSendFailed + }); tracing::debug!(length_bytes = response.len(), "got response"); }, } @@ -153,11 +164,11 @@ impl Connection { } } -fn read_to_end_ignoring_unexpected_eof( +async fn read_to_end_ignoring_unexpected_eof( reader: &mut R, buf: &mut Vec, ) -> std::io::Result -where R: Read { - match reader.read_to_end(buf) { +where R: AsyncRead + Unpin { + match reader.read_to_end(buf).await { Ok(0) => Ok(0), Ok(n) => Ok(n), Err(e) if e.kind() == std::io::ErrorKind::UnexpectedEof => { @@ -168,33 +179,35 @@ where R: Read { } } -fn send_request_in_background(payload: Payload) -> bool { +async fn send_request(payload: Payload) -> bool { // TODO[RC]: Make sure there are no stray threads left running - std::thread::spawn(move || { - let mut conn = Connection::new(payload.host_uri, payload.port).unwrap(); - let response = conn.send(&payload.body); - match response { - Ok(response) => { - let on_http_response_event = super::event::OnHttpResponseEvent { - request_id: payload.request_id, - response, - }; - - crate::event::queue::send(HermesEvent::new( - on_http_response_event, - TargetApp::All, - TargetModule::All, - )); - }, - Err(err) => tracing::debug!(%err, "error sending request"), - } - }); + let mut conn = Connection::new(payload.host_uri, payload.port) + .await + .unwrap(); // TODO[RC]: Fixme + let response = conn.send(&payload.body).await; + match response { + Ok(response) => { + let on_http_response_event = super::event::OnHttpResponseEvent { + request_id: payload.request_id, + response, + }; + + crate::event::queue::send(HermesEvent::new( + on_http_response_event, + TargetApp::All, + TargetModule::All, + )); + }, + Err(err) => tracing::debug!(%err, "error sending request"), + } true } fn executor(mut cmd_rx: CommandReceiver) { - let res = tokio::runtime::Builder::new_current_thread().build(); + let res = tokio::runtime::Builder::new_current_thread() + .enable_io() + .build(); let rt = match res { Ok(rt) => rt, @@ -210,8 +223,10 @@ fn executor(mut cmd_rx: CommandReceiver) { while let Some(cmd) = cmd_rx.recv().await { match cmd { Command::Send { payload, sender } => { - let sending_result = send_request_in_background(payload); - let _ = sender.send(sending_result); + tokio::spawn(async move { + let result = send_request(payload).await; + let _ = sender.send(result); + }); }, } } From dc040f49d9960a6c9efa7a201b6fbf18646244ad Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Thu, 10 Jul 2025 15:42:52 +0200 Subject: [PATCH 17/45] Cleanup --- .../hermes/http_request/tokio_runtime_task.rs | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 1b3b8b2955..759c3f8458 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -22,7 +22,7 @@ const HTTPS: &str = "https://"; pub enum Command { Send { payload: Payload, - sender: oneshot::Sender, + response_tx: oneshot::Sender, }, } @@ -56,10 +56,12 @@ impl From for ErrorCode { impl TokioTaskHandle { /// Sends a command to the Tokio runtime task. pub fn send(&self, payload: Payload) -> Result<(), RequestSendingError> { - let (sender, receiver) = tokio::sync::oneshot::channel(); - self.cmd_tx - .blocking_send(Command::Send { payload, sender })?; - receiver.blocking_recv()?; + let (response_tx, response_rx) = tokio::sync::oneshot::channel(); + self.cmd_tx.blocking_send(Command::Send { + payload, + response_tx, + })?; + response_rx.blocking_recv()?; Ok(()) } } @@ -179,7 +181,8 @@ where R: AsyncRead + Unpin { } } -async fn send_request(payload: Payload) -> bool { +// TODO[RC]: Result<()> instead of bool +async fn send_http_request(payload: Payload) -> bool { // TODO[RC]: Make sure there are no stray threads left running let mut conn = Connection::new(payload.host_uri, payload.port) .await @@ -204,6 +207,18 @@ async fn send_request(payload: Payload) -> bool { true } +async fn handle_command(cmd: Command) { + match cmd { + Command::Send { + payload, + response_tx, + } => { + let sending_result = send_http_request(payload).await; + let _ = response_tx.send(sending_result); + }, + } +} + fn executor(mut cmd_rx: CommandReceiver) { let res = tokio::runtime::Builder::new_current_thread() .enable_io() @@ -221,14 +236,7 @@ fn executor(mut cmd_rx: CommandReceiver) { rt.block_on(async move { while let Some(cmd) = cmd_rx.recv().await { - match cmd { - Command::Send { payload, sender } => { - tokio::spawn(async move { - let result = send_request(payload).await; - let _ = sender.send(result); - }); - }, - } + tokio::spawn(handle_command(cmd)); } }); } From 1d62d3374318128869b47394f7912a8b7630825d Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 09:56:05 +0200 Subject: [PATCH 18/45] Remove superfluous `RequestSendingError` --- .../hermes/http_request/mod.rs | 11 +---- .../hermes/http_request/tokio_runtime_task.rs | 48 +++++++------------ 2 files changed, 18 insertions(+), 41 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs index 484eb226b2..ec6f0fd1fe 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs @@ -23,13 +23,4 @@ pub(crate) fn new_context(_ctx: &crate::runtime_context::HermesRuntimeContext) { type Error = u32; #[cfg(test)] -mod test { - // use crate::runtime_extensions::hermes::http_request::send; - - // #[test] - // fn sending_works() { - // let result = send(24).unwrap(); - - // assert_eq!(result, true); - // } -} +mod test {} diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 759c3f8458..31a3e67ddb 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -22,7 +22,7 @@ const HTTPS: &str = "https://"; pub enum Command { Send { payload: Payload, - response_tx: oneshot::Sender, + response_tx: oneshot::Sender>, }, } @@ -33,36 +33,23 @@ pub struct TokioTaskHandle { cmd_tx: CommandSender, } -#[derive(Error, Debug)] -pub enum RequestSendingError { - #[error("Failed to send command via channel: {0}")] - ChannelSend(#[from] mpsc::error::SendError), - #[error("Failed to receive command result via channel: {0}")] - ResponseReceive(#[from] oneshot::error::RecvError), -} - -impl From for ErrorCode { - fn from(value: RequestSendingError) -> Self { - match value { - // We map all "internal" errors to `ErrorCode::Internal` to not expose implementation - // details to the user. Detailed information will be available in logs. - RequestSendingError::ChannelSend(_) | RequestSendingError::ResponseReceive(_) => { - ErrorCode::Internal - }, - } - } -} - impl TokioTaskHandle { /// Sends a command to the Tokio runtime task. - pub fn send(&self, payload: Payload) -> Result<(), RequestSendingError> { + pub fn send(&self, payload: Payload) -> Result<(), ErrorCode> { let (response_tx, response_rx) = tokio::sync::oneshot::channel(); - self.cmd_tx.blocking_send(Command::Send { - payload, - response_tx, - })?; - response_rx.blocking_recv()?; - Ok(()) + self.cmd_tx + .blocking_send(Command::Send { + payload, + response_tx, + }) + .map_err(|err| { + tracing::warn!(%err, "failed to send command via channel"); + ErrorCode::Internal + })?; + response_rx.blocking_recv().map_err(|err| { + tracing::warn!(%err, "failed to receive command result via channel"); + ErrorCode::Internal + })? } } @@ -75,7 +62,6 @@ pub fn spawn() -> TokioTaskHandle { TokioTaskHandle { cmd_tx } } -// TODO[RC]: Use Tokio here enum Connection { Http(TcpStream), Https(client::TlsStream), @@ -182,7 +168,7 @@ where R: AsyncRead + Unpin { } // TODO[RC]: Result<()> instead of bool -async fn send_http_request(payload: Payload) -> bool { +async fn send_http_request(payload: Payload) -> Result<(), ErrorCode> { // TODO[RC]: Make sure there are no stray threads left running let mut conn = Connection::new(payload.host_uri, payload.port) .await @@ -204,7 +190,7 @@ async fn send_http_request(payload: Payload) -> bool { Err(err) => tracing::debug!(%err, "error sending request"), } - true + Ok(()) } async fn handle_command(cmd: Command) { From 1304f41edfa5adfc85a0a840a41239469f2a9ae9 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 10:02:14 +0200 Subject: [PATCH 19/45] Fix unwrap --- .../hermes/http_request/tokio_runtime_task.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 31a3e67ddb..e168869f61 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -167,12 +167,9 @@ where R: AsyncRead + Unpin { } } -// TODO[RC]: Result<()> instead of bool async fn send_http_request(payload: Payload) -> Result<(), ErrorCode> { // TODO[RC]: Make sure there are no stray threads left running - let mut conn = Connection::new(payload.host_uri, payload.port) - .await - .unwrap(); // TODO[RC]: Fixme + let mut conn = Connection::new(payload.host_uri, payload.port).await?; let response = conn.send(&payload.body).await; match response { Ok(response) => { From 5580e1df75fa5db01b8640e71de3c6c086e0312e Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 10:09:48 +0200 Subject: [PATCH 20/45] Cleanup --- .../hermes/http_request/tokio_runtime_task.rs | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index e168869f61..1b692c53e2 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -125,12 +125,11 @@ impl Connection { error!("failed to send HTTP request: {err}"); ErrorCode::HttpSendFailed })?; - tracing::debug!("request sent, awaiting response"); read_to_end_ignoring_unexpected_eof(tcp_stream, &mut response) .await .map_err(|err| { tracing::debug!(%err, "failed to read from HTTP server"); - ErrorCode::HttpsSendFailed + ErrorCode::HttpSendFailed }); tracing::debug!(length_bytes = response.len(), "got response"); }, @@ -170,23 +169,18 @@ where R: AsyncRead + Unpin { async fn send_http_request(payload: Payload) -> Result<(), ErrorCode> { // TODO[RC]: Make sure there are no stray threads left running let mut conn = Connection::new(payload.host_uri, payload.port).await?; - let response = conn.send(&payload.body).await; - match response { - Ok(response) => { - let on_http_response_event = super::event::OnHttpResponseEvent { - request_id: payload.request_id, - response, - }; - - crate::event::queue::send(HermesEvent::new( - on_http_response_event, - TargetApp::All, - TargetModule::All, - )); - }, - Err(err) => tracing::debug!(%err, "error sending request"), - } + let response = conn.send(&payload.body).await?; + + let on_http_response_event = super::event::OnHttpResponseEvent { + request_id: payload.request_id, + response, + }; + crate::event::queue::send(HermesEvent::new( + on_http_response_event, + TargetApp::All, + TargetModule::All, + )); Ok(()) } From 7a6d4f138afd5e5cc2e0adcd746ffb0e5c994c60 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 10:33:07 +0200 Subject: [PATCH 21/45] Init RUSTLS crypto provider lazily --- hermes/bin/src/main.rs | 5 ----- .../runtime_extensions/hermes/http_request/mod.rs | 2 ++ .../hermes/http_request/tokio_runtime_task.rs | 13 ++++++++++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/hermes/bin/src/main.rs b/hermes/bin/src/main.rs index faafe86dc6..9972d16711 100644 --- a/hermes/bin/src/main.rs +++ b/hermes/bin/src/main.rs @@ -25,10 +25,5 @@ pub use wasm::module::bench::{ fn main() { use clap::Parser; - // TODO[RC]: Do this lazily at the first HTTPs request. - rustls::crypto::ring::default_provider() - .install_default() - .expect("Failed to install rustls crypto provider"); - cli::Cli::parse().exec(); } diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs index ec6f0fd1fe..c6b18d3def 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs @@ -3,6 +3,8 @@ #![allow(unused)] #![allow(dead_code)] +use std::sync::LazyLock; + mod event; mod host; mod tokio_runtime_task; diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 1b692c53e2..82b9720278 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use std::sync::{Arc, LazyLock}; use rustls::{pki_types::ServerName, ClientConfig, ClientConnection, RootCertStore, StreamOwned}; use thiserror::Error; @@ -16,6 +16,15 @@ use crate::{ runtime_extensions::bindings::hermes::http_request::api::{ErrorCode, Payload}, }; +static INIT_RUSTLS: LazyLock> = LazyLock::new(|| { + rustls::crypto::ring::default_provider() + .install_default() + .map_err(|_| { + tracing::error!("Failed to install default crypto provider for Rustls"); + ErrorCode::Internal + }) +}); + const HTTP: &str = "http://"; const HTTPS: &str = "https://"; @@ -81,6 +90,8 @@ impl Connection { tracing::trace!(%addr, port, "connected over HTTP"); return Ok(Connection::Http(stream)); } else if addr.as_ref().starts_with(HTTPS) { + (*INIT_RUSTLS)?; + // TODO[RC]: No need to configure RootCertStore for every connection let sliced_addr = &addr.as_ref()[HTTPS.len()..]; let mut root_store = RootCertStore::empty(); From 77992a4782a10d279cbd7cf42c7d423f35a1fa36 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 11:07:58 +0200 Subject: [PATCH 22/45] Init more RUSTLS machinery lazily --- .../hermes/http_request/mod.rs | 10 ++- .../hermes/http_request/tokio_runtime_task.rs | 62 +++++++++++-------- 2 files changed, 44 insertions(+), 28 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs index c6b18d3def..9200efeefe 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs @@ -3,7 +3,9 @@ #![allow(unused)] #![allow(dead_code)] -use std::sync::LazyLock; +use std::sync::{Arc, LazyLock, OnceLock, RwLock}; + +use tokio_rustls::TlsConnector; mod event; mod host; @@ -11,13 +13,17 @@ mod tokio_runtime_task; struct State { pub tokio_rt_handle: tokio_runtime_task::TokioTaskHandle, + pub tls_connector: OnceLock, } /// Http Request extension internal state. static STATE: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { let tokio_rt_handle = tokio_runtime_task::spawn(); - State { tokio_rt_handle } + State { + tokio_rt_handle, + tls_connector: OnceLock::new(), + } }); pub(crate) fn new_context(_ctx: &crate::runtime_context::HermesRuntimeContext) {} diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 82b9720278..cbc4608ae3 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -1,4 +1,4 @@ -use std::sync::{Arc, LazyLock}; +use std::sync::{Arc, LazyLock, RwLock}; use rustls::{pki_types::ServerName, ClientConfig, ClientConnection, RootCertStore, StreamOwned}; use thiserror::Error; @@ -13,18 +13,12 @@ use webpki_roots::TLS_SERVER_ROOTS; use crate::{ event::{HermesEvent, HermesEventPayload, TargetApp, TargetModule}, - runtime_extensions::bindings::hermes::http_request::api::{ErrorCode, Payload}, + runtime_extensions::{ + bindings::hermes::http_request::api::{ErrorCode, Payload}, + hermes::http_request::STATE, + }, }; -static INIT_RUSTLS: LazyLock> = LazyLock::new(|| { - rustls::crypto::ring::default_provider() - .install_default() - .map_err(|_| { - tracing::error!("Failed to install default crypto provider for Rustls"); - ErrorCode::Internal - }) -}); - const HTTP: &str = "http://"; const HTTPS: &str = "https://"; @@ -62,6 +56,26 @@ impl TokioTaskHandle { } } +static INIT_RUSTLS_CRYPTO: LazyLock> = LazyLock::new(|| { + rustls::crypto::ring::default_provider() + .install_default() + .map_err(|_| { + tracing::error!("Failed to install default crypto provider for Rustls"); + ErrorCode::Internal + }) +}); + +fn init_rustls_connector() -> TlsConnector { + let mut root_store = RootCertStore::empty(); + root_store.extend(TLS_SERVER_ROOTS.iter().cloned()); + + let config = ClientConfig::builder() + .with_root_certificates(root_store) + .with_no_client_auth(); + let config = Arc::new(config); + TlsConnector::from(config) +} + pub fn spawn() -> TokioTaskHandle { let (cmd_tx, cmd_rx) = tokio::sync::mpsc::channel(1); std::thread::spawn(move || { @@ -90,19 +104,10 @@ impl Connection { tracing::trace!(%addr, port, "connected over HTTP"); return Ok(Connection::Http(stream)); } else if addr.as_ref().starts_with(HTTPS) { - (*INIT_RUSTLS)?; + (*INIT_RUSTLS_CRYPTO)?; - // TODO[RC]: No need to configure RootCertStore for every connection let sliced_addr = &addr.as_ref()[HTTPS.len()..]; - let mut root_store = RootCertStore::empty(); - root_store.extend(TLS_SERVER_ROOTS.iter().cloned()); - - let config = ClientConfig::builder() - .with_root_certificates(root_store) - .with_no_client_auth(); - let config = Arc::new(config); - let connector = TlsConnector::from(config); - let tcp = TcpStream::connect((sliced_addr, port)) + let tcp_stream = TcpStream::connect((sliced_addr, port)) .await .map_err(|err| { tracing::debug!(%err, %sliced_addr, "tcp stream to HTTPs server"); @@ -114,10 +119,15 @@ impl Connection { ErrorCode::HttpsConnectionFailed })?; - let stream = connector.connect(server_name, tcp).await.map_err(|err| { - tracing::debug!(%err, %sliced_addr, "TLS handshake failed"); - ErrorCode::HttpsConnectionFailed - })?; + let stream = STATE + .tls_connector + .get_or_init(init_rustls_connector) + .connect(server_name, tcp_stream) + .await + .map_err(|err| { + tracing::debug!(%err, %sliced_addr, "TLS handshake failed"); + ErrorCode::HttpsConnectionFailed + })?; tracing::trace!(%addr, port, "connected over HTTPs"); return Ok(Connection::Https(stream)); From 445f712cf244a8151231acc580b4396deb40f624 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 11:08:35 +0200 Subject: [PATCH 23/45] Remove stray todo --- wasm/wasi/wit/deps/hermes-http-request/api.wit | 1 - 1 file changed, 1 deletion(-) diff --git a/wasm/wasi/wit/deps/hermes-http-request/api.wit b/wasm/wasi/wit/deps/hermes-http-request/api.wit index 4c02bc04e2..497c5071fe 100644 --- a/wasm/wasi/wit/deps/hermes-http-request/api.wit +++ b/wasm/wasi/wit/deps/hermes-http-request/api.wit @@ -21,7 +21,6 @@ interface api { /// HTTP request payload (caller manages full body formatting) record payload { /// Host URI (scheme + domain, no path), e.g., "http://example.com" - /// TODO[RC]: Invalid when unspecified host-uri: string, /// Port (e.g., 80 for HTTP, 443 for HTTPS) port: u16, From e013e1c797c1b2515043909fe79cc3748dcc5af7 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 11:21:10 +0200 Subject: [PATCH 24/45] Case insensitive scheme check --- .../hermes/http_request/tokio_runtime_task.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index cbc4608ae3..3ca6ba26ce 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -93,7 +93,7 @@ enum Connection { impl Connection { async fn new(addr: S, port: u16) -> Result where S: AsRef + Into + core::fmt::Display { - if addr.as_ref().starts_with(HTTP) { + if addr.as_ref().to_ascii_lowercase().starts_with(HTTP) { let sliced_addr = &addr.as_ref()[HTTP.len()..]; let stream = TcpStream::connect((sliced_addr, port)) .await @@ -103,7 +103,7 @@ impl Connection { })?; tracing::trace!(%addr, port, "connected over HTTP"); return Ok(Connection::Http(stream)); - } else if addr.as_ref().starts_with(HTTPS) { + } else if addr.as_ref().to_ascii_lowercase().starts_with(HTTPS) { (*INIT_RUSTLS_CRYPTO)?; let sliced_addr = &addr.as_ref()[HTTPS.len()..]; From 32474475888159109d191094455935b8cfca468f Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 11:29:02 +0200 Subject: [PATCH 25/45] Startup cleanup --- hermes/bin/src/cli/run.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/hermes/bin/src/cli/run.rs b/hermes/bin/src/cli/run.rs index 0da11c8db9..42ecb5a253 100644 --- a/hermes/bin/src/cli/run.rs +++ b/hermes/bin/src/cli/run.rs @@ -1,6 +1,6 @@ //! Run cli command -use std::{path::PathBuf, time::Duration}; +use std::path::PathBuf; use clap::Args; use console::Emoji; @@ -56,17 +56,10 @@ impl Run { Emoji::new("🛠️", ""), app.name() ); - - match reactor::load_app(app) { - Ok(r) => r, - Err(err) => println!("reactor loading err {err}"), - }; - println!("finished loading app"); + reactor::load_app(app)?; std::thread::yield_now(); - println!("yielded"); - println!("sleeping for 4 seconds"); - std::thread::sleep(Duration::from_secs(4)); + // TODO[RC]: Temporary hack to keep the reactor running. loop {} Ok(()) From a5031848933caf7b0b4d9513dfa112bf9663351e Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 11:29:10 +0200 Subject: [PATCH 26/45] Stub --- wasm/stub-module/stub-module.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wasm/stub-module/stub-module.c b/wasm/stub-module/stub-module.c index 014405a26d..3369a9a942 100644 --- a/wasm/stub-module/stub-module.c +++ b/wasm/stub-module/stub-module.c @@ -55,3 +55,7 @@ bool exports_hermes_integration_test_event_test(uint32_t test, bool run, exports bool exports_hermes_integration_test_event_bench(uint32_t test, bool run, exports_hermes_integration_test_event_test_result_t *ret) { return false; } + +void exports_hermes_http_request_event_on_http_response_on_http_response(uint64_t *maybe_request_id, hermes_list_u8_t *response) { + +} \ No newline at end of file From 6ae0817b28c65b3742c5612d7deb4df482eeb3f5 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 11:39:39 +0200 Subject: [PATCH 27/45] Clean-up unused dependencies --- hermes/bin/Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/hermes/bin/Cargo.toml b/hermes/bin/Cargo.toml index 19d07ba7af..1c3e092ca7 100644 --- a/hermes/bin/Cargo.toml +++ b/hermes/bin/Cargo.toml @@ -81,13 +81,10 @@ sha2 = "0.10.8" ed25519-dalek = { version="2.1.1", features = ["pem"] } x509-cert = { version="0.2.5", features = ["pem"] } coset = "0.3.8" -rust-ipfs = "0.14.1" dirs = "6.0.0" regex = "1.11.0" -reqwest = "0.12.22" rustls = "0.23.28" webpki-roots = "1.0.1" -webpki = "0.22.4" tokio-rustls = "0.26.2" [build-dependencies] From d4a80313bd1926e4af3ff6bad22b64829ee475cb Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 11:48:42 +0200 Subject: [PATCH 28/45] Cleanup --- hermes/bin/src/event/queue.rs | 10 ---------- hermes/bin/src/reactor.rs | 11 ----------- 2 files changed, 21 deletions(-) diff --git a/hermes/bin/src/event/queue.rs b/hermes/bin/src/event/queue.rs index 72bfd21dda..c19ab34668 100644 --- a/hermes/bin/src/event/queue.rs +++ b/hermes/bin/src/event/queue.rs @@ -40,19 +40,14 @@ struct HermesEventQueue { /// /// # Errors: /// - `AlreadyInitializedError` -#[allow(unreachable_code)] pub(crate) fn init() -> anyhow::Result<()> { - println!("entering init queue"); let (sender, receiver) = std::sync::mpsc::channel(); EVENT_QUEUE_INSTANCE .set(HermesEventQueue { sender }) .map_err(|_| AlreadyInitializedError)?; - println!("event queue instance set"); - thread::spawn(move || { - println!("spawning event thread"); event_execution_loop(receiver); }); Ok(()) @@ -118,11 +113,6 @@ fn targeted_app_event_execution(event: &HermesEvent) { /// Executes Hermes events from the provided receiver . fn event_execution_loop(receiver: Receiver) { for event in receiver { - println!("even target app: {:?}", event.target_app); - println!("even target module: {:?}", event.target_module); - targeted_app_event_execution(&event); } - - println!("finished execution loop!!"); } diff --git a/hermes/bin/src/reactor.rs b/hermes/bin/src/reactor.rs index 753c025b35..f9a56a5791 100644 --- a/hermes/bin/src/reactor.rs +++ b/hermes/bin/src/reactor.rs @@ -32,36 +32,25 @@ struct Reactor { /// Initialize Hermes Reactor. /// Setup and runs all necessary services. pub(crate) fn init() -> anyhow::Result<()> { - println!("entering init ok"); event::queue::init()?; - println!("init called ok"); - REACTOR_STATE .set(Reactor { apps: DashMap::new(), }) .map_err(|_| AlreadyInitializedError)?; - println!("reactor state set ok"); - Ok(()) } /// Load Hermes application into the Hermes Reactor. pub(crate) fn load_app(app: Application) -> anyhow::Result<()> { - println!("entering load app"); - let reactor = REACTOR_STATE.get().ok_or(NotInitializedError)?; - println!("got reactor state ok"); - let app_name = app.name().clone(); reactor.apps.insert(app_name.clone(), app); init::emit_init_event(app_name)?; - - println!("emit init event sent!"); Ok(()) } From fe9dbbcc0e0aef5ba52ff6ca3722a4611f3b933c Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 11:53:53 +0200 Subject: [PATCH 29/45] Cleanup --- .../hermes/http_request/host.rs | 2 +- .../hermes/http_request/mod.rs | 7 +----- .../hermes/http_request/tokio_runtime_task.rs | 23 +++++++++++-------- .../runtime_extensions/hermes/init/event.rs | 3 --- .../src/runtime_extensions/hermes/init/mod.rs | 2 -- wasm/wasi/Earthfile | 1 - 6 files changed, 15 insertions(+), 23 deletions(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs index 8937e22617..b50b6a9506 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/host.rs @@ -1,4 +1,4 @@ -//! Cardano Blockchain host implementation for WASM runtime. +//! Http Request host implementation for WASM runtime. use crate::{ runtime_context::HermesRuntimeContext, diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs index 9200efeefe..46708d8aaf 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/mod.rs @@ -1,9 +1,6 @@ //! Http Request extension implementation. -#![allow(unused)] -#![allow(dead_code)] - -use std::sync::{Arc, LazyLock, OnceLock, RwLock}; +use std::sync::OnceLock; use tokio_rustls::TlsConnector; @@ -28,7 +25,5 @@ static STATE: once_cell::sync::Lazy = once_cell::sync::Lazy::new(|| { pub(crate) fn new_context(_ctx: &crate::runtime_context::HermesRuntimeContext) {} -type Error = u32; - #[cfg(test)] mod test {} diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 3ca6ba26ce..27c2cfdb5e 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -1,18 +1,17 @@ -use std::sync::{Arc, LazyLock, RwLock}; +use std::sync::{Arc, LazyLock}; -use rustls::{pki_types::ServerName, ClientConfig, ClientConnection, RootCertStore, StreamOwned}; -use thiserror::Error; +use rustls::{pki_types::ServerName, ClientConfig, RootCertStore}; use tokio::{ - io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}, + io::{AsyncRead, AsyncReadExt, AsyncWriteExt}, net::TcpStream, - sync::{mpsc, oneshot}, + sync::oneshot, }; -use tokio_rustls::{client, TlsConnector, TlsStream}; +use tokio_rustls::{client, TlsConnector}; use tracing::{error, trace}; use webpki_roots::TLS_SERVER_ROOTS; use crate::{ - event::{HermesEvent, HermesEventPayload, TargetApp, TargetModule}, + event::{HermesEvent, TargetApp, TargetModule}, runtime_extensions::{ bindings::hermes::http_request::api::{ErrorCode, Payload}, hermes::http_request::STATE, @@ -151,7 +150,7 @@ impl Connection { .map_err(|err| { tracing::debug!(%err, "failed to read from HTTP server"); ErrorCode::HttpSendFailed - }); + })?; tracing::debug!(length_bytes = response.len(), "got response"); }, Connection::Https(tls_stream) => { @@ -164,7 +163,7 @@ impl Connection { .map_err(|err| { tracing::debug!(%err, "failed to read from HTTPs server"); ErrorCode::HttpsSendFailed - }); + })?; tracing::debug!(length_bytes = response.len(), "got response"); }, } @@ -201,7 +200,11 @@ async fn send_http_request(payload: Payload) -> Result<(), ErrorCode> { on_http_response_event, TargetApp::All, TargetModule::All, - )); + )) + .map_err(|err| { + tracing::error!(%err, "queue failure"); + ErrorCode::Internal + })?; Ok(()) } diff --git a/hermes/bin/src/runtime_extensions/hermes/init/event.rs b/hermes/bin/src/runtime_extensions/hermes/init/event.rs index cdbcd6698b..1173790ac6 100644 --- a/hermes/bin/src/runtime_extensions/hermes/init/event.rs +++ b/hermes/bin/src/runtime_extensions/hermes/init/event.rs @@ -10,10 +10,7 @@ impl HermesEventPayload for InitEvent { "init" } - #[allow(unreachable_code)] fn execute(&self, module: &mut crate::wasm::module::ModuleInstance) -> anyhow::Result<()> { - println!("executing init event"); - let _res = module .instance .hermes_init_event() diff --git a/hermes/bin/src/runtime_extensions/hermes/init/mod.rs b/hermes/bin/src/runtime_extensions/hermes/init/mod.rs index e9379b4703..198667b35d 100644 --- a/hermes/bin/src/runtime_extensions/hermes/init/mod.rs +++ b/hermes/bin/src/runtime_extensions/hermes/init/mod.rs @@ -19,8 +19,6 @@ pub(crate) fn emit_init_event(target_app: ApplicationName) -> anyhow::Result<()> TargetModule::All, ); - println!("sending init event"); hermes_event::queue::send(init_event)?; - println!("event has been sent!"); Ok(()) } diff --git a/wasm/wasi/Earthfile b/wasm/wasi/Earthfile index 1c99cb24ac..0ea8b8005a 100644 --- a/wasm/wasi/Earthfile +++ b/wasm/wasi/Earthfile @@ -80,7 +80,6 @@ build-rust-bindings: RUN wit-bindgen rust --generate-all -w hermes:wasi/hermes ../wasi/wit SAVE ARTIFACT hermes.rs -# SAVE ARTIFACT hermes.rs AS LOCAL hermes_bindings.rs # build-go-bindings - Generate tinygo bindings build-go-bindings: From d42f886e25342bff1db875d4efb4618a01fc179b Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 11:57:39 +0200 Subject: [PATCH 30/45] Cleanup --- hermes/bin/src/event/queue.rs | 1 - .../hermes/http_request/tokio_runtime_task.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/hermes/bin/src/event/queue.rs b/hermes/bin/src/event/queue.rs index c19ab34668..284acf6cc0 100644 --- a/hermes/bin/src/event/queue.rs +++ b/hermes/bin/src/event/queue.rs @@ -93,7 +93,6 @@ fn targeted_module_event_execution(target_app_name: &ApplicationName, event: &He /// Executes provided Hermes event filtering by target app. fn targeted_app_event_execution(event: &HermesEvent) { - println!("entering app event execution"); match event.target_app() { TargetApp::All => { if let Ok(target_apps) = reactor::get_all_app_names() { diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 27c2cfdb5e..291d042883 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -228,7 +228,7 @@ fn executor(mut cmd_rx: CommandReceiver) { let rt = match res { Ok(rt) => rt, Err(err) => { - error!(error = ?err, "Failed to start Http Request Runtime Extension background thread"); + error!(error = ?err, "failed to start Http Request Runtime Extension background thread"); return; }, }; From 6467abcde4dc979bb1821871fe79739917ca40f7 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 13:15:49 +0200 Subject: [PATCH 31/45] Add todo --- .../hermes/http_request/tokio_runtime_task.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 291d042883..075c9aeadc 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -175,6 +175,8 @@ async fn read_to_end_ignoring_unexpected_eof( reader: &mut R, buf: &mut Vec, ) -> std::io::Result where R: AsyncRead + Unpin { + // TODO[RC]: This won't work for payloads that do not include "Connection: close", we need + // a more sophisticated processing. match reader.read_to_end(buf).await { Ok(0) => Ok(0), Ok(n) => Ok(n), From 87b220863dda368de3d8da213252c6cf538d5633 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 13:25:43 +0200 Subject: [PATCH 32/45] Update comment --- .../hermes/http_request/tokio_runtime_task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 075c9aeadc..cabadc5fca 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -136,7 +136,7 @@ impl Connection { } } - // TODO[RC]: Timeout needed here, but maybe first switch to Tokio + // TODO[RC]: Timeout or more complex task management needed here async fn send(&mut self, body: &[u8]) -> Result, ErrorCode> { let mut response = Vec::new(); match self { From c74782f36901cc7fc7d4e59eaaab0e9f0e6d30e5 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Fri, 11 Jul 2025 13:26:53 +0200 Subject: [PATCH 33/45] Revert accidental changes --- hermes/bin/src/runtime_extensions/hermes/init/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/hermes/bin/src/runtime_extensions/hermes/init/mod.rs b/hermes/bin/src/runtime_extensions/hermes/init/mod.rs index 198667b35d..a7f29884fb 100644 --- a/hermes/bin/src/runtime_extensions/hermes/init/mod.rs +++ b/hermes/bin/src/runtime_extensions/hermes/init/mod.rs @@ -18,7 +18,6 @@ pub(crate) fn emit_init_event(target_app: ApplicationName) -> anyhow::Result<()> TargetApp::List(vec![target_app]), TargetModule::All, ); - hermes_event::queue::send(init_event)?; Ok(()) } From 20a575c45e1cec896bd40ff2065ea1970d49d532 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Tue, 15 Jul 2025 10:08:58 +0200 Subject: [PATCH 34/45] Update spellcheck dictionary --- .config/dictionaries/project.dic | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.config/dictionaries/project.dic b/.config/dictionaries/project.dic index 95fc629f25..7ecba503d2 100644 --- a/.config/dictionaries/project.dic +++ b/.config/dictionaries/project.dic @@ -153,6 +153,7 @@ pubk pubkey pubspec pwrite +rustls qpsg quic rapidoc @@ -213,6 +214,7 @@ wasip wasmtime webasm webassembly +webpki WORKDIR xprivate XPRV From c68d0437b0e866614652c3de00070771de24e9b5 Mon Sep 17 00:00:00 2001 From: no30bit Date: Tue, 15 Jul 2025 14:04:25 +0300 Subject: [PATCH 35/45] bump hermes-ipfs --- hermes/bin/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hermes/bin/Cargo.toml b/hermes/bin/Cargo.toml index 1c3e092ca7..d4e1eae613 100644 --- a/hermes/bin/Cargo.toml +++ b/hermes/bin/Cargo.toml @@ -37,7 +37,7 @@ blosc-src = { version = "0.3.4", features = ["lz4", "zlib", "zstd"] } criterion = {version = "0.6.0", optional=true} cardano-chain-follower = { path = "../crates/cardano-chain-follower", version = "0.0.1" } -hermes-ipfs = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "v0.0.3" } +hermes-ipfs = { version = "0.0.3", git = "https://github.com/input-output-hk/catalyst-libs.git", branch = "chore/hermes-ipfs-bump" } wasmtime = { version = "33.0.0", default-features = false, features = ["runtime", "cranelift", "component-model"] } rusty_ulid = "2.0.0" From 0eebaa9c2a0f773a61d02cae5a136b23f3a49f04 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Tue, 29 Jul 2025 10:54:22 +0200 Subject: [PATCH 36/45] Bump wasmtime --- hermes/bin/Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hermes/bin/Cargo.toml b/hermes/bin/Cargo.toml index 84b7501395..1c2785f337 100644 --- a/hermes/bin/Cargo.toml +++ b/hermes/bin/Cargo.toml @@ -46,7 +46,7 @@ criterion = {version = "0.6.0", optional=true} cardano-chain-follower = { path = "../crates/cardano-chain-follower", version = "0.0.1" } hermes-ipfs = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", branch = "chore/hermes-ipfs-bump" } -wasmtime = { version = "33.0.0", default-features = false, features = ["runtime", "cranelift", "component-model"] } +wasmtime = { version = "35.0.0", default-features = false, features = ["runtime", "cranelift", "component-model"] } rusty_ulid = "2.0.0" anyhow = "1.0.89" hex-literal = "1.0.0" @@ -104,7 +104,7 @@ build-info-build = "0.0.40" [dev-dependencies] serial_test = { version = "3.1.1", features = ["file_locks"] } # An override with the "wat" feature added. -wasmtime = { version = "33.0.0", default-features = false, features = ["runtime", "cranelift", "component-model", "wat"] } +wasmtime = { version = "35.0.0", default-features = false, features = ["runtime", "cranelift", "component-model", "wat"] } httpmock = "0.7.0" [package.metadata.cargo-machete] From 853ff06de2edef3d34fd0105a1a1559723c5b723 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Tue, 29 Jul 2025 10:55:06 +0200 Subject: [PATCH 37/45] Remove stray test placeholder --- wasm/integration-test/http_request/Earthfile | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 wasm/integration-test/http_request/Earthfile diff --git a/wasm/integration-test/http_request/Earthfile b/wasm/integration-test/http_request/Earthfile deleted file mode 100644 index 4efd3b078e..0000000000 --- a/wasm/integration-test/http_request/Earthfile +++ /dev/null @@ -1,3 +0,0 @@ -# Placeholder -# -# To be created after the wasm-related bump are done. \ No newline at end of file From 13de82cfc5f66b92025719a506759c15f457b095 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Tue, 29 Jul 2025 11:21:27 +0200 Subject: [PATCH 38/45] Allow fork --- hermes/deny.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hermes/deny.toml b/hermes/deny.toml index a9b164847d..c46f517378 100644 --- a/hermes/deny.toml +++ b/hermes/deny.toml @@ -58,6 +58,8 @@ allow-git = [ "https://github.com/txpipe/kes", "https://github.com/txpipe/curve25519-dalek", "https://github.com/input-output-hk/mithril", + # Maintained fork of an archived crates-io version. + "https://github.com/dariusc93/rust-ipfs", ] [licenses] From a31584178f27f99601cfa2b3a7c5bd1660c863ca Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Wed, 30 Jul 2025 12:42:59 +0200 Subject: [PATCH 39/45] Updates --- Earthfile | 4 ++-- docs/Earthfile | 2 +- hermes/Cargo.toml | 1 - hermes/Earthfile | 2 +- hermes/bin/src/event/queue.rs | 2 +- hermes/bin/src/hdf5/file.rs | 2 +- hermes/bin/src/runtime_context.rs | 6 ++++++ hermes/bin/src/runtime_extensions/hermes/cron/queue.rs | 2 +- .../hermes/http_request/tokio_runtime_task.rs | 1 + .../src/runtime_extensions/hermes/sqlite/connection/core.rs | 2 +- hermes/bin/src/runtime_extensions/hermes/sqlite/core.rs | 2 +- hermes/bin/src/wasm/module.rs | 2 +- hermes/crates/cardano-chain-follower/src/follow.rs | 1 - hermes/crates/cardano-chain-follower/testbed/Cargo.toml | 1 - .../cardano-chain-follower/testbed/rust-toolchain.toml | 2 +- hermes/deny.toml | 1 + hermes/rust-toolchain.toml | 2 +- wasm/examples/c/cardano_age/Earthfile | 2 +- wasm/examples/c/next_century/Earthfile | 2 +- wasm/examples/rust/cardano_age/Earthfile | 2 +- wasm/examples/rust/next_century/Earthfile | 2 +- wasm/integration-test/cardano/Earthfile | 2 +- wasm/integration-test/cardano/rust-toolchain.toml | 2 +- wasm/integration-test/clocks/Earthfile | 2 +- wasm/integration-test/cron/Earthfile | 2 +- wasm/integration-test/crypto/Earthfile | 2 +- wasm/integration-test/hashing/Earthfile | 2 +- wasm/integration-test/http_reply/Earthfile | 2 +- wasm/integration-test/http_reply/rust-toolchain.toml | 2 +- wasm/integration-test/ipfs/Earthfile | 2 +- wasm/integration-test/ipfs/rust-toolchain.toml | 2 +- wasm/integration-test/localtime/Earthfile | 2 +- wasm/integration-test/logger/Earthfile | 2 +- wasm/integration-test/smoke-test/Earthfile | 2 +- wasm/integration-test/sqlite/Earthfile | 2 +- wasm/integration-test/sqlite/rust-toolchain.toml | 2 +- wasm/integration-test/wasi-filesystem/Earthfile | 2 +- wasm/stub-module/Earthfile | 2 +- wasm/wasi/Earthfile | 2 +- 39 files changed, 42 insertions(+), 37 deletions(-) diff --git a/Earthfile b/Earthfile index 2089f26fd9..ae8d2b2a24 100644 --- a/Earthfile +++ b/Earthfile @@ -1,7 +1,7 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.4.5 AS mdlint-ci -IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.4.5 AS cspell-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.4.9 AS mdlint-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.4.9 AS cspell-ci # cspell: words livedocs sitedocs diff --git a/docs/Earthfile b/docs/Earthfile index d8f795ddad..25ca1d2108 100644 --- a/docs/Earthfile +++ b/docs/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.4.5 AS docs-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:93.4.5 AS docs-ci IMPORT .. AS repo IMPORT ../hermes AS hermes diff --git a/hermes/Cargo.toml b/hermes/Cargo.toml index 82c0de1662..fb098d5634 100644 --- a/hermes/Cargo.toml +++ b/hermes/Cargo.toml @@ -47,7 +47,6 @@ exit = "deny" get_unwrap = "deny" index_refutable_slice = "deny" indexing_slicing = "deny" -match_on_vec_items = "deny" match_wild_err_arm = "deny" missing_panics_doc = "deny" panic = "deny" diff --git a/hermes/Earthfile b/hermes/Earthfile index 1a969b4329..ec523de843 100644 --- a/hermes/Earthfile +++ b/hermes/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.5 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.9 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci diff --git a/hermes/bin/src/event/queue.rs b/hermes/bin/src/event/queue.rs index 6d0dcf63eb..f51ca7b706 100644 --- a/hermes/bin/src/event/queue.rs +++ b/hermes/bin/src/event/queue.rs @@ -121,7 +121,7 @@ fn targeted_module_event_execution(target_app_name: &ApplicationName, event: &He } } }, - }; + } } /// Executes provided Hermes event filtering by target app. diff --git a/hermes/bin/src/hdf5/file.rs b/hermes/bin/src/hdf5/file.rs index 8eb24f9c70..493018edc5 100644 --- a/hermes/bin/src/hdf5/file.rs +++ b/hermes/bin/src/hdf5/file.rs @@ -60,7 +60,7 @@ impl File { /// Convert arbitrary error to `std::io::Error`. #[allow(clippy::needless_pass_by_value)] fn map_to_io_error(err: impl ToString) -> std::io::Error { - std::io::Error::new(std::io::ErrorKind::Other, err.to_string()) + std::io::Error::other(err.to_string()) } impl std::io::Read for File { diff --git a/hermes/bin/src/runtime_context.rs b/hermes/bin/src/runtime_context.rs index d00e2e4bce..bbd43bd701 100644 --- a/hermes/bin/src/runtime_context.rs +++ b/hermes/bin/src/runtime_context.rs @@ -2,6 +2,8 @@ use std::sync::Arc; +use wasmtime::component::HasData; + use crate::{app::ApplicationName, vfs::Vfs, wasm::module::ModuleId}; /// Hermes Runtime Context. This is passed to the WASM runtime. @@ -23,6 +25,10 @@ pub(crate) struct HermesRuntimeContext { vfs: Arc, } +impl HasData for HermesRuntimeContext { + type Data<'a> = &'a mut Self; +} + impl HermesRuntimeContext { /// Creates a new instance of the `Context`. pub(crate) fn new( diff --git a/hermes/bin/src/runtime_extensions/hermes/cron/queue.rs b/hermes/bin/src/runtime_extensions/hermes/cron/queue.rs index b56971bf9c..4b7113b948 100644 --- a/hermes/bin/src/runtime_extensions/hermes/cron/queue.rs +++ b/hermes/bin/src/runtime_extensions/hermes/cron/queue.rs @@ -106,7 +106,7 @@ impl CronEventQueue { for OnCronEvent { tag, last } in cron_events { v.push((tag.clone(), *last)); } - }; + } v }) } else { diff --git a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs index 1755e96886..947d78f946 100644 --- a/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs +++ b/hermes/bin/src/runtime_extensions/hermes/http_request/tokio_runtime_task.rs @@ -98,6 +98,7 @@ pub fn spawn() -> TokioTaskHandle { } /// Represents a connection to an HTTP or HTTPS server. +#[allow(clippy::large_enum_variant)] enum Connection { /// Represents a plain HTTP connection. Http(TcpStream), diff --git a/hermes/bin/src/runtime_extensions/hermes/sqlite/connection/core.rs b/hermes/bin/src/runtime_extensions/hermes/sqlite/connection/core.rs index 25743b86bb..9f8a04a304 100644 --- a/hermes/bin/src/runtime_extensions/hermes/sqlite/connection/core.rs +++ b/hermes/bin/src/runtime_extensions/hermes/sqlite/connection/core.rs @@ -72,7 +72,7 @@ pub(crate) fn prepare(db_ptr: *mut sqlite3, sql: &str) -> Result<*mut sqlite3_st sql_cstring.as_ptr(), n_byte, 0, - &mut stmt_ptr, + &raw mut stmt_ptr, std::ptr::null_mut(), ) }; diff --git a/hermes/bin/src/runtime_extensions/hermes/sqlite/core.rs b/hermes/bin/src/runtime_extensions/hermes/sqlite/core.rs index b2f27a28f4..c536b76784 100644 --- a/hermes/bin/src/runtime_extensions/hermes/sqlite/core.rs +++ b/hermes/bin/src/runtime_extensions/hermes/sqlite/core.rs @@ -47,7 +47,7 @@ pub(super) fn open( let rc = unsafe { sqlite3_open_v2( db_path.to_string_lossy().as_ptr().cast(), - &mut db_ptr, + &raw mut db_ptr, flags, std::ptr::null(), ) diff --git a/hermes/bin/src/wasm/module.rs b/hermes/bin/src/wasm/module.rs index 1731739cff..0b0ffcadf6 100644 --- a/hermes/bin/src/wasm/module.rs +++ b/hermes/bin/src/wasm/module.rs @@ -90,7 +90,7 @@ impl Module { linker .allow_shadowing(true) .define_unknown_imports_as_traps(&wasm_module)?; - bindings::Hermes::add_to_linker( + bindings::Hermes::add_to_linker::<_, HermesRuntimeContext>( &mut linker, &LinkOptions::default(), |state: &mut HermesRuntimeContext| state, diff --git a/hermes/crates/cardano-chain-follower/src/follow.rs b/hermes/crates/cardano-chain-follower/src/follow.rs index 718e6a62f7..57b432c8ae 100644 --- a/hermes/crates/cardano-chain-follower/src/follow.rs +++ b/hermes/crates/cardano-chain-follower/src/follow.rs @@ -501,7 +501,6 @@ mod task { } Err(_) => { drop(response_tx.send(Err(crate::Error::SetReadPointer))); - continue; } } } diff --git a/hermes/crates/cardano-chain-follower/testbed/Cargo.toml b/hermes/crates/cardano-chain-follower/testbed/Cargo.toml index 4c8c53d880..ed4318e847 100644 --- a/hermes/crates/cardano-chain-follower/testbed/Cargo.toml +++ b/hermes/crates/cardano-chain-follower/testbed/Cargo.toml @@ -32,7 +32,6 @@ exit = "deny" get_unwrap = "deny" index_refutable_slice = "deny" indexing_slicing = "deny" -match_on_vec_items = "deny" match_wild_err_arm = "deny" missing_panics_doc = "deny" panic = "deny" diff --git a/hermes/crates/cardano-chain-follower/testbed/rust-toolchain.toml b/hermes/crates/cardano-chain-follower/testbed/rust-toolchain.toml index 5bedd373fc..c2ee2a8766 100644 --- a/hermes/crates/cardano-chain-follower/testbed/rust-toolchain.toml +++ b/hermes/crates/cardano-chain-follower/testbed/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.85" +channel = "1.88" profile = "default" diff --git a/hermes/deny.toml b/hermes/deny.toml index c46f517378..d69e5b5565 100644 --- a/hermes/deny.toml +++ b/hermes/deny.toml @@ -83,6 +83,7 @@ allow = [ "Zlib", "MIT-0", "CDLA-Permissive-2.0", + "OpenSSL", ] exceptions = [ #{ allow = ["Zlib"], crate = "tinyvec" }, diff --git a/hermes/rust-toolchain.toml b/hermes/rust-toolchain.toml index 8c8ca6d417..17b9824d90 100644 --- a/hermes/rust-toolchain.toml +++ b/hermes/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.85" +channel = "1.88" profile = "default" \ No newline at end of file diff --git a/wasm/examples/c/cardano_age/Earthfile b/wasm/examples/c/cardano_age/Earthfile index 5a949fa02f..79ebd94cf0 100644 --- a/wasm/examples/c/cardano_age/Earthfile +++ b/wasm/examples/c/cardano_age/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.5 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.9 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/examples/c/next_century/Earthfile b/wasm/examples/c/next_century/Earthfile index 6a39cc94f7..6f2e3f2c57 100644 --- a/wasm/examples/c/next_century/Earthfile +++ b/wasm/examples/c/next_century/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.5 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:3.4.9 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/examples/rust/cardano_age/Earthfile b/wasm/examples/rust/cardano_age/Earthfile index 72425ca09d..b747160af2 100644 --- a/wasm/examples/rust/cardano_age/Earthfile +++ b/wasm/examples/rust/cardano_age/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.5 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.9 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/rust AS rust-ci diff --git a/wasm/examples/rust/next_century/Earthfile b/wasm/examples/rust/next_century/Earthfile index 4b470e0467..80497cc36b 100644 --- a/wasm/examples/rust/next_century/Earthfile +++ b/wasm/examples/rust/next_century/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.5 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.9 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/rust AS rust-ci diff --git a/wasm/integration-test/cardano/Earthfile b/wasm/integration-test/cardano/Earthfile index f7d76467ea..262904de39 100644 --- a/wasm/integration-test/cardano/Earthfile +++ b/wasm/integration-test/cardano/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.5 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.9 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci diff --git a/wasm/integration-test/cardano/rust-toolchain.toml b/wasm/integration-test/cardano/rust-toolchain.toml index a9895023f1..9362c8b07a 100644 --- a/wasm/integration-test/cardano/rust-toolchain.toml +++ b/wasm/integration-test/cardano/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.85" +channel = "1.88" targets = ["wasm32-wasip2"] diff --git a/wasm/integration-test/clocks/Earthfile b/wasm/integration-test/clocks/Earthfile index cf75ad9e3a..42174be478 100644 --- a/wasm/integration-test/clocks/Earthfile +++ b/wasm/integration-test/clocks/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.5 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.9 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/cron/Earthfile b/wasm/integration-test/cron/Earthfile index 9689e2ee20..92a391bbf6 100644 --- a/wasm/integration-test/cron/Earthfile +++ b/wasm/integration-test/cron/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.5 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.9 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/crypto/Earthfile b/wasm/integration-test/crypto/Earthfile index 1cd0934bc4..4b860abb93 100644 --- a/wasm/integration-test/crypto/Earthfile +++ b/wasm/integration-test/crypto/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.5 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.9 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/hashing/Earthfile b/wasm/integration-test/hashing/Earthfile index d0bf68d038..01eebe400b 100644 --- a/wasm/integration-test/hashing/Earthfile +++ b/wasm/integration-test/hashing/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.5 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.9 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/http_reply/Earthfile b/wasm/integration-test/http_reply/Earthfile index 64ebf744b9..597f89b668 100644 --- a/wasm/integration-test/http_reply/Earthfile +++ b/wasm/integration-test/http_reply/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.5 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.9 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci diff --git a/wasm/integration-test/http_reply/rust-toolchain.toml b/wasm/integration-test/http_reply/rust-toolchain.toml index a9895023f1..9362c8b07a 100644 --- a/wasm/integration-test/http_reply/rust-toolchain.toml +++ b/wasm/integration-test/http_reply/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.85" +channel = "1.88" targets = ["wasm32-wasip2"] diff --git a/wasm/integration-test/ipfs/Earthfile b/wasm/integration-test/ipfs/Earthfile index a4b472cda8..70a5fdc706 100644 --- a/wasm/integration-test/ipfs/Earthfile +++ b/wasm/integration-test/ipfs/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.5 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.9 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci diff --git a/wasm/integration-test/ipfs/rust-toolchain.toml b/wasm/integration-test/ipfs/rust-toolchain.toml index a9895023f1..9362c8b07a 100644 --- a/wasm/integration-test/ipfs/rust-toolchain.toml +++ b/wasm/integration-test/ipfs/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.85" +channel = "1.88" targets = ["wasm32-wasip2"] diff --git a/wasm/integration-test/localtime/Earthfile b/wasm/integration-test/localtime/Earthfile index a0227df177..fc63731c29 100644 --- a/wasm/integration-test/localtime/Earthfile +++ b/wasm/integration-test/localtime/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.5 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.9 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/logger/Earthfile b/wasm/integration-test/logger/Earthfile index ae167ca6ed..8e59bdb5f6 100644 --- a/wasm/integration-test/logger/Earthfile +++ b/wasm/integration-test/logger/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.5 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.9 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/smoke-test/Earthfile b/wasm/integration-test/smoke-test/Earthfile index 47cf2f9148..54a6c9e4fb 100644 --- a/wasm/integration-test/smoke-test/Earthfile +++ b/wasm/integration-test/smoke-test/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.5 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.9 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/integration-test/sqlite/Earthfile b/wasm/integration-test/sqlite/Earthfile index 40c998dca0..341a5ecbd5 100644 --- a/wasm/integration-test/sqlite/Earthfile +++ b/wasm/integration-test/sqlite/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.5 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.9 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci diff --git a/wasm/integration-test/sqlite/rust-toolchain.toml b/wasm/integration-test/sqlite/rust-toolchain.toml index a9895023f1..9362c8b07a 100644 --- a/wasm/integration-test/sqlite/rust-toolchain.toml +++ b/wasm/integration-test/sqlite/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.85" +channel = "1.88" targets = ["wasm32-wasip2"] diff --git a/wasm/integration-test/wasi-filesystem/Earthfile b/wasm/integration-test/wasi-filesystem/Earthfile index 1e246d43e0..1b1107f1bc 100644 --- a/wasm/integration-test/wasi-filesystem/Earthfile +++ b/wasm/integration-test/wasi-filesystem/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.5 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.9 AS rust-ci # Use when debugging cat-ci locally. # IMPORT ../../catalyst-ci/earthly/rust AS rust-ci diff --git a/wasm/stub-module/Earthfile b/wasm/stub-module/Earthfile index 008c894c02..e64bb6318b 100644 --- a/wasm/stub-module/Earthfile +++ b/wasm/stub-module/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.5 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.9 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci diff --git a/wasm/wasi/Earthfile b/wasm/wasi/Earthfile index 51e35a00db..ee8c1a78cf 100644 --- a/wasm/wasi/Earthfile +++ b/wasm/wasi/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.5 AS rust-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.4.9 AS rust-ci IMPORT github.com/input-output-hk/catalyst-ci/earthly/go:v3.4.8 AS go-ci # Use when debugging cat-ci locally. From 49ba7bd550f20cc89a55ee14b317079849be399f Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Wed, 30 Jul 2025 12:48:44 +0200 Subject: [PATCH 40/45] CI version fix --- wasm/examples/c/next_century/Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wasm/examples/c/next_century/Earthfile b/wasm/examples/c/next_century/Earthfile index 6f2e3f2c57..2f4f212bd6 100644 --- a/wasm/examples/c/next_century/Earthfile +++ b/wasm/examples/c/next_century/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:3.4.9 AS wasm-c-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/wasm/c:v3.4.9 AS wasm-c-ci # Use when debugging cat-ci locally. # IMPORT ../../../../catalyst-ci/earthly/wasm/c AS wasm-c-ci From 292c6f20b9bbc752f794bca1dfd972da8a0ce128 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Wed, 30 Jul 2025 22:49:07 +0200 Subject: [PATCH 41/45] Temporarily point to the `main` branch of catalyst-libs --- hermes/bin/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hermes/bin/Cargo.toml b/hermes/bin/Cargo.toml index 1c2785f337..f3c58f0d9c 100644 --- a/hermes/bin/Cargo.toml +++ b/hermes/bin/Cargo.toml @@ -44,7 +44,7 @@ yamux = "=0.13.5" criterion = {version = "0.6.0", optional=true} cardano-chain-follower = { path = "../crates/cardano-chain-follower", version = "0.0.1" } -hermes-ipfs = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", branch = "chore/hermes-ipfs-bump" } +hermes-ipfs = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", branch = "main" } wasmtime = { version = "35.0.0", default-features = false, features = ["runtime", "cranelift", "component-model"] } rusty_ulid = "2.0.0" From 30a90df03a30cf89e78ffb5245f078aa7ba80ef2 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Wed, 30 Jul 2025 22:49:27 +0200 Subject: [PATCH 42/45] Create .ipfs repo directory if it does not exist --- hermes/bin/src/ipfs/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hermes/bin/src/ipfs/mod.rs b/hermes/bin/src/ipfs/mod.rs index 1a68f8e6d1..fb97947ee6 100644 --- a/hermes/bin/src/ipfs/mod.rs +++ b/hermes/bin/src/ipfs/mod.rs @@ -49,6 +49,10 @@ pub(crate) static HERMES_IPFS: OnceCell = OnceCell::new(); /// Returns errors if IPFS node fails to start. pub fn bootstrap(base_dir: &Path, default_bootstrap: bool) -> anyhow::Result<()> { let ipfs_data_path = base_dir.join("ipfs"); + if !ipfs_data_path.exists() { + tracing::info!("creating IPFS repo directory: {}", ipfs_data_path.display()); + std::fs::create_dir_all(&ipfs_data_path)?; + } let ipfs_node = HermesIpfsNode::init( IpfsBuilder::new() .with_default() From 6125fa509dc287b8085728b8ac222fbf27995a39 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Thu, 31 Jul 2025 11:00:38 +0200 Subject: [PATCH 43/45] Fix docs build --- docs/Earthfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Earthfile b/docs/Earthfile index 25ca1d2108..003161cb6b 100644 --- a/docs/Earthfile +++ b/docs/Earthfile @@ -1,6 +1,6 @@ VERSION 0.8 -IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:93.4.5 AS docs-ci +IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.4.9 AS docs-ci IMPORT .. AS repo IMPORT ../hermes AS hermes From 74c00e577785887086ef0c0ad869add80c4f25a1 Mon Sep 17 00:00:00 2001 From: rafal-ch Date: Thu, 31 Jul 2025 12:50:21 +0200 Subject: [PATCH 44/45] Bump `hermes-ipfs` --- hermes/bin/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hermes/bin/Cargo.toml b/hermes/bin/Cargo.toml index f3c58f0d9c..14da5be8fe 100644 --- a/hermes/bin/Cargo.toml +++ b/hermes/bin/Cargo.toml @@ -44,7 +44,7 @@ yamux = "=0.13.5" criterion = {version = "0.6.0", optional=true} cardano-chain-follower = { path = "../crates/cardano-chain-follower", version = "0.0.1" } -hermes-ipfs = { version = "0.0.4", git = "https://github.com/input-output-hk/catalyst-libs.git", branch = "main" } +hermes-ipfs = { version = "0.0.5", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "hermes-ipfs/v0.0.5" } wasmtime = { version = "35.0.0", default-features = false, features = ["runtime", "cranelift", "component-model"] } rusty_ulid = "2.0.0" From 17ad1c6c4699dde8e21b8d0c8563521e5630db49 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Thu, 31 Jul 2025 21:37:37 +0700 Subject: [PATCH 45/45] fix(hermes): Bumping every dependency to latest we can, and add back Cargo.lock (#458) * fix(hermes): start bumping everything thats old * fix(hermes): More dependency bumps and a spelling update * fix(hermes): Bump the last dependencies, and add back Cargo.lock because Hermes is an app. --- .gitignore | 2 +- hermes/.gitignore | 3 + hermes/Cargo.lock | 9183 +++++++++++++++++++++++++++++++++++++++++ hermes/bin/Cargo.toml | 84 +- wasm/.cspell.json | 65 +- 5 files changed, 9261 insertions(+), 76 deletions(-) create mode 100644 hermes/Cargo.lock diff --git a/.gitignore b/.gitignore index c3453566fa..7629e14a10 100644 --- a/.gitignore +++ b/.gitignore @@ -91,4 +91,4 @@ $RECYCLE.BIN/ # Specifically exclude it in the directory it appears, if its required. # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html Cargo.lock -wasm/integration-test/http-request/target +**/target/** diff --git a/hermes/.gitignore b/hermes/.gitignore index 26a45d186c..3e55c7ed05 100644 --- a/hermes/.gitignore +++ b/hermes/.gitignore @@ -4,6 +4,9 @@ debug/ target/ +# This is an application so allow Cargo lock for now. +!Cargo.lock + # This file is only used for local development/debugging bindings.rs diff --git a/hermes/Cargo.lock b/hermes/Cargo.lock new file mode 100644 index 0000000000..c44896c9c7 --- /dev/null +++ b/hermes/Cargo.lock @@ -0,0 +1,9183 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common", + "generic-array", +] + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "aes-gcm" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +dependencies = [ + "aead", + "aes", + "cipher", + "ctr", + "ghash", + "subtle", +] + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "getrandom 0.3.3", + "once_cell", + "serde", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "alloc-no-stdlib" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" + +[[package]] +name = "alloc-stdlib" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +dependencies = [ + "alloc-no-stdlib", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anes" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" + +[[package]] +name = "anstream" +version = "0.6.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.59.0", +] + +[[package]] +name = "anyhow" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" + +[[package]] +name = "arbitrary" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + +[[package]] +name = "ascii" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16" + +[[package]] +name = "ascii-canvas" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8824ecca2e851cec16968d54a01dd372ef8f95b244fb84b84e70128be347c3c6" +dependencies = [ + "term", +] + +[[package]] +name = "asn1-rs" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5493c3bedbacf7fd7382c6346bbd66687d12bbaad3a89a2d2c303ee6cf20b048" +dependencies = [ + "asn1-rs-derive 0.5.1", + "asn1-rs-impl", + "displaydoc", + "nom 7.1.3", + "num-traits", + "rusticata-macros", + "thiserror 1.0.69", + "time", +] + +[[package]] +name = "asn1-rs" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56624a96882bb8c26d61312ae18cb45868e5a9992ea73c58e45c3101e56a1e60" +dependencies = [ + "asn1-rs-derive 0.6.0", + "asn1-rs-impl", + "displaydoc", + "nom 7.1.3", + "num-traits", + "rusticata-macros", + "thiserror 2.0.12", + "time", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "965c2d33e53cb6b267e148a4cb0760bc01f4904c1cd4bb4002a085bb016d1490" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", + "synstructure", +] + +[[package]] +name = "asn1-rs-derive" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3109e49b1e4909e9db6515a30c633684d68cdeaa252f215214cb4fa1a5bfee2c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", + "synstructure", +] + +[[package]] +name = "asn1-rs-impl" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b18050c2cd6fe86c3a76584ef5e0baf286d038cda203eb6223df2cc413565f7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "asn1_der" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "155a5a185e42c6b77ac7b88a15143d930a9e9727a5b7b77eed417404ab15c247" + +[[package]] +name = "assert-json-diff" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e4f2b81832e72834d7518d8487a0396a28cc408186a2e8854c0f98011faf12" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "async-attributes" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" +dependencies = [ + "quote", + "syn 1.0.109", +] + +[[package]] +name = "async-channel" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" +dependencies = [ + "concurrent-queue", + "event-listener 2.5.3", + "futures-core", +] + +[[package]] +name = "async-channel" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb812ffb58524bdd10860d7d974e2f01cc0950c2438a74ee5ec2e2280c6c4ffa" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand", + "futures-lite", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" +dependencies = [ + "async-channel 2.5.0", + "async-executor", + "async-io", + "async-lock", + "blocking", + "futures-lite", + "once_cell", +] + +[[package]] +name = "async-io" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19634d6336019ef220f09fd31168ce5c184b295cbf80345437cc36094ef223ca" +dependencies = [ + "async-lock", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite", + "parking", + "polling", + "rustix 1.0.8", + "slab", + "windows-sys 0.60.2", +] + +[[package]] +name = "async-lock" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" +dependencies = [ + "event-listener 5.4.0", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-object-pool" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "333c456b97c3f2d50604e8b2624253b7f787208cb72eb75e64b0ad11b221652c" +dependencies = [ + "async-std", +] + +[[package]] +name = "async-process" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65daa13722ad51e6ab1a1b9c01299142bc75135b337923cfa10e79bbbd669f00" +dependencies = [ + "async-channel 2.5.0", + "async-io", + "async-lock", + "async-signal", + "async-task", + "blocking", + "cfg-if", + "event-listener 5.4.0", + "futures-lite", + "rustix 1.0.8", +] + +[[package]] +name = "async-rt" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2148ff00ee6e15870ba6e30e605f905ea89b46bad8f87916afd7792530fde9b1" +dependencies = [ + "futures", + "parking_lot", + "tokio", + "wasm-bindgen-futures", +] + +[[package]] +name = "async-signal" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f567af260ef69e1d52c2b560ce0ea230763e6fbb9214a85d768760a920e3e3c1" +dependencies = [ + "async-io", + "async-lock", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix 1.0.8", + "signal-hook-registry", + "slab", + "windows-sys 0.60.2", +] + +[[package]] +name = "async-std" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "730294c1c08c2e0f85759590518f6333f0d5a0a766a27d519c1b244c3dfd8a24" +dependencies = [ + "async-attributes", + "async-channel 1.9.0", + "async-global-executor", + "async-io", + "async-lock", + "async-process", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite", + "gloo-timers 0.3.0", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + +[[package]] +name = "async-stream" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" +dependencies = [ + "async-stream-impl", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + +[[package]] +name = "async-trait" +version = "0.1.88" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e539d3fca749fcee5236ab05e93a52867dd549cc157c8cb7f99595f3cedffdb5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "asynchronous-codec" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a860072022177f903e59730004fb5dc13db9275b79bb2aef7ba8ce831956c233" +dependencies = [ + "bytes", + "futures-sink", + "futures-util", + "memchr", + "pin-project-lite", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "attohttpc" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16e2cdb6d5ed835199484bb92bb8b3edd526effe995c61732580439c1a67e2e9" +dependencies = [ + "base64 0.22.1", + "http 1.3.1", + "log", + "url", +] + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "axum" +version = "0.6.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +dependencies = [ + "async-trait", + "axum-core", + "bitflags 1.3.2", + "bytes", + "futures-util", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.32", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "sync_wrapper 0.1.2", + "tower 0.4.13", + "tower-layer", + "tower-service", +] + +[[package]] +name = "axum-core" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +dependencies = [ + "async-trait", + "bytes", + "futures-util", + "http 0.2.12", + "http-body 0.4.6", + "mime", + "rustversion", + "tower-layer", + "tower-service", +] + +[[package]] +name = "backtrace" +version = "0.3.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] + +[[package]] +name = "base-x" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" + +[[package]] +name = "base16ct" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" + +[[package]] +name = "base58" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64ct" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55248b47b0caf0546f7988906588779981c43bb1bc9d0c44087278f80cdb44ba" + +[[package]] +name = "basic-cookies" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67bd8fd42c16bdb08688243dc5f0cc117a3ca9efeeaba3a345a18a6159ad96f7" +dependencies = [ + "lalrpop", + "lalrpop-util", + "regex", +] + +[[package]] +name = "bech32" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" + +[[package]] +name = "bimap" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "230c5f1ca6a325a32553f8640d31ac9b49f2411e901e427570154868b46da4f7" + +[[package]] +name = "binary-layout" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5845e3504cf59b9588fff324710f27ee519515b8a8a9f1207042da9a9e64f819" +dependencies = [ + "doc-comment", + "paste", +] + +[[package]] +name = "bincode" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36eaf5d7b090263e8150820482d5d93cd964a81e4019913c972f4edcc6edb740" +dependencies = [ + "bincode_derive", + "serde", + "unty", +] + +[[package]] +name = "bincode_derive" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf95709a440f45e986983918d0e8a1f30a9b1df04918fc828670606804ac3c09" +dependencies = [ + "virtue", +] + +[[package]] +name = "bip32" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db40d3dfbeab4e031d78c844642fa0caa0b0db11ce1607ac9d2986dff1405c69" +dependencies = [ + "bs58", + "hmac", + "k256", + "once_cell", + "pbkdf2", + "rand_core 0.6.4", + "ripemd", + "secp256k1", + "sha2", + "subtle", + "zeroize", +] + +[[package]] +name = "bip39" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d193de1f7487df1914d3a568b772458861d33f9c54249612cc2893d6915054" +dependencies = [ + "bitcoin_hashes", + "rand_core 0.6.4", + "serde", + "unicode-normalization", +] + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec 0.6.3", +] + +[[package]] +name = "bit-set" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +dependencies = [ + "bit-vec 0.8.0", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bit-vec" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" + +[[package]] +name = "bitcoin-internals" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9425c3bf7089c983facbae04de54513cce73b41c7f9ff8c845b54e7bc64ebbfb" + +[[package]] +name = "bitcoin_hashes" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1930a4dabfebb8d7d9992db18ebe3ae2876f0a305fab206fd168df931ede293b" +dependencies = [ + "bitcoin-internals", + "hex-conservative", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" + +[[package]] +name = "blake2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe" +dependencies = [ + "digest", +] + +[[package]] +name = "blake2b_simd" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06e903a20b159e944f91ec8499fe1e55651480c541ea0a584f5d967c49ad9d99" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "blake2s_simd" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e90f7deecfac93095eb874a40febd69427776e24e1bd7f87f33ac62d6f0174df" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] + +[[package]] +name = "blake3" +version = "1.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3888aaa89e4b2a40fca9848e400f6a658a5a3978de7be858e209cafa8be9a4a0" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", +] + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "blocking" +version = "1.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83f8d02be6967315521be875afa792a316e28d57b5a2d401897e2a7921b7f21" +dependencies = [ + "async-channel 2.5.0", + "async-task", + "futures-io", + "futures-lite", + "piper", +] + +[[package]] +name = "blosc-src" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68d27ab5ceb94ae9cd343f6fbc7bb84543496d547ed7c0db6718175fd41cb6" +dependencies = [ + "cc", + "libz-sys", + "lz4-sys", + "zstd-sys", +] + +[[package]] +name = "borrow-or-share" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3eeab4423108c5d7c744f4d234de88d18d636100093ae04caf4825134b9c3a32" + +[[package]] +name = "brotli" +version = "8.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9991eea70ea4f293524138648e41ee89b0b2b12ddef3b255effa43c8056e0e0d" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", + "brotli-decompressor", +] + +[[package]] +name = "brotli-decompressor" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03" +dependencies = [ + "alloc-no-stdlib", + "alloc-stdlib", +] + +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "sha2", + "tinyvec", +] + +[[package]] +name = "build-info" +version = "0.0.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e232cc6fad4ac9f969bba34440da4d45947a55e60008fbaf5342163f30d6d34" +dependencies = [ + "bincode", + "build-info-common", + "build-info-proc", +] + +[[package]] +name = "build-info-build" +version = "0.0.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c095501b4684e681005757c3171fccf3b8a4132a8cf8e5135b6a885068cd413e" +dependencies = [ + "anyhow", + "base64 0.22.1", + "bincode", + "build-info-common", + "cargo_metadata", + "chrono", + "git2", + "glob", + "pretty_assertions", + "rustc_version", + "serde_json", + "zstd", +] + +[[package]] +name = "build-info-common" +version = "0.0.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b409ed3b3b89db66e81ed7df221d30a1d78c298e719472cac30b21dfdacf9ce" +dependencies = [ + "chrono", + "derive_more", + "semver", + "serde", +] + +[[package]] +name = "build-info-proc" +version = "0.0.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fc6a2f7c956ef2a43081719feb90f90998ad1343c770db43bcdbfbc63894db8" +dependencies = [ + "anyhow", + "base64 0.22.1", + "bincode", + "build-info-common", + "chrono", + "num-bigint", + "num-traits", + "proc-macro-error2", + "proc-macro2", + "quote", + "serde_json", + "syn 2.0.104", + "zstd", +] + +[[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" +dependencies = [ + "allocator-api2", +] + +[[package]] +name = "bytecount" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175812e0be2bccb6abe50bb8d566126198344f707e304f45c648fd8f2cc0365e" + +[[package]] +name = "bytemuck" +version = "1.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c76a5792e44e4abe34d3abf15636779261d45a7450612059293d1d2cfc63422" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +dependencies = [ + "serde", +] + +[[package]] +name = "camino" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0da45bc31171d8d6960122e222a67740df867c1dd53b4d51caa297084c185cab" +dependencies = [ + "serde", +] + +[[package]] +name = "cardano-chain-follower" +version = "0.0.1" +dependencies = [ + "hex", + "pallas", + "pallas-hardano", + "thiserror 2.0.12", + "tokio", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "cargo-platform" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84982c6c0ae343635a3a4ee6dedef965513735c8b183caa7289fa6e27399ebd4" +dependencies = [ + "serde", +] + +[[package]] +name = "cargo-util-schemas" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e63d2780ac94487eb9f1fea7b0d56300abc9eb488800854ca217f102f5caccca" +dependencies = [ + "semver", + "serde", + "serde-untagged", + "serde-value", + "thiserror 1.0.69", + "toml", + "unicode-xid", + "url", +] + +[[package]] +name = "cargo_metadata" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f7835cfc6135093070e95eb2b53e5d9b5c403dc3a6be6040ee026270aa82502" +dependencies = [ + "camino", + "cargo-platform", + "cargo-util-schemas", + "semver", + "serde", + "serde_json", + "thiserror 2.0.12", +] + +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + +[[package]] +name = "cbor4ii" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544cf8c89359205f4f990d0e6f3828db42df85b5dac95d09157a250eb0749c4" +dependencies = [ + "serde", +] + +[[package]] +name = "cbor4ii" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "472931dd4dfcc785075b09be910147f9c6258883fc4591d0dac6116392b2daa6" +dependencies = [ + "serde", +] + +[[package]] +name = "cc" +version = "1.2.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7" +dependencies = [ + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" + +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + +[[package]] +name = "chacha20" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" +dependencies = [ + "cfg-if", + "cipher", + "cpufeatures", +] + +[[package]] +name = "chacha20poly1305" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +dependencies = [ + "aead", + "chacha20", + "cipher", + "poly1305", + "zeroize", +] + +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "chrono-tz" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6139a8597ed92cf816dfb33f5dd6cf0bb93a6adc938f11039f371bc5bcd26c3" +dependencies = [ + "chrono", + "phf", +] + +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half 2.6.0", +] + +[[package]] +name = "cid" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3147d8272e8fa0ccd29ce51194dd98f79ddfb8191ba9e3409884e751798acf3a" +dependencies = [ + "core2", + "multibase", + "multihash", + "serde", + "serde_bytes", + "unsigned-varint 0.8.0", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common", + "inout", + "zeroize", +] + +[[package]] +name = "clap" +version = "4.5.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "clap_lex" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" + +[[package]] +name = "cmake" +version = "0.1.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7caa3f9de89ddbe2c607f4101924c5abec803763ae9534e4f4d7d8f84aa81f0" +dependencies = [ + "cc", +] + +[[package]] +name = "cobs" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa961b519f0b462e3a3b4a34b64d119eeaca1d59af726fe450bbba07a9fc0a1" +dependencies = [ + "thiserror 2.0.12", +] + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "console" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e09ced7ebbccb63b4c65413d821f2e00ce54c5ca4514ddc6b3c892fdbcbc69d" +dependencies = [ + "encode_unicode", + "libc", + "once_cell", + "unicode-width", + "windows-sys 0.60.2", +] + +[[package]] +name = "const-oid" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" + +[[package]] +name = "constant_time_eq" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" + +[[package]] +name = "convert_case" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb402b8d4c85569410425650ce3eddc7d698ed96d39a73f941b08fb63082f1e7" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "core2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" +dependencies = [ + "memchr", +] + +[[package]] +name = "core_maths" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30" +dependencies = [ + "libm", +] + +[[package]] +name = "coset" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8cc80f631f8307b887faca24dcc3abc427cd0367f6eb6188f6e8f5b7ad8fb" +dependencies = [ + "ciborium", + "ciborium-io", +] + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "cranelift-assembler-x64" +version = "0.122.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae7b60ec3fd7162427d3b3801520a1908bef7c035b52983cd3ca11b8e7deb51" +dependencies = [ + "cranelift-assembler-x64-meta", +] + +[[package]] +name = "cranelift-assembler-x64-meta" +version = "0.122.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6511c200fed36452697b4b6b161eae57d917a2044e6333b1c1389ed63ccadeee" +dependencies = [ + "cranelift-srcgen", +] + +[[package]] +name = "cranelift-bforest" +version = "0.122.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f7086a645aa58bae979312f64e3029ac760ac1b577f5cd2417844842a2ca07f" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-bitset" +version = "0.122.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5225b4dec45f3f3dbf383f12560fac5ce8d780f399893607e21406e12e77f491" +dependencies = [ + "serde", + "serde_derive", +] + +[[package]] +name = "cranelift-codegen" +version = "0.122.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "858fb3331e53492a95979378d6df5208dd1d0d315f19c052be8115f4efc888e0" +dependencies = [ + "bumpalo", + "cranelift-assembler-x64", + "cranelift-bforest", + "cranelift-bitset", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-control", + "cranelift-entity", + "cranelift-isle", + "gimli", + "hashbrown 0.15.4", + "log", + "pulley-interpreter", + "regalloc2", + "rustc-hash", + "serde", + "smallvec", + "target-lexicon", + "wasmtime-internal-math", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.122.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456715b9d5f12398f156d5081096e7b5d039f01b9ecc49790a011c8e43e65b5f" +dependencies = [ + "cranelift-assembler-x64-meta", + "cranelift-codegen-shared", + "cranelift-srcgen", + "pulley-interpreter", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.122.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0306041099499833f167a0ddb707e1e54100f1a84eab5631bc3dad249708f482" + +[[package]] +name = "cranelift-control" +version = "0.122.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1672945e1f9afc2297f49c92623f5eabc64398e2cb0d824f8f72a2db2df5af23" +dependencies = [ + "arbitrary", +] + +[[package]] +name = "cranelift-entity" +version = "0.122.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa3cd55eb5f3825b9ae5de1530887907360a6334caccdc124c52f6d75246c98a" +dependencies = [ + "cranelift-bitset", + "serde", + "serde_derive", +] + +[[package]] +name = "cranelift-frontend" +version = "0.122.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "781f9905f8139b8de22987b66b522b416fe63eb76d823f0b3a8c02c8fd9500c7" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.122.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a05337a2b02c3df00b4dd9a263a027a07b3dff49f61f7da3b5d195c21eaa633d" + +[[package]] +name = "cranelift-native" +version = "0.122.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eee7a496dd66380082c9c5b6f2d5fa149cec0ec383feec5caf079ca2b3671c2" +dependencies = [ + "cranelift-codegen", + "libc", + "target-lexicon", +] + +[[package]] +name = "cranelift-srcgen" +version = "0.122.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b530783809a55cb68d070e0de60cfbb3db0dc94c8850dd5725411422bedcf6bb" + +[[package]] +name = "crc" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9710d3b3739c2e349eb44fe848ad0b7c8cb1e42bd87ee49371df2f7acaf3e675" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d374276b40fb8bbdee95aef7c7fa6b5316ec764510eb64b8dd0e2ed0d7e7f5" + +[[package]] +name = "crc32fast" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "criterion" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1c047a62b0cc3e145fa84415a3191f628e980b194c2755aa12300a4e6cbd928" +dependencies = [ + "anes", + "cast", + "ciborium", + "clap", + "criterion-plot", + "itertools 0.13.0", + "num-traits", + "oorandom", + "plotters", + "rayon", + "regex", + "serde", + "serde_json", + "tinytemplate", + "walkdir", +] + +[[package]] +name = "criterion-plot" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b1bcc0dc7dfae599d84ad0b1a55f80cde8af3725da8313b528da95ef783e338" +dependencies = [ + "cast", + "itertools 0.13.0", +] + +[[package]] +name = "critical-section" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" + +[[package]] +name = "crossbeam-channel" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-queue" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "crypto-bigint" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dc92fb57ca44df6db8059111ab3af99a63d5d0f8375d9972e319a379c6bab76" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "subtle", + "zeroize", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "typenum", +] + +[[package]] +name = "cryptoxide" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "382ce8820a5bb815055d3553a610e8cb542b2d767bbacea99038afda96cd760d" + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher", +] + +[[package]] +name = "curve25519-dalek" +version = "4.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be" +dependencies = [ + "cfg-if", + "cpufeatures", + "curve25519-dalek-derive", + "digest", + "fiat-crypto", + "rustc_version", + "subtle", + "zeroize", +] + +[[package]] +name = "curve25519-dalek-derive" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.104", +] + +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "dashmap" +version = "6.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5041cc499144891f3790297212f32a74fb938e5136a14943f338ef9e0ae276cf" +dependencies = [ + "cfg-if", + "crossbeam-utils", + "hashbrown 0.14.5", + "lock_api", + "once_cell", + "parking_lot_core", +] + +[[package]] +name = "data-encoding" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" + +[[package]] +name = "data-encoding-macro" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47ce6c96ea0102f01122a185683611bd5ac8d99e62bc59dd12e6bda344ee673d" +dependencies = [ + "data-encoding", + "data-encoding-macro-internal", +] + +[[package]] +name = "data-encoding-macro-internal" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d162beedaa69905488a8da94f5ac3edb4dd4788b732fadb7bd120b2625c1976" +dependencies = [ + "data-encoding", + "syn 2.0.104", +] + +[[package]] +name = "data-url" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a" + +[[package]] +name = "der" +version = "0.7.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +dependencies = [ + "const-oid", + "der_derive", + "flagset", + "pem-rfc7468", + "zeroize", +] + +[[package]] +name = "der-parser" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cd0a5c643689626bec213c4d8bd4d96acc8ffdb4ad4bb6bc16abf27d5f4b553" +dependencies = [ + "asn1-rs 0.6.2", + "displaydoc", + "nom 7.1.3", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "der-parser" +version = "10.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07da5016415d5a3c4dd39b11ed26f915f52fc4e0dc197d87908bc916e51bc1a6" +dependencies = [ + "asn1-rs 0.7.1", + "displaydoc", + "nom 7.1.3", + "num-bigint", + "num-traits", + "rusticata-macros", +] + +[[package]] +name = "der_derive" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8034092389675178f570469e6c3b0465d3d30b4505c294a6550db47f3c17ad18" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "deranged" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" +dependencies = [ + "powerfmt", + "serde", +] + +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "derive_more" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" +dependencies = [ + "derive_more-impl", +] + +[[package]] +name = "derive_more-impl" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "syn 2.0.104", + "unicode-xid", +] + +[[package]] +name = "diff" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common", + "subtle", +] + +[[package]] +name = "dirs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users 0.5.1", + "windows-sys 0.60.2", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users 0.4.6", + "winapi", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "dtoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6add3b8cff394282be81f3fc1a0605db594ed69890078ca6e2cab1c408bcf04" + +[[package]] +name = "dyn-clone" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + +[[package]] +name = "ecdsa" +version = "0.16.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee27f32b5c5292967d2d4a9d7f1e0b0aed2c15daded5a60300e4abb9d8020bca" +dependencies = [ + "der", + "digest", + "elliptic-curve", + "rfc6979", + "signature", + "spki", +] + +[[package]] +name = "ed25519" +version = "2.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "115531babc129696a58c64a4fef0a8bf9e9698629fb97e9e40767d235cfbcd53" +dependencies = [ + "pkcs8", + "signature", +] + +[[package]] +name = "ed25519-bip32" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb588f93c0d91b2f668849fd6d030cddb0b2e31f105963be189da5acdf492a21" +dependencies = [ + "cryptoxide", +] + +[[package]] +name = "ed25519-dalek" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70e796c081cee67dc755e1a36a0a172b897fab85fc3f6bc48307991f64e4eca9" +dependencies = [ + "curve25519-dalek", + "ed25519", + "serde", + "sha2", + "subtle", + "zeroize", +] + +[[package]] +name = "either" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" + +[[package]] +name = "elliptic-curve" +version = "0.13.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6043086bf7973472e0c7dff2142ea0b680d30e18d9cc40f267efbf222bd47" +dependencies = [ + "base16ct", + "crypto-bigint", + "digest", + "ff", + "generic-array", + "group", + "pem-rfc7468", + "pkcs8", + "rand_core 0.6.4", + "sec1", + "subtle", + "zeroize", +] + +[[package]] +name = "email_address" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e079f19b08ca6239f47f8ba8509c11cf3ea30095831f7fed61441475edd8c449" +dependencies = [ + "serde", +] + +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + +[[package]] +name = "ena" +version = "0.14.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d248bdd43ce613d87415282f69b9bb99d947d290b10962dd6c56233312c2ad5" +dependencies = [ + "log", +] + +[[package]] +name = "encode_unicode" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "enum-as-inner" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1e6a265c649f3f5979b601d26f1d05ada116434c87741c9493cb56218f76cbc" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "erased-serde" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e004d887f51fcb9fef17317a2f3525c887d8aa3f4f50fed920816a688284a5b7" +dependencies = [ + "serde", + "typeid", +] + +[[package]] +name = "errno" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "escape8259" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5692dd7b5a1978a5aeb0ce83b7655c58ca8efdcb79d21036ea249da95afec2c6" + +[[package]] +name = "euclid" +version = "0.22.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad9cdb4b747e485a12abb0e6566612956c7a1bafa3bdb8d682c5b6d403589e48" +dependencies = [ + "num-traits", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "event-listener" +version = "5.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener 5.4.0", + "pin-project-lite", +] + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fancy-regex" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6215aee357f8c7c989ebb4b8466ca4d7dc93b3957039f2fc3ea2ade8ea5f279" +dependencies = [ + "bit-set 0.8.0", + "derivative", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "ff" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0b50bfb653653f9ca9095b427bed08ab8d75a137839d9ad64eb11810d5b6393" +dependencies = [ + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "fiat-crypto" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" + +[[package]] +name = "filetime" +version = "0.2.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35c0522e981e68cbfa8c3f978441a5f34b30b96e146b33cd3359176b50fe8586" +dependencies = [ + "cfg-if", + "libc", + "libredox", + "windows-sys 0.59.0", +] + +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] +name = "flagset" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7ac824320a75a52197e8f2d787f6a38b6718bb6897a35142d749af3c0e8f4fe" + +[[package]] +name = "flate2" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" + +[[package]] +name = "fluent-uri" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1918b65d96df47d3591bed19c5cca17e3fa5d0707318e4b5ef2eae01764df7e5" +dependencies = [ + "borrow-or-share", + "ref-cast", + "serde", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "fontconfig-parser" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbc773e24e02d4ddd8395fd30dc147524273a83e54e0f312d986ea30de5f5646" +dependencies = [ + "roxmltree", +] + +[[package]] +name = "fontdb" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "457e789b3d1202543297a350643cf459f836cade38934e7a4cf6a39e7cde2905" +dependencies = [ + "fontconfig-parser", + "log", + "memmap2", + "slotmap", + "tinyvec", + "ttf-parser", +] + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fraction" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f158e3ff0a1b334408dc9fb811cd99b446986f4d8b741bb08f9df1604085ae7" +dependencies = [ + "lazy_static", + "num", +] + +[[package]] +name = "fs2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "fslock" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04412b8935272e3a9bae6f48c7bfff74c2911f60525404edfdd28e49884c3bfb" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "futures" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-bounded" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91f328e7fb845fc832912fb6a34f40cf6d1888c92f974d1893a54e97b5ff542e" +dependencies = [ + "futures-timer", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-executor" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", + "num_cpus", +] + +[[package]] +name = "futures-io" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" + +[[package]] +name = "futures-lite" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-macro" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "futures-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f2f12607f92c69b12ed746fabf9ca4f5c482cba46679c1a75b874ed7c26adb" +dependencies = [ + "futures-io", + "rustls", + "rustls-pki-types", +] + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-timeout" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc766541fbac66e9c9b53a92623c38e9a22768a4bd6a0c49a0b564b0126474e2" +dependencies = [ + "futures", + "futures-timer", + "pin-project", +] + +[[package]] +name = "futures-timer" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f288b0a4f20f9a56b5d1da57e2227c661b7b16168e2f72365f57b63326e29b24" +dependencies = [ + "gloo-timers 0.2.6", + "send_wrapper 0.4.0", +] + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "generator" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d18470a76cb7f8ff746cf1f7470914f900252ec36bbc40b569d74b1258446827" +dependencies = [ + "cc", + "cfg-if", + "libc", + "log", + "rustversion", + "windows 0.61.3", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", + "zeroize", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", + "wasm-bindgen", +] + +[[package]] +name = "ghash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" +dependencies = [ + "opaque-debug", + "polyval", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +dependencies = [ + "fallible-iterator", + "indexmap 2.10.0", + "stable_deref_trait", +] + +[[package]] +name = "git2" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2deb07a133b1520dc1a5690e9bd08950108873d7ed5de38dcc74d3b5ebffa110" +dependencies = [ + "bitflags 2.9.1", + "libc", + "libgit2-sys", + "log", + "url", +] + +[[package]] +name = "glob" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" + +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "gloo-timers" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "group" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" +dependencies = [ + "ff", + "rand_core 0.6.4", + "subtle", +] + +[[package]] +name = "h2" +version = "0.3.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0beca50380b1fc32983fc1cb4587bfa4bb9e78fc259aad4a0032d2080309222d" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap 2.10.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17da50a276f1e01e0ba6c029e47b7100754904ee8a278f886546e98575380785" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.3.1", + "indexmap 2.10.0", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "half" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b43ede17f21864e81be2fa654110bf1e793774238d86ef8555c37e6519c0403" + +[[package]] +name = "half" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "459196ed295495a68f7d7fe1d84f6c4b7ff0e21fe3017b2f283c6fac3ad803c9" +dependencies = [ + "cfg-if", + "crunchy", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" +dependencies = [ + "allocator-api2", + "equivalent", + "foldhash", + "serde", +] + +[[package]] +name = "hashlink" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown 0.14.5", +] + +[[package]] +name = "hdf5-metno" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f8592329337a96c802cccdbd11fe5f9476cb940d5a88dcca729a2ecf82e1c9" +dependencies = [ + "bitflags 2.9.1", + "blosc-src", + "cfg-if", + "hdf5-metno-derive", + "hdf5-metno-sys", + "hdf5-metno-types", + "lazy_static", + "libc", + "ndarray", + "paste", +] + +[[package]] +name = "hdf5-metno-derive" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25557ccc26f5b17b8f6014c58761e5eb53e815728907071999c3957bfee23bc2" +dependencies = [ + "proc-macro-crate", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "hdf5-metno-src" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "956b57b8b4e133bcfbc874a2c9c6d4020e0da420dcfa05aea79091888f2b0763" +dependencies = [ + "cmake", +] + +[[package]] +name = "hdf5-metno-sys" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de20d5ba22c244493bdfefb91d8e9de08e3e58d96a792532da5e0df545aed279" +dependencies = [ + "hdf5-metno-src", + "libc", + "libloading", + "parking_lot", + "pkg-config", + "regex", + "serde", + "serde_derive", + "winreg 0.52.0", +] + +[[package]] +name = "hdf5-metno-types" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86784ab948de3b7ffdf4c64561fdc1ec86ec512054e04ca649eda65ad0c6faa9" +dependencies = [ + "ascii", + "cfg-if", + "hdf5-metno-sys", + "libc", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermes" +version = "0.0.5" +dependencies = [ + "anyhow", + "bip32", + "bip39", + "blake2b_simd", + "blosc-src", + "build-info", + "build-info-build", + "cardano-chain-follower", + "chrono", + "chrono-tz", + "clap", + "console", + "coset", + "criterion", + "crossbeam-queue", + "dashmap", + "derive_more", + "dirs", + "ed25519-bip32", + "ed25519-dalek", + "hdf5-metno", + "hermes-ipfs", + "hex", + "hex-literal", + "hmac", + "http-body-util", + "httpmock", + "hyper 1.6.0", + "hyper-util", + "iana-time-zone", + "jsonschema", + "libsqlite3-sys", + "libtest-mimic", + "num_cpus", + "once_cell", + "pallas", + "pbkdf2", + "rand 0.9.2", + "regex", + "reqwest", + "rustls", + "rusty_ulid", + "saffron", + "serde", + "serde_json", + "serial_test", + "sha2", + "stringzilla", + "temp-dir", + "thiserror 2.0.12", + "tokio", + "tokio-rustls", + "tracing", + "tracing-subscriber", + "url", + "usvg", + "uuid", + "wasmtime", + "webpki-roots 1.0.2", + "x509-cert", +] + +[[package]] +name = "hermes-ipfs" +version = "0.0.5" +source = "git+https://github.com/input-output-hk/catalyst-libs.git?tag=hermes-ipfs%2Fv0.0.5#d11f82bb56fea4e7fd33b4b19a714dcea0838957" +dependencies = [ + "anyhow", + "derive_more", + "ipld-core", + "rust-ipfs", + "tokio", +] + +[[package]] +name = "hermit-abi" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hex-conservative" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212ab92002354b4819390025006c897e8140934349e8635c9b077f47b4dcbd20" + +[[package]] +name = "hex-literal" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcaaec4551594c969335c98c903c1397853d4198408ea609190f420500f6be71" + +[[package]] +name = "hex_fmt" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07f60793ff0a4d9cef0f18e63b5357e06209987153a64648c972c1e5aff336f" + +[[package]] +name = "hickory-proto" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8a6fe56c0038198998a6f217ca4e7ef3a5e51f46163bd6dd60b5c71ca6c6502" +dependencies = [ + "async-trait", + "cfg-if", + "data-encoding", + "enum-as-inner", + "futures-channel", + "futures-io", + "futures-util", + "idna", + "ipnet", + "once_cell", + "rand 0.9.2", + "ring", + "socket2 0.5.10", + "thiserror 2.0.12", + "tinyvec", + "tokio", + "tracing", + "url", +] + +[[package]] +name = "hickory-resolver" +version = "0.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc62a9a99b0bfb44d2ab95a7208ac952d31060efc16241c87eaf36406fecf87a" +dependencies = [ + "cfg-if", + "futures-util", + "hickory-proto", + "ipconfig", + "moka", + "once_cell", + "parking_lot", + "rand 0.9.2", + "resolv-conf", + "smallvec", + "thiserror 2.0.12", + "tokio", + "tracing", +] + +[[package]] +name = "hkdf" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b5f8eb2ad728638ea2c7d47a21db23b7b58a72ed6a38256b8a1849f15fbbdf7" +dependencies = [ + "hmac", +] + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.3.1", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http 1.3.1", + "http-body 1.0.1", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "httpmock" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08ec9586ee0910472dec1a1f0f8acf52f0fdde93aea74d70d4a3107b4be0fd5b" +dependencies = [ + "assert-json-diff", + "async-object-pool", + "async-std", + "async-trait", + "base64 0.21.7", + "basic-cookies", + "crossbeam-utils", + "form_urlencoded", + "futures-util", + "hyper 0.14.32", + "lazy_static", + "levenshtein", + "log", + "regex", + "serde", + "serde_json", + "serde_regex", + "similar", + "tokio", + "url", +] + +[[package]] +name = "hyper" +version = "0.14.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2 0.3.27", + "http 0.2.12", + "http-body 0.4.6", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2 0.5.10", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.11", + "http 1.3.1", + "http-body 1.0.1", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http 1.3.1", + "hyper 1.6.0", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-timeout" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +dependencies = [ + "hyper 0.14.32", + "pin-project-lite", + "tokio", + "tokio-io-timeout", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper 1.6.0", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http 1.3.1", + "http-body 1.0.1", + "hyper 1.6.0", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2 0.6.0", + "system-configuration", + "tokio", + "tower-service", + "tracing", + "windows-registry", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core 0.61.2", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" + +[[package]] +name = "icu_properties" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "potential_utf", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" + +[[package]] +name = "icu_provider" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" +dependencies = [ + "displaydoc", + "icu_locale_core", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + +[[package]] +name = "idb" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3afe8830d5802f769dc0be20a87f9f116798c896650cb6266eb5c19a3c109eed" +dependencies = [ + "js-sys", + "num-traits", + "thiserror 1.0.69", + "tokio", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "if-addrs" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cabb0019d51a643781ff15c9c8a3e5dedc365c47211270f4e8f82812fedd8f0a" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "if-watch" +version = "3.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdf9d64cfcf380606e64f9a0bcf493616b65331199f984151a6fa11a7b3cde38" +dependencies = [ + "async-io", + "core-foundation", + "fnv", + "futures", + "if-addrs", + "ipnet", + "log", + "netlink-packet-core", + "netlink-packet-route", + "netlink-proto", + "netlink-sys", + "rtnetlink", + "system-configuration", + "tokio", + "windows 0.53.0", +] + +[[package]] +name = "igd-next" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516893339c97f6011282d5825ac94fc1c7aad5cad26bdc2d0cee068c0bf97f97" +dependencies = [ + "async-trait", + "attohttpc", + "bytes", + "futures", + "http 1.3.1", + "http-body-util", + "hyper 1.6.0", + "hyper-util", + "log", + "rand 0.9.2", + "tokio", + "url", + "xmltree", +] + +[[package]] +name = "imagesize" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edcd27d72f2f071c64249075f42e205ff93c9a4c5f6c6da53e79ed9f9832c285" + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "indexmap" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" +dependencies = [ + "equivalent", + "hashbrown 0.15.4", + "serde", +] + +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "generic-array", +] + +[[package]] +name = "io-uring" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4" +dependencies = [ + "bitflags 2.9.1", + "cfg-if", + "libc", +] + +[[package]] +name = "ipconfig" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b58db92f96b720de98181bbbe63c831e87005ab460c1bf306eb2622b4707997f" +dependencies = [ + "socket2 0.5.10", + "widestring", + "windows-sys 0.48.0", + "winreg 0.50.0", +] + +[[package]] +name = "ipld-core" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "104718b1cc124d92a6d01ca9c9258a7df311405debb3408c445a36452f9bf8db" +dependencies = [ + "cid", + "serde", + "serde_bytes", +] + +[[package]] +name = "ipld-dagpb" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5eb3c08f1508fa62ffe1a805aafa116d2eb034b3542c85596db132f279abc47" +dependencies = [ + "bytes", + "ipld-core", + "quick-protobuf", + "thiserror 1.0.69", +] + +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "iri-string" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] +name = "itertools" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1c173a5686ce8bfa551b3563d0c2170bf24ca44da99c7ca4bfdab5418c3fe57" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "jobserver" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38f262f097c174adebe41eb73d66ae9c06b2844fb0da69969647bbddd9b0538a" +dependencies = [ + "getrandom 0.3.3", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "jsonschema" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbce926db3fae74d35e37f059a7b8eb1f30f5781c97ea1ae239a49c337dbb08" +dependencies = [ + "ahash", + "base64 0.22.1", + "bytecount", + "email_address", + "fancy-regex", + "fraction", + "idna", + "itoa", + "num-cmp", + "num-traits", + "once_cell", + "percent-encoding", + "referencing", + "regex", + "regex-syntax 0.8.5", + "reqwest", + "serde", + "serde_json", + "uuid-simd", +] + +[[package]] +name = "k256" +version = "0.13.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6e3919bbaa2945715f0bb6d3934a173d1e9a59ac23767fbaaef277265a7411b" +dependencies = [ + "cfg-if", + "ecdsa", + "elliptic-curve", + "once_cell", + "sha2", + "signature", +] + +[[package]] +name = "keccak" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecc2af9a1119c51f12a14607e783cb977bde58bc069ff0c3da1095e635d70654" +dependencies = [ + "cpufeatures", +] + +[[package]] +name = "kurbo" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c62026ae44756f8a599ba21140f350303d4f08dcdcc71b5ad9c9bb8128c13c62" +dependencies = [ + "arrayvec", + "euclid", + "smallvec", +] + +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + +[[package]] +name = "lalrpop" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55cb077ad656299f160924eb2912aa147d7339ea7d69e1b5517326fdcec3c1ca" +dependencies = [ + "ascii-canvas", + "bit-set 0.5.3", + "ena", + "itertools 0.11.0", + "lalrpop-util", + "petgraph", + "pico-args", + "regex", + "regex-syntax 0.8.5", + "string_cache", + "term", + "tiny-keccak", + "unicode-xid", + "walkdir", +] + +[[package]] +name = "lalrpop-util" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507460a910eb7b32ee961886ff48539633b788a36b65692b95f225b844c82553" +dependencies = [ + "regex-automata 0.4.9", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "levenshtein" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" + +[[package]] +name = "libc" +version = "0.2.174" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" + +[[package]] +name = "libgit2-sys" +version = "0.18.2+1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c42fe03df2bd3c53a3a9c7317ad91d80c81cd1fb0caec8d7cc4cd2bfa10c222" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + +[[package]] +name = "libloading" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667" +dependencies = [ + "cfg-if", + "windows-targets 0.53.3", +] + +[[package]] +name = "libm" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de" + +[[package]] +name = "libp2p" +version = "0.56.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce71348bf5838e46449ae240631117b487073d5f347c06d434caddcb91dceb5a" +dependencies = [ + "bytes", + "either", + "futures", + "futures-timer", + "getrandom 0.2.16", + "libp2p-allow-block-list", + "libp2p-autonat", + "libp2p-connection-limits", + "libp2p-core", + "libp2p-dcutr", + "libp2p-dns", + "libp2p-gossipsub", + "libp2p-identify", + "libp2p-identity", + "libp2p-kad", + "libp2p-mdns", + "libp2p-metrics", + "libp2p-noise", + "libp2p-ping", + "libp2p-pnet", + "libp2p-quic", + "libp2p-relay", + "libp2p-rendezvous", + "libp2p-request-response", + "libp2p-swarm", + "libp2p-tcp", + "libp2p-tls", + "libp2p-upnp", + "libp2p-websocket", + "libp2p-websocket-websys", + "libp2p-yamux", + "multiaddr", + "pin-project", + "rw-stream-sink", + "thiserror 2.0.12", +] + +[[package]] +name = "libp2p-allow-block-list" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d16ccf824ee859ca83df301e1c0205270206223fd4b1f2e512a693e1912a8f4a" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", +] + +[[package]] +name = "libp2p-autonat" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fab5e25c49a7d48dac83d95d8f3bac0a290d8a5df717012f6e34ce9886396c0b" +dependencies = [ + "async-trait", + "asynchronous-codec", + "either", + "futures", + "futures-bounded", + "futures-timer", + "libp2p-core", + "libp2p-identity", + "libp2p-request-response", + "libp2p-swarm", + "quick-protobuf", + "quick-protobuf-codec", + "rand 0.8.5", + "rand_core 0.6.4", + "thiserror 2.0.12", + "tracing", + "web-time", +] + +[[package]] +name = "libp2p-connection-limits" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a18b8b607cf3bfa2f8c57db9c7d8569a315d5cc0a282e6bfd5ebfc0a9840b2a0" +dependencies = [ + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", +] + +[[package]] +name = "libp2p-core" +version = "0.43.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d28e2d2def7c344170f5c6450c0dbe3dfef655610dbfde2f6ac28a527abbe36" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "libp2p-identity", + "multiaddr", + "multihash", + "multistream-select", + "parking_lot", + "pin-project", + "quick-protobuf", + "rand 0.8.5", + "rw-stream-sink", + "thiserror 2.0.12", + "tracing", + "unsigned-varint 0.8.0", + "web-time", +] + +[[package]] +name = "libp2p-dcutr" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4f0eec23bc79cabfdf6934718f161fc42a1d98e2c9d44007c80eb91534200c" +dependencies = [ + "asynchronous-codec", + "either", + "futures", + "futures-bounded", + "futures-timer", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "lru", + "quick-protobuf", + "quick-protobuf-codec", + "thiserror 2.0.12", + "tracing", + "web-time", +] + +[[package]] +name = "libp2p-dns" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b770c1c8476736ca98c578cba4b505104ff8e842c2876b528925f9766379f9a" +dependencies = [ + "async-trait", + "futures", + "hickory-resolver", + "libp2p-core", + "libp2p-identity", + "parking_lot", + "smallvec", + "tracing", +] + +[[package]] +name = "libp2p-gossipsub" +version = "0.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba535a5d960cc39c3621cee2941ff570a9476679a4c7ca80982412b14f4a88fd" +dependencies = [ + "async-channel 2.5.0", + "asynchronous-codec", + "base64 0.22.1", + "byteorder", + "bytes", + "either", + "fnv", + "futures", + "futures-timer", + "getrandom 0.2.16", + "hashlink", + "hex_fmt", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "quick-protobuf", + "quick-protobuf-codec", + "rand 0.8.5", + "regex", + "serde", + "sha2", + "tracing", + "web-time", +] + +[[package]] +name = "libp2p-identify" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ab792a8b68fdef443a62155b01970c81c3aadab5e659621b063ef252a8e65e8" +dependencies = [ + "asynchronous-codec", + "either", + "futures", + "futures-bounded", + "futures-timer", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "quick-protobuf", + "quick-protobuf-codec", + "smallvec", + "thiserror 2.0.12", + "tracing", +] + +[[package]] +name = "libp2p-identity" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3104e13b51e4711ff5738caa1fb54467c8604c2e94d607e27745bcf709068774" +dependencies = [ + "asn1_der", + "bs58", + "ed25519-dalek", + "hkdf", + "k256", + "multihash", + "p256", + "quick-protobuf", + "rand 0.8.5", + "ring", + "sec1", + "serde", + "sha2", + "thiserror 2.0.12", + "tracing", + "zeroize", +] + +[[package]] +name = "libp2p-kad" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13d3fd632a5872ec804d37e7413ceea20588f69d027a0fa3c46f82574f4dee60" +dependencies = [ + "asynchronous-codec", + "bytes", + "either", + "fnv", + "futures", + "futures-bounded", + "futures-timer", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "quick-protobuf", + "quick-protobuf-codec", + "rand 0.8.5", + "serde", + "sha2", + "smallvec", + "thiserror 2.0.12", + "tracing", + "uint", + "web-time", +] + +[[package]] +name = "libp2p-mdns" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c66872d0f1ffcded2788683f76931be1c52e27f343edb93bc6d0bcd8887be443" +dependencies = [ + "futures", + "hickory-proto", + "if-watch", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "rand 0.8.5", + "smallvec", + "socket2 0.5.10", + "tokio", + "tracing", +] + +[[package]] +name = "libp2p-metrics" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805a555148522cb3414493a5153451910cb1a146c53ffbf4385708349baf62b7" +dependencies = [ + "futures", + "libp2p-core", + "libp2p-dcutr", + "libp2p-gossipsub", + "libp2p-identify", + "libp2p-identity", + "libp2p-kad", + "libp2p-ping", + "libp2p-relay", + "libp2p-swarm", + "pin-project", + "prometheus-client", + "web-time", +] + +[[package]] +name = "libp2p-noise" +version = "0.46.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc73eacbe6462a0eb92a6527cac6e63f02026e5407f8831bde8293f19217bfbf" +dependencies = [ + "asynchronous-codec", + "bytes", + "futures", + "libp2p-core", + "libp2p-identity", + "multiaddr", + "multihash", + "quick-protobuf", + "rand 0.8.5", + "snow", + "static_assertions", + "thiserror 2.0.12", + "tracing", + "x25519-dalek", + "zeroize", +] + +[[package]] +name = "libp2p-ping" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74bb7fcdfd9fead4144a3859da0b49576f171a8c8c7c0bfc7c541921d25e60d3" +dependencies = [ + "futures", + "futures-timer", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "rand 0.8.5", + "tracing", + "web-time", +] + +[[package]] +name = "libp2p-pnet" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf240b834dfa3f8b48feb2c4b87bb2cf82751543001b6ee86077f48183b18d52" +dependencies = [ + "futures", + "pin-project", + "rand 0.8.5", + "salsa20", + "sha3", + "tracing", +] + +[[package]] +name = "libp2p-quic" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8dc448b2de9f4745784e3751fe8bc6c473d01b8317edd5ababcb0dec803d843f" +dependencies = [ + "futures", + "futures-timer", + "if-watch", + "libp2p-core", + "libp2p-identity", + "libp2p-tls", + "quinn", + "rand 0.8.5", + "ring", + "rustls", + "socket2 0.5.10", + "thiserror 2.0.12", + "tokio", + "tracing", +] + +[[package]] +name = "libp2p-relay" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "551b24ae04c63859bf5e25644acdd6aa469deb5c5cd872ca21c2c9b45a5a5192" +dependencies = [ + "asynchronous-codec", + "bytes", + "either", + "futures", + "futures-bounded", + "futures-timer", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "quick-protobuf", + "quick-protobuf-codec", + "rand 0.8.5", + "static_assertions", + "thiserror 2.0.12", + "tracing", + "web-time", +] + +[[package]] +name = "libp2p-relay-manager" +version = "0.4.0" +source = "git+https://github.com/dariusc93/rust-ipfs?rev=26b99cb#26b99cbfcfe45d8dbdf9770193a407fc7b4b8032" +dependencies = [ + "anyhow", + "futures", + "futures-timer", + "getrandom 0.2.16", + "libp2p", + "rand 0.8.5", +] + +[[package]] +name = "libp2p-rendezvous" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15285d828c2b4a34cb660c2e74cd6938116daceab1f4357bae933d5b08cca933" +dependencies = [ + "async-trait", + "asynchronous-codec", + "bimap", + "futures", + "futures-timer", + "libp2p-core", + "libp2p-identity", + "libp2p-request-response", + "libp2p-swarm", + "quick-protobuf", + "quick-protobuf-codec", + "rand 0.8.5", + "thiserror 2.0.12", + "tracing", + "web-time", +] + +[[package]] +name = "libp2p-request-response" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9f1cca83488b90102abac7b67d5c36fc65bc02ed47620228af7ed002e6a1478" +dependencies = [ + "async-trait", + "cbor4ii 0.3.3", + "futures", + "futures-bounded", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm", + "rand 0.8.5", + "serde", + "serde_json", + "smallvec", + "tracing", +] + +[[package]] +name = "libp2p-swarm" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aa762e5215919a34e31c35d4b18bf2e18566ecab7f8a3d39535f4a3068f8b62" +dependencies = [ + "either", + "fnv", + "futures", + "futures-timer", + "getrandom 0.2.16", + "libp2p-core", + "libp2p-identity", + "libp2p-swarm-derive", + "lru", + "multistream-select", + "rand 0.8.5", + "smallvec", + "tokio", + "tracing", + "wasm-bindgen-futures", + "web-time", +] + +[[package]] +name = "libp2p-swarm-derive" +version = "0.35.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd297cf53f0cb3dee4d2620bb319ae47ef27c702684309f682bdb7e55a18ae9c" +dependencies = [ + "heck 0.5.0", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "libp2p-tcp" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65b4e030c52c46c8d01559b2b8ca9b7c4185f10576016853129ca1fe5cd1a644" +dependencies = [ + "futures", + "futures-timer", + "if-watch", + "libc", + "libp2p-core", + "socket2 0.5.10", + "tokio", + "tracing", +] + +[[package]] +name = "libp2p-tls" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96ff65a82e35375cbc31ebb99cacbbf28cb6c4fefe26bf13756ddcf708d40080" +dependencies = [ + "futures", + "futures-rustls", + "libp2p-core", + "libp2p-identity", + "rcgen", + "ring", + "rustls", + "rustls-webpki", + "thiserror 2.0.12", + "x509-parser 0.17.0", + "yasna", +] + +[[package]] +name = "libp2p-upnp" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4757e65fe69399c1a243bbb90ec1ae5a2114b907467bf09f3575e899815bb8d3" +dependencies = [ + "futures", + "futures-timer", + "igd-next", + "libp2p-core", + "libp2p-swarm", + "tokio", + "tracing", +] + +[[package]] +name = "libp2p-websocket" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "520e29066a48674c007bc11defe5dce49908c24cafd8fad2f5e1a6a8726ced53" +dependencies = [ + "either", + "futures", + "futures-rustls", + "libp2p-core", + "libp2p-identity", + "parking_lot", + "pin-project-lite", + "rw-stream-sink", + "soketto", + "thiserror 2.0.12", + "tracing", + "url", + "webpki-roots 0.26.11", +] + +[[package]] +name = "libp2p-websocket-websys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e73d85b4dc8c2044f58508461bd8bb12f541217c0038ade8cce0ddc1607b8f72" +dependencies = [ + "bytes", + "futures", + "js-sys", + "libp2p-core", + "send_wrapper 0.6.0", + "thiserror 2.0.12", + "tracing", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "libp2p-yamux" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f15df094914eb4af272acf9adaa9e287baa269943f32ea348ba29cfb9bfc60d8" +dependencies = [ + "either", + "futures", + "libp2p-core", + "thiserror 2.0.12", + "tracing", + "yamux 0.12.1", + "yamux 0.13.6", +] + +[[package]] +name = "libredox" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3" +dependencies = [ + "bitflags 2.9.1", + "libc", + "redox_syscall", +] + +[[package]] +name = "libsqlite3-sys" +version = "0.35.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "133c182a6a2c87864fe97778797e46c7e999672690dc9fa3ee8e241aa4a9c13f" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "libtest-mimic" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5297962ef19edda4ce33aaa484386e0a5b3d7f2f4e037cbeee00503ef6b29d33" +dependencies = [ + "anstream", + "anstyle", + "clap", + "escape8259", +] + +[[package]] +name = "libz-sys" +version = "1.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b70e7a7df205e92a1a4cd9aaae7898dac0aa555503cc0a649494d0d60e7651d" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "litemap" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" + +[[package]] +name = "lock_api" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" +dependencies = [ + "value-bag", +] + +[[package]] +name = "loom" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "lru" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "234cf4f4a04dc1f57e24b96cc0cd600cf2af460d4161ac5ecdd0af8e1f3b2a38" +dependencies = [ + "hashbrown 0.15.4", +] + +[[package]] +name = "lru-slab" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" + +[[package]] +name = "lz4-sys" +version = "1.11.1+lz4-1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bd8c0d6c6ed0cd30b3652886bb8711dc4bb01d637a68105a3d5158039b418e6" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "mach2" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d640282b302c0bb0a2a8e0233ead9035e3bed871f0b7e81fe4a1ec829765db44" +dependencies = [ + "libc", +] + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "matchit" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94" + +[[package]] +name = "matrixmultiply" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a06de3016e9fae57a36fd14dba131fccf49f74b40b7fbdb472f96e361ec71a08" +dependencies = [ + "autocfg", + "rawpointer", +] + +[[package]] +name = "memchr" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" + +[[package]] +name = "memfd" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" +dependencies = [ + "rustix 0.38.44", +] + +[[package]] +name = "memmap2" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "483758ad303d734cec05e5c12b41d7e93e6a6390c5e9dae6bdeb7c1259012d28" +dependencies = [ + "libc", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "minicbor" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d15f4203d71fdf90903c2696e55426ac97a363c67b218488a73b534ce7aca10" +dependencies = [ + "half 1.8.3", + "minicbor-derive", +] + +[[package]] +name = "minicbor-derive" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1154809406efdb7982841adb6311b3d095b46f78342dd646736122fe6b19e267" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" +dependencies = [ + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", + "windows-sys 0.59.0", +] + +[[package]] +name = "moka" +version = "0.12.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9321642ca94a4282428e6ea4af8cc2ca4eac48ac7a6a4ea8f33f76d0ce70926" +dependencies = [ + "crossbeam-channel", + "crossbeam-epoch", + "crossbeam-utils", + "loom", + "parking_lot", + "portable-atomic", + "rustc_version", + "smallvec", + "tagptr", + "thiserror 1.0.69", + "uuid", +] + +[[package]] +name = "multiaddr" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe6351f60b488e04c1d21bc69e56b89cb3f5e8f5d22557d6e8031bdfd79b6961" +dependencies = [ + "arrayref", + "byteorder", + "data-encoding", + "libp2p-identity", + "multibase", + "multihash", + "percent-encoding", + "serde", + "static_assertions", + "unsigned-varint 0.8.0", + "url", +] + +[[package]] +name = "multibase" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404" +dependencies = [ + "base-x", + "data-encoding", + "data-encoding-macro", +] + +[[package]] +name = "multihash" +version = "0.19.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b430e7953c29dd6a09afc29ff0bb69c6e306329ee6794700aee27b76a1aea8d" +dependencies = [ + "core2", + "serde", + "unsigned-varint 0.8.0", +] + +[[package]] +name = "multihash-codetable" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67996849749d25f1da9f238e8ace2ece8f9d6bdf3f9750aaf2ae7de3a5cad8ea" +dependencies = [ + "blake2b_simd", + "blake2s_simd", + "blake3", + "core2", + "digest", + "multihash-derive", + "ripemd", + "sha1", + "sha2", + "sha3", + "strobe-rs", +] + +[[package]] +name = "multihash-derive" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f1b7edab35d920890b88643a765fc9bd295cf0201f4154dda231bef9b8404eb" +dependencies = [ + "core2", + "multihash", + "multihash-derive-impl", +] + +[[package]] +name = "multihash-derive-impl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3dc7141bd06405929948754f0628d247f5ca1865be745099205e5086da957cb" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.104", + "synstructure", +] + +[[package]] +name = "multimap" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d87ecb2933e8aeadb3e3a02b828fed80a7528047e68b4f424523a0981a3a084" + +[[package]] +name = "multistream-select" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea0df8e5eec2298a62b326ee4f0d7fe1a6b90a09dfcf9df37b38f947a8c42f19" +dependencies = [ + "bytes", + "futures", + "log", + "pin-project", + "smallvec", + "unsigned-varint 0.7.2", +] + +[[package]] +name = "native-tls" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "ndarray" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841" +dependencies = [ + "matrixmultiply", + "num-complex", + "num-integer", + "num-traits", + "portable-atomic", + "portable-atomic-util", + "rawpointer", +] + +[[package]] +name = "netlink-packet-core" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72724faf704479d67b388da142b186f916188505e7e0b26719019c525882eda4" +dependencies = [ + "anyhow", + "byteorder", + "netlink-packet-utils", +] + +[[package]] +name = "netlink-packet-route" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053998cea5a306971f88580d0829e90f270f940befd7cf928da179d4187a5a66" +dependencies = [ + "anyhow", + "bitflags 1.3.2", + "byteorder", + "libc", + "netlink-packet-core", + "netlink-packet-utils", +] + +[[package]] +name = "netlink-packet-utils" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ede8a08c71ad5a95cdd0e4e52facd37190977039a4704eb82a283f713747d34" +dependencies = [ + "anyhow", + "byteorder", + "paste", + "thiserror 1.0.69", +] + +[[package]] +name = "netlink-proto" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72452e012c2f8d612410d89eea01e2d9b56205274abb35d53f60200b2ec41d60" +dependencies = [ + "bytes", + "futures", + "log", + "netlink-packet-core", + "netlink-sys", + "thiserror 2.0.12", +] + +[[package]] +name = "netlink-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16c903aa70590cb93691bf97a767c8d1d6122d2cc9070433deb3bbf36ce8bd23" +dependencies = [ + "bytes", + "futures", + "libc", + "log", + "tokio", +] + +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nom" +version = "5.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b" +dependencies = [ + "memchr", + "version_check", +] + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" +dependencies = [ + "num-bigint", + "num-complex", + "num-integer", + "num-iter", + "num-rational", + "num-traits", +] + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-cmp" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63335b2e2c34fae2fb0aa2cecfd9f0832a1e24b3b32ecec612c3426d46dc8aaa" + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1429034a0490724d0075ebb2bc9e875d6503c3cf69e235a8941aa757d83ef5bf" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "crc32fast", + "hashbrown 0.15.4", + "indexmap 2.10.0", + "memchr", +] + +[[package]] +name = "oid-registry" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8d8034d9489cdaf79228eb9f6a3b8d7bb32ba00d6645ebd48eef4077ceb5bd9" +dependencies = [ + "asn1-rs 0.6.2", +] + +[[package]] +name = "oid-registry" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12f40cff3dde1b6087cc5d5f5d4d65712f34016a03ed60e9c08dcc392736b5b7" +dependencies = [ + "asn1-rs 0.7.1", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" +dependencies = [ + "critical-section", + "portable-atomic", +] + +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + +[[package]] +name = "oorandom" +version = "11.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "openssl" +version = "0.10.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" +dependencies = [ + "bitflags 2.9.1", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "openssl-sys" +version = "0.9.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "ordered-float" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits", +] + +[[package]] +name = "outref" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a80800c0488c3a21695ea981a54918fbb37abf04f4d0720c453632255e2ff0e" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "p256" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9863ad85fa8f4460f9c48cb909d38a0d689dba1f6f6988a5e3e0d31071bcd4b" +dependencies = [ + "ecdsa", + "elliptic-curve", + "primeorder", + "sha2", +] + +[[package]] +name = "pallas" +version = "0.25.0" +source = "git+https://github.com/input-output-hk/catalyst-pallas.git?rev=709acb19c52c6b789279ecc4bc8793b5d8b5abe9#709acb19c52c6b789279ecc4bc8793b5d8b5abe9" +dependencies = [ + "pallas-addresses", + "pallas-applying", + "pallas-codec", + "pallas-configs", + "pallas-crypto", + "pallas-network", + "pallas-primitives", + "pallas-traverse", + "pallas-txbuilder", + "pallas-utxorpc", +] + +[[package]] +name = "pallas-addresses" +version = "0.25.0" +source = "git+https://github.com/input-output-hk/catalyst-pallas.git?rev=709acb19c52c6b789279ecc4bc8793b5d8b5abe9#709acb19c52c6b789279ecc4bc8793b5d8b5abe9" +dependencies = [ + "base58", + "bech32", + "crc", + "cryptoxide", + "hex", + "pallas-codec", + "pallas-crypto", + "thiserror 1.0.69", +] + +[[package]] +name = "pallas-applying" +version = "0.25.0" +source = "git+https://github.com/input-output-hk/catalyst-pallas.git?rev=709acb19c52c6b789279ecc4bc8793b5d8b5abe9#709acb19c52c6b789279ecc4bc8793b5d8b5abe9" +dependencies = [ + "hex", + "pallas-addresses", + "pallas-codec", + "pallas-crypto", + "pallas-primitives", + "pallas-traverse", + "rand 0.8.5", +] + +[[package]] +name = "pallas-codec" +version = "0.25.0" +source = "git+https://github.com/input-output-hk/catalyst-pallas.git?rev=709acb19c52c6b789279ecc4bc8793b5d8b5abe9#709acb19c52c6b789279ecc4bc8793b5d8b5abe9" +dependencies = [ + "hex", + "minicbor", + "serde", + "thiserror 1.0.69", +] + +[[package]] +name = "pallas-configs" +version = "0.25.0" +source = "git+https://github.com/input-output-hk/catalyst-pallas.git?rev=709acb19c52c6b789279ecc4bc8793b5d8b5abe9#709acb19c52c6b789279ecc4bc8793b5d8b5abe9" +dependencies = [ + "base64 0.22.1", + "hex", + "num-rational", + "pallas-addresses", + "pallas-codec", + "pallas-crypto", + "pallas-primitives", + "serde", + "serde_json", + "serde_with", +] + +[[package]] +name = "pallas-crypto" +version = "0.25.0" +source = "git+https://github.com/input-output-hk/catalyst-pallas.git?rev=709acb19c52c6b789279ecc4bc8793b5d8b5abe9#709acb19c52c6b789279ecc4bc8793b5d8b5abe9" +dependencies = [ + "cryptoxide", + "hex", + "pallas-codec", + "rand_core 0.6.4", + "serde", + "thiserror 1.0.69", +] + +[[package]] +name = "pallas-hardano" +version = "0.25.0" +source = "git+https://github.com/input-output-hk/catalyst-pallas.git?rev=709acb19c52c6b789279ecc4bc8793b5d8b5abe9#709acb19c52c6b789279ecc4bc8793b5d8b5abe9" +dependencies = [ + "binary-layout", + "pallas-network", + "pallas-traverse", + "tap", + "thiserror 1.0.69", + "tracing", +] + +[[package]] +name = "pallas-network" +version = "0.25.0" +source = "git+https://github.com/input-output-hk/catalyst-pallas.git?rev=709acb19c52c6b789279ecc4bc8793b5d8b5abe9#709acb19c52c6b789279ecc4bc8793b5d8b5abe9" +dependencies = [ + "byteorder", + "hex", + "itertools 0.12.1", + "pallas-codec", + "pallas-crypto", + "rand 0.8.5", + "socket2 0.5.10", + "thiserror 1.0.69", + "tokio", + "tracing", +] + +[[package]] +name = "pallas-primitives" +version = "0.25.0" +source = "git+https://github.com/input-output-hk/catalyst-pallas.git?rev=709acb19c52c6b789279ecc4bc8793b5d8b5abe9#709acb19c52c6b789279ecc4bc8793b5d8b5abe9" +dependencies = [ + "base58", + "bech32", + "hex", + "log", + "pallas-codec", + "pallas-crypto", + "serde", + "serde_json", +] + +[[package]] +name = "pallas-traverse" +version = "0.25.0" +source = "git+https://github.com/input-output-hk/catalyst-pallas.git?rev=709acb19c52c6b789279ecc4bc8793b5d8b5abe9#709acb19c52c6b789279ecc4bc8793b5d8b5abe9" +dependencies = [ + "hex", + "pallas-addresses", + "pallas-codec", + "pallas-crypto", + "pallas-primitives", + "paste", + "serde", + "thiserror 1.0.69", +] + +[[package]] +name = "pallas-txbuilder" +version = "0.25.0" +source = "git+https://github.com/input-output-hk/catalyst-pallas.git?rev=709acb19c52c6b789279ecc4bc8793b5d8b5abe9#709acb19c52c6b789279ecc4bc8793b5d8b5abe9" +dependencies = [ + "hex", + "pallas-addresses", + "pallas-codec", + "pallas-crypto", + "pallas-primitives", + "pallas-traverse", + "pallas-wallet", + "serde", + "serde_json", + "thiserror 1.0.69", +] + +[[package]] +name = "pallas-utxorpc" +version = "0.25.0" +source = "git+https://github.com/input-output-hk/catalyst-pallas.git?rev=709acb19c52c6b789279ecc4bc8793b5d8b5abe9#709acb19c52c6b789279ecc4bc8793b5d8b5abe9" +dependencies = [ + "pallas-codec", + "pallas-primitives", + "pallas-traverse", + "utxorpc-spec", +] + +[[package]] +name = "pallas-wallet" +version = "0.25.0" +source = "git+https://github.com/input-output-hk/catalyst-pallas.git?rev=709acb19c52c6b789279ecc4bc8793b5d8b5abe9#709acb19c52c6b789279ecc4bc8793b5d8b5abe9" +dependencies = [ + "bech32", + "bip39", + "cryptoxide", + "ed25519-bip32", + "pallas-crypto", + "rand 0.8.5", + "thiserror 1.0.69", +] + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + +[[package]] +name = "parking_lot" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets 0.52.6", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pbjson" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1030c719b0ec2a2d25a5df729d6cff1acf3cc230bf766f4f97833591f7577b90" +dependencies = [ + "base64 0.21.7", + "serde", +] + +[[package]] +name = "pbjson-build" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2580e33f2292d34be285c5bc3dba5259542b083cfad6037b6d70345f24dcb735" +dependencies = [ + "heck 0.4.1", + "itertools 0.11.0", + "prost", + "prost-types", +] + +[[package]] +name = "pbjson-types" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18f596653ba4ac51bdecbb4ef6773bc7f56042dc13927910de1684ad3d32aa12" +dependencies = [ + "bytes", + "chrono", + "pbjson", + "pbjson-build", + "prost", + "prost-build", + "serde", +] + +[[package]] +name = "pbkdf2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2" +dependencies = [ + "digest", + "hmac", +] + +[[package]] +name = "pem" +version = "3.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38af38e8470ac9dee3ce1bae1af9c1671fffc44ddfd8bd1d0a3445bf349a8ef3" +dependencies = [ + "base64 0.22.1", + "serde", +] + +[[package]] +name = "pem-rfc7468" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +dependencies = [ + "base64ct", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "petgraph" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" +dependencies = [ + "fixedbitset", + "indexmap 2.10.0", +] + +[[package]] +name = "phf" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "913273894cec178f401a31ec4b656318d95473527be05c0752cc41cdc32be8b7" +dependencies = [ + "phf_shared 0.12.1", +] + +[[package]] +name = "phf_shared" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67eabc2ef2a60eb7faa00097bd1ffdb5bd28e62bf39990626a582201b7a754e5" +dependencies = [ + "siphasher", +] + +[[package]] +name = "phf_shared" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06005508882fb681fd97892ecff4b7fd0fee13ef1aa569f8695dae7ab9099981" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pico-args" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" + +[[package]] +name = "pin-project" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677f1add503faace112b9f1373e43e9e054bfdd22ff1a63c1bc485eaec6a6a8a" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e918e4ff8c4549eb882f14b3a4bc8c8bc93de829416eacf579f1207a8fbf861" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "piper" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" +dependencies = [ + "atomic-waker", + "fastrand", + "futures-io", +] + +[[package]] +name = "pkcs8" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +dependencies = [ + "der", + "spki", +] + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "plotters" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aeb6f403d7a4911efb1e33402027fc44f29b5bf6def3effcc22d7bb75f2b747" +dependencies = [ + "num-traits", + "plotters-backend", + "plotters-svg", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "plotters-backend" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df42e13c12958a16b3f7f4386b9ab1f3e7933914ecea48da7139435263a4172a" + +[[package]] +name = "plotters-svg" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51bae2ac328883f7acdfea3d66a7c35751187f870bc81f94563733a154d7a670" +dependencies = [ + "plotters-backend", +] + +[[package]] +name = "pollable-map" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d6bdfa83e9df9f8aed76d670be96ab6e4043a1c4808da1df9005feed1a82293" +dependencies = [ + "futures", + "futures-timeout", +] + +[[package]] +name = "polling" +version = "3.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ee9b2fa7a4517d2c91ff5bc6c297a427a96749d15f98fcdbb22c05571a4d4b7" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix 1.0.8", + "windows-sys 0.60.2", +] + +[[package]] +name = "poly1305" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +dependencies = [ + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "polyval" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" +dependencies = [ + "cfg-if", + "cpufeatures", + "opaque-debug", + "universal-hash", +] + +[[package]] +name = "portable-atomic" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f84267b20a16ea918e43c6a88433c2d54fa145c92a811b5b047ccbe153674483" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "postcard" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" +dependencies = [ + "cobs", + "embedded-io 0.4.0", + "embedded-io 0.6.1", + "serde", +] + +[[package]] +name = "potential_utf" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "precomputed-hash" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" + +[[package]] +name = "pretty_assertions" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ae130e2f271fbc2ac3a40fb1d07180839cdbbe443c7a27e1e3c13c5cac0116d" +dependencies = [ + "diff", + "yansi", +] + +[[package]] +name = "prettyplease" +version = "0.2.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff24dfcda44452b9816fff4cd4227e1bb73ff5a2f1bc1105aa92fb8565ce44d2" +dependencies = [ + "proc-macro2", + "syn 2.0.104", +] + +[[package]] +name = "primeorder" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "353e1ca18966c16d9deb1c69278edbc5f194139612772bd9537af60ac231e1e6" +dependencies = [ + "elliptic-curve", +] + +[[package]] +name = "proc-macro-crate" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edce586971a4dfaa28950c6f18ed55e0406c1ab88bbce2c6f6293a7aaba73d35" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro-error-attr2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5" +dependencies = [ + "proc-macro2", + "quote", +] + +[[package]] +name = "proc-macro-error2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802" +dependencies = [ + "proc-macro-error-attr2", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prometheus-client" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf41c1a7c32ed72abe5082fb19505b969095c12da9f5732a4bc9878757fd087c" +dependencies = [ + "dtoa", + "itoa", + "parking_lot", + "prometheus-client-derive-encode", +] + +[[package]] +name = "prometheus-client-derive-encode" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "440f724eba9f6996b75d63681b0a92b06947f1457076d503a4d2e2c8f56442b8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "prost" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" +dependencies = [ + "bytes", + "heck 0.5.0", + "itertools 0.12.1", + "log", + "multimap", + "once_cell", + "petgraph", + "prettyplease", + "prost", + "prost-types", + "regex", + "syn 2.0.104", + "tempfile", +] + +[[package]] +name = "prost-derive" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +dependencies = [ + "anyhow", + "itertools 0.12.1", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "prost-types" +version = "0.12.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +dependencies = [ + "prost", +] + +[[package]] +name = "pulley-interpreter" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b89c4319786b16c1a6a38ee04788d32c669b61ba4b69da2162c868c18be99c1b" +dependencies = [ + "cranelift-bitset", + "log", + "pulley-macros", + "wasmtime-internal-math", +] + +[[package]] +name = "pulley-macros" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938543690519c20c3a480d20a8efcc8e69abeb44093ab1df4e7c1f81f26c677a" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "quick-protobuf" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d6da84cc204722a989e01ba2f6e1e276e190f22263d0cb6ce8526fcdb0d2e1f" +dependencies = [ + "byteorder", +] + +[[package]] +name = "quick-protobuf-codec" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15a0580ab32b169745d7a39db2ba969226ca16738931be152a3209b409de2474" +dependencies = [ + "asynchronous-codec", + "bytes", + "quick-protobuf", + "thiserror 1.0.69", + "unsigned-varint 0.8.0", +] + +[[package]] +name = "quinn" +version = "0.11.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626214629cda6781b6dc1d316ba307189c85ba657213ce642d9c77670f8202c8" +dependencies = [ + "bytes", + "cfg_aliases", + "futures-io", + "pin-project-lite", + "quinn-proto", + "quinn-udp", + "rustc-hash", + "rustls", + "socket2 0.5.10", + "thiserror 2.0.12", + "tokio", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-proto" +version = "0.11.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49df843a9161c85bb8aae55f101bc0bac8bcafd637a620d9122fd7e0b2f7422e" +dependencies = [ + "bytes", + "getrandom 0.3.3", + "lru-slab", + "rand 0.9.2", + "ring", + "rustc-hash", + "rustls", + "rustls-pki-types", + "slab", + "thiserror 2.0.12", + "tinyvec", + "tracing", + "web-time", +] + +[[package]] +name = "quinn-udp" +version = "0.5.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcebb1209ee276352ef14ff8732e24cc2b02bbac986cd74a4c81bcb2f9881970" +dependencies = [ + "cfg_aliases", + "libc", + "once_cell", + "socket2 0.5.10", + "tracing", + "windows-sys 0.59.0", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.3", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.3", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.16", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.3", +] + +[[package]] +name = "rawpointer" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3" + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "rcgen" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75e669e5202259b5314d1ea5397316ad400819437857b90861765f24c4cf80a2" +dependencies = [ + "pem", + "ring", + "rustls-pki-types", + "time", + "x509-parser 0.16.0", + "yasna", +] + +[[package]] +name = "redox_syscall" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +dependencies = [ + "bitflags 2.9.1", +] + +[[package]] +name = "redox_users" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43" +dependencies = [ + "getrandom 0.2.16", + "libredox", + "thiserror 1.0.69", +] + +[[package]] +name = "redox_users" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78eaea1f52c56d57821be178b2d47e09ff26481a6042e8e042fcb0ced068b470" +dependencies = [ + "getrandom 0.2.16", + "libredox", + "thiserror 2.0.12", +] + +[[package]] +name = "ref-cast" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0ae411dbe946a674d89546582cea4ba2bb8defac896622d6496f14c23ba5cf" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1165225c21bff1f3bbce98f5a1f889949bc902d3575308cc7b0de30b4f6d27c7" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "referencing" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0c7a0ce4e6f443ac9fb6774a8e4c317f9122dcada54e9ca91e12cdbbae1cd1d" +dependencies = [ + "ahash", + "fluent-uri", + "once_cell", + "parking_lot", + "percent-encoding", + "serde_json", +] + +[[package]] +name = "regalloc2" +version = "0.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5216b1837de2149f8bc8e6d5f88a9326b63b8c836ed58ce4a0a29ec736a59734" +dependencies = [ + "allocator-api2", + "bumpalo", + "hashbrown 0.15.4", + "log", + "rustc-hash", + "smallvec", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "reqwest" +version = "0.12.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbc931937e6ca3a06e3b6c0aa7841849b160a90351d6ab467a8b9b9959767531" +dependencies = [ + "base64 0.22.1", + "bytes", + "encoding_rs", + "futures-channel", + "futures-core", + "futures-util", + "h2 0.4.11", + "http 1.3.1", + "http-body 1.0.1", + "http-body-util", + "hyper 1.6.0", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "js-sys", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 1.0.2", + "tokio", + "tokio-native-tls", + "tower 0.5.2", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "resolv-conf" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95325155c684b1c89f7765e30bc1c42e4a6da51ca513615660cb8a62ef9a88e3" + +[[package]] +name = "rfc6979" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dd2a808d456c4a54e300a23e9f5a67e122c3024119acbfd73e3bf664491cb2" +dependencies = [ + "hmac", + "subtle", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.16", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "ripemd" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd124222d17ad93a644ed9d011a40f4fb64aa54275c08cc216524a9ea82fb09f" +dependencies = [ + "digest", +] + +[[package]] +name = "rlimit" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7043b63bd0cd1aaa628e476b80e6d4023a3b50eb32789f2728908107bd0c793a" +dependencies = [ + "libc", +] + +[[package]] +name = "roxmltree" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" + +[[package]] +name = "rtnetlink" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a552eb82d19f38c3beed3f786bd23aa434ceb9ac43ab44419ca6d67a7e186c0" +dependencies = [ + "futures", + "log", + "netlink-packet-core", + "netlink-packet-route", + "netlink-packet-utils", + "netlink-proto", + "netlink-sys", + "nix", + "thiserror 1.0.69", + "tokio", +] + +[[package]] +name = "rust-ipfs" +version = "0.15.0" +source = "git+https://github.com/dariusc93/rust-ipfs?rev=26b99cb#26b99cbfcfe45d8dbdf9770193a407fc7b4b8032" +dependencies = [ + "anyhow", + "async-rt", + "async-stream", + "async-trait", + "asynchronous-codec", + "base64 0.22.1", + "bytes", + "chrono", + "either", + "fs2", + "futures", + "futures-timeout", + "futures-timer", + "getrandom 0.2.16", + "hickory-resolver", + "hkdf", + "idb", + "indexmap 2.10.0", + "ipld-core", + "ipld-dagpb", + "libp2p", + "libp2p-allow-block-list", + "libp2p-connection-limits", + "libp2p-relay-manager", + "multibase", + "multihash", + "multihash-codetable", + "multihash-derive", + "p256", + "parking_lot", + "pem", + "pollable-map", + "quick-protobuf", + "quick-protobuf-codec", + "rand 0.8.5", + "rand_chacha 0.3.1", + "rcgen", + "rlimit", + "rust-ipns", + "rust-unixfs", + "sec1", + "send_wrapper 0.6.0", + "serde", + "serde-wasm-bindgen", + "serde_ipld_dagcbor", + "serde_ipld_dagjson", + "serde_json", + "sha2", + "simple_x509", + "thiserror 2.0.12", + "tokio", + "tokio-stream", + "tokio-util", + "tracing", + "tracing-futures", + "unsigned-varint 0.8.0", + "wasm-bindgen-futures", + "web-time", + "zeroize", +] + +[[package]] +name = "rust-ipns" +version = "0.7.0" +source = "git+https://github.com/dariusc93/rust-ipfs?rev=26b99cb#26b99cbfcfe45d8dbdf9770193a407fc7b4b8032" +dependencies = [ + "bytes", + "chrono", + "cid", + "derive_more", + "getrandom 0.2.16", + "libp2p-identity", + "multihash", + "quick-protobuf", + "serde", + "serde_ipld_dagcbor", +] + +[[package]] +name = "rust-unixfs" +version = "0.5.0" +source = "git+https://github.com/dariusc93/rust-ipfs?rev=26b99cb#26b99cbfcfe45d8dbdf9770193a407fc7b4b8032" +dependencies = [ + "either", + "filetime", + "ipld-core", + "ipld-dagpb", + "multihash", + "multihash-codetable", + "multihash-derive", + "quick-protobuf", + "sha2", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" + +[[package]] +name = "rustc-hash" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rusticata-macros" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "faf0c4a6ece9950b9abdb62b1cfcf2a68b3b67a10ba445b3bb85be2a293d0632" +dependencies = [ + "nom 7.1.3", +] + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.9.1", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" +dependencies = [ + "bitflags 2.9.1", + "errno", + "libc", + "linux-raw-sys 0.9.4", + "windows-sys 0.60.2", +] + +[[package]] +name = "rustls" +version = "0.23.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc" +dependencies = [ + "brotli", + "brotli-decompressor", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", + "zlib-rs", +] + +[[package]] +name = "rustls-pki-types" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +dependencies = [ + "web-time", + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" + +[[package]] +name = "rusty_ulid" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e0719c0520bdfc6f5a02c8bd8b20f9fc8785de57d4e117e144ade9c5f152626" +dependencies = [ + "rand 0.8.5", + "serde", + "time", +] + +[[package]] +name = "rustybuzz" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3c7c96f8a08ee34eff8857b11b49b07d71d1c3f4e88f8a88d4c9e9f90b1702" +dependencies = [ + "bitflags 2.9.1", + "bytemuck", + "core_maths", + "log", + "smallvec", + "ttf-parser", + "unicode-bidi-mirroring", + "unicode-ccc", + "unicode-properties", + "unicode-script", +] + +[[package]] +name = "rw-stream-sink" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8c9026ff5d2f23da5e45bbc283f156383001bfb09c4e44256d02c1a685fe9a1" +dependencies = [ + "futures", + "pin-project", + "static_assertions", +] + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "saffron" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03fb9a628596fc7590eb7edbf7b0613287be78df107f5f97b118aad59fb2eea9" +dependencies = [ + "chrono", + "nom 5.1.3", +] + +[[package]] +name = "salsa20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97a22f5af31f73a954c10289c93e8a50cc23d971e80ee446f1f6f7137a088213" +dependencies = [ + "cipher", +] + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scc" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22b2d775fb28f245817589471dd49c5edf64237f4a19d10ce9a92ff4651a27f4" +dependencies = [ + "sdd", +] + +[[package]] +name = "schannel" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "schemars" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "schemars" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" +dependencies = [ + "dyn-clone", + "ref-cast", + "serde", + "serde_json", +] + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "sdd" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "490dcfcbfef26be6800d11870ff2df8774fa6e86d047e3e8c8a76b25655e41ca" + +[[package]] +name = "sec1" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e97a565f76233a6003f9f5c54be1d9c5bdfa3eccfb189469f11ec4901c47dc" +dependencies = [ + "base16ct", + "der", + "generic-array", + "pkcs8", + "subtle", + "zeroize", +] + +[[package]] +name = "secp256k1" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25996b82292a7a57ed3508f052cfff8640d38d32018784acd714758b43da9c8f" +dependencies = [ + "secp256k1-sys", +] + +[[package]] +name = "secp256k1-sys" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4473013577ec77b4ee3668179ef1186df3146e2cf2d927bd200974c6fe60fd99" +dependencies = [ + "cc", +] + +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags 2.9.1", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +dependencies = [ + "serde", +] + +[[package]] +name = "send_wrapper" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" + +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde-untagged" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "299d9c19d7d466db4ab10addd5703e4c615dec2a5a16dbbafe191045e87ee66e" +dependencies = [ + "erased-serde", + "serde", + "typeid", +] + +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float", + "serde", +] + +[[package]] +name = "serde-wasm-bindgen" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8302e169f0eddcc139c70f139d19d6467353af16f9fce27e8c30158036a1e16b" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + +[[package]] +name = "serde_bytes" +version = "0.11.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8437fd221bde2d4ca316d61b90e337e9e702b3820b87d63caa9ba6c02bd06d96" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "serde_ipld_dagcbor" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99600723cf53fb000a66175555098db7e75217c415bdd9a16a65d52a19dcc4fc" +dependencies = [ + "cbor4ii 0.2.14", + "ipld-core", + "scopeguard", + "serde", +] + +[[package]] +name = "serde_ipld_dagjson" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3359b47ba7f4a306ef5984665e10539e212e97217afa489437d533208eecda36" +dependencies = [ + "ipld-core", + "serde", + "serde_json", +] + +[[package]] +name = "serde_json" +version = "1.0.141" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_regex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8136f1a4ea815d7eac4101cfd0b16dc0cb5e1fe1b8609dfd728058656b7badf" +dependencies = [ + "regex", + "serde", +] + +[[package]] +name = "serde_spanned" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" +dependencies = [ + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_with" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2c45cd61fefa9db6f254525d46e392b852e0e61d9a1fd36e5bd183450a556d5" +dependencies = [ + "base64 0.22.1", + "chrono", + "hex", + "indexmap 1.9.3", + "indexmap 2.10.0", + "schemars 0.9.0", + "schemars 1.0.4", + "serde", + "serde_derive", + "serde_json", + "serde_with_macros", + "time", +] + +[[package]] +name = "serde_with_macros" +version = "3.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de90945e6565ce0d9a25098082ed4ee4002e047cb59892c318d66821e14bb30f" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "serial_test" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9" +dependencies = [ + "fslock", + "futures", + "log", + "once_cell", + "parking_lot", + "scc", + "serial_test_derive", +] + +[[package]] +name = "serial_test_derive" +version = "3.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "sha1" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha2" +version = "0.10.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sha3" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75872d278a8f37ef87fa0ddbda7802605cb18344497949862c0d4dcb291eba60" +dependencies = [ + "digest", + "keccak", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +dependencies = [ + "libc", +] + +[[package]] +name = "signature" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +dependencies = [ + "digest", + "rand_core 0.6.4", +] + +[[package]] +name = "similar" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" + +[[package]] +name = "simple_asn1" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eb4ea60fb301dc81dfc113df680571045d375ab7345d171c5dc7d7e13107a80" +dependencies = [ + "chrono", + "num-bigint", + "num-traits", + "thiserror 1.0.69", +] + +[[package]] +name = "simple_x509" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417fc25f99e6af54350cbc26997572b6ee04c4b8deec627ce5f16f76a7ed887b" +dependencies = [ + "chrono", + "num-traits", + "simple_asn1", +] + +[[package]] +name = "simplecss" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9c6883ca9c3c7c90e888de77b7a5c849c779d25d74a1269b0218b14e8b136c" +dependencies = [ + "log", +] + +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + +[[package]] +name = "slab" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" + +[[package]] +name = "slotmap" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" +dependencies = [ + "version_check", +] + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +dependencies = [ + "serde", +] + +[[package]] +name = "snow" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "850948bee068e713b8ab860fe1adc4d109676ab4c3b621fd8147f06b261f2f85" +dependencies = [ + "aes-gcm", + "blake2", + "chacha20poly1305", + "curve25519-dalek", + "rand_core 0.6.4", + "ring", + "rustc_version", + "sha2", + "subtle", +] + +[[package]] +name = "socket2" +version = "0.5.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e22376abed350d73dd1cd119b57ffccad95b4e585a7cda43e286245ce23c0678" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "socket2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "soketto" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e859df029d160cb88608f5d7df7fb4753fd20fdfb4de5644f3d8b8440841721" +dependencies = [ + "base64 0.22.1", + "bytes", + "futures", + "httparse", + "log", + "rand 0.8.5", + "sha1", +] + +[[package]] +name = "spki" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +dependencies = [ + "base64ct", + "der", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strict-num" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" +dependencies = [ + "float-cmp", +] + +[[package]] +name = "string_cache" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf776ba3fa74f83bf4b63c3dcbbf82173db2632ed8452cb2d891d33f459de70f" +dependencies = [ + "new_debug_unreachable", + "parking_lot", + "phf_shared 0.11.3", + "precomputed-hash", +] + +[[package]] +name = "stringzilla" +version = "3.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37136e6ed7d761204e8c091ca89f4807f75b7915d78a9c91e43303e5b6ce4e54" +dependencies = [ + "cc", +] + +[[package]] +name = "strobe-rs" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98fe17535ea31344936cc58d29fec9b500b0452ddc4cc24c429c8a921a0e84e5" +dependencies = [ + "bitflags 1.3.2", + "byteorder", + "keccak", + "subtle", + "zeroize", +] + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "svgtypes" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68c7541fff44b35860c1a7a47a7cadf3e4a304c457b58f9870d9706ece028afc" +dependencies = [ + "kurbo", + "siphasher", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.9.1", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tagptr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417" + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[package]] +name = "target-lexicon" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e502f78cdbb8ba4718f566c418c52bc729126ffd16baee5baa718cf25dd5a69a" + +[[package]] +name = "temp-dir" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83176759e9416cf81ee66cb6508dbfe9c96f20b8b56265a39917551c23c70964" + +[[package]] +name = "tempfile" +version = "3.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" +dependencies = [ + "fastrand", + "getrandom 0.3.3", + "once_cell", + "rustix 1.0.8", + "windows-sys 0.59.0", +] + +[[package]] +name = "term" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" +dependencies = [ + "dirs-next", + "rustversion", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "test_component" +version = "0.1.0" +dependencies = [ + "serde_json", + "url", + "wit-bindgen", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl 2.0.12", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "thread_local" +version = "1.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f60246a4944f24f6e018aa17cdeffb7818b76356965d03b07d6a9886e8962185" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "time" +version = "0.3.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" + +[[package]] +name = "time-macros" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "tiny-skia-path" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + +[[package]] +name = "tinystr" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinytemplate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be4d6b5f19ff7664e8c98d03e2139cb510db9b0a60b55f8e8709b689d939b6bc" +dependencies = [ + "serde", + "serde_json", +] + +[[package]] +name = "tinyvec" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09b3661f17e86524eccd4371ab0429194e0d7c008abb45f7a7495b1719463c71" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tls_codec" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de2e01245e2bb89d6f05801c564fa27624dbd7b1846859876c7dad82e90bf6b" +dependencies = [ + "tls_codec_derive", + "zeroize", +] + +[[package]] +name = "tls_codec_derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d2e76690929402faae40aebdda620a2c0e25dd6d3b9afe48867dfd95991f4bd" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "tokio" +version = "1.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43864ed400b6043a4757a25c7a64a8efde741aed79a056a2fb348a406701bb35" +dependencies = [ + "backtrace", + "bytes", + "io-uring", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "slab", + "socket2 0.6.0", + "tokio-macros", + "windows-sys 0.59.0", +] + +[[package]] +name = "tokio-io-timeout" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bd86198d9ee903fedd2f9a2e72014287c0d9167e4ae43b5853007205dda1b76" +dependencies = [ + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-stream" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eca58d7bba4a75707817a2c44174253f9236b2d5fbd055602e9d5c07c139a047" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +dependencies = [ + "bytes", + "futures-core", + "futures-io", + "futures-sink", + "futures-util", + "hashbrown 0.15.4", + "pin-project-lite", + "slab", + "tokio", +] + +[[package]] +name = "toml" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" +dependencies = [ + "indexmap 2.10.0", + "serde", + "serde_spanned", + "toml_datetime", + "toml_write", + "winnow", +] + +[[package]] +name = "toml_write" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" + +[[package]] +name = "tonic" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +dependencies = [ + "async-stream", + "async-trait", + "axum", + "base64 0.21.7", + "bytes", + "h2 0.3.27", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.32", + "hyper-timeout", + "percent-encoding", + "pin-project", + "prost", + "tokio", + "tokio-stream", + "tower 0.4.13", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" +dependencies = [ + "futures-core", + "futures-util", + "indexmap 1.9.3", + "pin-project", + "pin-project-lite", + "rand 0.8.5", + "slab", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper 1.0.2", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +dependencies = [ + "bitflags 2.9.1", + "bytes", + "futures-util", + "http 1.3.1", + "http-body 1.0.1", + "iri-string", + "pin-project-lite", + "tower 0.5.2", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "tracing-core" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "futures", + "futures-task", + "pin-project", + "tracing", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-serde" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704b1aeb7be0d0a84fc9828cae51dab5970fee5088f83d1dd7ee6f6246fc6ff1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "time", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "ttf-parser" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" +dependencies = [ + "core_maths", +] + +[[package]] +name = "typeid" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" + +[[package]] +name = "typenum" +version = "1.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" + +[[package]] +name = "uint" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "909988d098b2f738727b161a106cfc7cab00c539c2687a8836f8e565976fb53e" +dependencies = [ + "byteorder", + "crunchy", + "hex", + "static_assertions", +] + +[[package]] +name = "unicode-bidi" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c1cb5db39152898a79168971543b1cb5020dff7fe43c8dc468b0885f5e29df5" + +[[package]] +name = "unicode-bidi-mirroring" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfa6e8c60bb66d49db113e0125ee8711b7647b5579dc7f5f19c42357ed039fe" + +[[package]] +name = "unicode-ccc" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce61d488bcdc9bc8b5d1772c404828b17fc481c0a582b5581e95fb233aef503e" + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "unicode-normalization" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-properties" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70f2a8b45122e719eb623c01822704c4e0907e7e426a05927e1a1cfff5b75d0" + +[[package]] +name = "unicode-script" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb421b350c9aff471779e262955939f565ec18b86c15364e6bdf0d662ca7c1f" + +[[package]] +name = "unicode-segmentation" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" + +[[package]] +name = "unicode-vo" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1d386ff53b415b7fe27b50bb44679e2cc4660272694b7b6f3326d8480823a94" + +[[package]] +name = "unicode-width" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a1a07cc7db3810833284e8d372ccdc6da29741639ecc70c9ec107df0fa6154c" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common", + "subtle", +] + +[[package]] +name = "unsigned-varint" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6889a77d49f1f013504cec6bf97a2c730394adedaeb1deb5ea08949a50541105" + +[[package]] +name = "unsigned-varint" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb066959b24b5196ae73cb057f45598450d2c5f71460e98c49b738086eff9c06" +dependencies = [ + "asynchronous-codec", + "bytes", +] + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "unty" +version = "0.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "usvg" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80be9b06fbae3b8b303400ab20778c80bbaf338f563afe567cf3c9eea17b47ef" +dependencies = [ + "base64 0.22.1", + "data-url", + "flate2", + "fontdb", + "imagesize", + "kurbo", + "log", + "pico-args", + "roxmltree", + "rustybuzz", + "simplecss", + "siphasher", + "strict-num", + "svgtypes", + "tiny-skia-path", + "unicode-bidi", + "unicode-script", + "unicode-vo", + "xmlwriter", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "utxorpc-spec" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6ed1da9027ea2010458a9aa5da7d896518176165d630f0325ad2c994f69772b" +dependencies = [ + "bytes", + "futures-core", + "pbjson", + "pbjson-types", + "prost", + "serde", + "tonic", +] + +[[package]] +name = "uuid" +version = "1.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d" +dependencies = [ + "getrandom 0.3.3", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "uuid-simd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b082222b4f6619906941c17eb2297fff4c2fb96cb60164170522942a200bd8" +dependencies = [ + "outref", + "uuid", + "vsimd", +] + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "value-bag" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "943ce29a8a743eb10d6082545d861b24f9d1b160b7d741e0f2cdf726bec909c5" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "virtue" +version = "0.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "051eb1abcf10076295e815102942cc58f9d5e3b4560e46e53c21e8ff6f3af7b1" + +[[package]] +name = "vsimd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt 0.39.0", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn 2.0.104", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wasm-encoder" +version = "0.235.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3bc393c395cb621367ff02d854179882b9a351b4e0c93d1397e6090b53a5c2a" +dependencies = [ + "leb128fmt", + "wasmparser 0.235.0", +] + +[[package]] +name = "wasm-encoder" +version = "0.236.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3108979166ab0d3c7262d2e16a2190ffe784b2a5beb963edef154b5e8e07680b" +dependencies = [ + "leb128fmt", + "wasmparser 0.236.0", +] + +[[package]] +name = "wasm-metadata" +version = "0.235.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b055604ba04189d54b8c0ab2c2fc98848f208e103882d5c0b984f045d5ea4d20" +dependencies = [ + "anyhow", + "indexmap 2.10.0", + "wasm-encoder 0.235.0", + "wasmparser 0.235.0", +] + +[[package]] +name = "wasmparser" +version = "0.235.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "161296c618fa2d63f6ed5fffd1112937e803cb9ec71b32b01a76321555660917" +dependencies = [ + "bitflags 2.9.1", + "hashbrown 0.15.4", + "indexmap 2.10.0", + "semver", + "serde", +] + +[[package]] +name = "wasmparser" +version = "0.236.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d1eee846a705f6f3cb9d7b9f79b54583810f1fb57a1e3aea76d1742db2e3d2" +dependencies = [ + "bitflags 2.9.1", + "indexmap 2.10.0", + "semver", +] + +[[package]] +name = "wasmprinter" +version = "0.235.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75aa8e9076de6b9544e6dab4badada518cca0bf4966d35b131bbd057aed8fa0a" +dependencies = [ + "anyhow", + "termcolor", + "wasmparser 0.235.0", +] + +[[package]] +name = "wasmtime" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe976922a16af3b0d67172c473d1fd4f1aa5d0af9c8ba6538c741f3af686f4" +dependencies = [ + "addr2line", + "anyhow", + "bitflags 2.9.1", + "bumpalo", + "cc", + "cfg-if", + "encoding_rs", + "hashbrown 0.15.4", + "indexmap 2.10.0", + "libc", + "log", + "mach2", + "memfd", + "object", + "once_cell", + "postcard", + "pulley-interpreter", + "rustix 1.0.8", + "semver", + "serde", + "serde_derive", + "smallvec", + "target-lexicon", + "wasmparser 0.235.0", + "wasmtime-environ", + "wasmtime-internal-asm-macros", + "wasmtime-internal-component-macro", + "wasmtime-internal-component-util", + "wasmtime-internal-cranelift", + "wasmtime-internal-fiber", + "wasmtime-internal-jit-icache-coherence", + "wasmtime-internal-math", + "wasmtime-internal-slab", + "wasmtime-internal-unwinder", + "wasmtime-internal-versioned-export-macros", + "wasmtime-internal-winch", + "wat", + "windows-sys 0.59.0", +] + +[[package]] +name = "wasmtime-environ" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44b6264a78d806924abbc76bbc75eac24976bc83bdfb938e5074ae551242436f" +dependencies = [ + "anyhow", + "cranelift-bitset", + "cranelift-entity", + "gimli", + "indexmap 2.10.0", + "log", + "object", + "postcard", + "semver", + "serde", + "serde_derive", + "smallvec", + "target-lexicon", + "wasm-encoder 0.235.0", + "wasmparser 0.235.0", + "wasmprinter", + "wasmtime-internal-component-util", +] + +[[package]] +name = "wasmtime-internal-asm-macros" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6775a9b516559716e5710e95a8014ca0adcc81e5bf4d3ad7899d89ae40094d1a" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-internal-component-macro" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc3d098205e405e6b5ced06c1815621b823464b6ea289eaafe494139b0aee287" +dependencies = [ + "anyhow", + "proc-macro2", + "quote", + "syn 2.0.104", + "wasmtime-internal-component-util", + "wasmtime-internal-wit-bindgen", + "wit-parser", +] + +[[package]] +name = "wasmtime-internal-component-util" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "219252067216242ed2b32665611b0ee356d6e92cbb897ecb9a10cae0b97bdeca" + +[[package]] +name = "wasmtime-internal-cranelift" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ec9ad7565e6a8de7cb95484e230ff689db74a4a085219e0da0cbd637a29c01c" +dependencies = [ + "anyhow", + "cfg-if", + "cranelift-codegen", + "cranelift-control", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "gimli", + "itertools 0.14.0", + "log", + "object", + "pulley-interpreter", + "smallvec", + "target-lexicon", + "thiserror 2.0.12", + "wasmparser 0.235.0", + "wasmtime-environ", + "wasmtime-internal-math", + "wasmtime-internal-versioned-export-macros", +] + +[[package]] +name = "wasmtime-internal-fiber" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b636ff8b220ebaf29dfe3b23770e4b2bad317b9683e3bf7345e162387385b39" +dependencies = [ + "anyhow", + "cc", + "cfg-if", + "libc", + "rustix 1.0.8", + "wasmtime-internal-asm-macros", + "wasmtime-internal-versioned-export-macros", + "windows-sys 0.59.0", +] + +[[package]] +name = "wasmtime-internal-jit-icache-coherence" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4417e06b7f80baff87d9770852c757a39b8d7f11d78b2620ca992b8725f16f50" +dependencies = [ + "anyhow", + "cfg-if", + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "wasmtime-internal-math" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7710d5c4ecdaa772927fd11e5dc30a9a62d1fc8fe933e11ad5576ad596ab6612" +dependencies = [ + "libm", +] + +[[package]] +name = "wasmtime-internal-slab" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6ab22fabe1eed27ab01fd47cd89deacf43ad222ed7fd169ba6f4dd1fbddc53b" + +[[package]] +name = "wasmtime-internal-unwinder" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "307708f302f5dcf19c1bbbfb3d9f2cbc837dd18088a7988747b043a46ba38ecc" +dependencies = [ + "anyhow", + "cfg-if", + "cranelift-codegen", + "log", + "object", +] + +[[package]] +name = "wasmtime-internal-versioned-export-macros" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "342b0466f92b7217a4de9e114175fedee1907028567d2548bcd42f71a8b5b016" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "wasmtime-internal-winch" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2012e7384c25b91aab2f1b6a1e1cbab9d0f199bbea06cc873597a3f047f05730" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "object", + "target-lexicon", + "wasmparser 0.235.0", + "wasmtime-environ", + "wasmtime-internal-cranelift", + "winch-codegen", +] + +[[package]] +name = "wasmtime-internal-wit-bindgen" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ae057d44a5b60e6ec529b0c21809a9d1fc92e91ef6e0f6771ed11dd02a94a08" +dependencies = [ + "anyhow", + "heck 0.5.0", + "indexmap 2.10.0", + "wit-parser", +] + +[[package]] +name = "wast" +version = "236.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11d6b6faeab519ba6fbf9b26add41617ca6f5553f99ebc33d876e591d2f4f3c6" +dependencies = [ + "bumpalo", + "leb128fmt", + "memchr", + "unicode-width", + "wasm-encoder 0.236.0", +] + +[[package]] +name = "wat" +version = "1.236.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc31704322400f461f7f31a5f9190d5488aaeafb63ae69ad2b5888d2704dcb08" +dependencies = [ + "wast", +] + +[[package]] +name = "web-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "0.26.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.2", +] + +[[package]] +name = "webpki-roots" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8983c3ab33d6fb807cfcdad2491c4ea8cbc8ed839181c7dfd9c67c83e261b2" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "widestring" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd7cf3379ca1aac9eea11fba24fd7e315d621f8dfe35c8d7d2be8b793726e07d" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "winch-codegen" +version = "35.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "839a334ef7c62d8368dbd427e767a6fbb1ba08cc12ecce19cbb666c10613b585" +dependencies = [ + "anyhow", + "cranelift-assembler-x64", + "cranelift-codegen", + "gimli", + "regalloc2", + "smallvec", + "target-lexicon", + "thiserror 2.0.12", + "wasmparser 0.235.0", + "wasmtime-environ", + "wasmtime-internal-cranelift", + "wasmtime-internal-math", +] + +[[package]] +name = "windows" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efc5cf48f83140dcaab716eeaea345f9e93d0018fb81162753a3f76c3397b538" +dependencies = [ + "windows-core 0.53.0", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows" +version = "0.61.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893" +dependencies = [ + "windows-collections", + "windows-core 0.61.2", + "windows-future", + "windows-link", + "windows-numerics", +] + +[[package]] +name = "windows-collections" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3beeceb5e5cfd9eb1d76b381630e82c4241ccd0d27f1a39ed41b2760b255c5e8" +dependencies = [ + "windows-core 0.61.2", +] + +[[package]] +name = "windows-core" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dcc5b895a6377f1ab9fa55acedab1fd5ac0db66ad1e6c7f47e28a22e446a5dd" +dependencies = [ + "windows-result 0.1.2", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result 0.3.4", + "windows-strings", +] + +[[package]] +name = "windows-future" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e" +dependencies = [ + "windows-core 0.61.2", + "windows-link", + "windows-threading", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-numerics" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9150af68066c4c5c07ddc0ce30421554771e528bde427614c61038bc2c92c2b1" +dependencies = [ + "windows-core 0.61.2", + "windows-link", +] + +[[package]] +name = "windows-registry" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e" +dependencies = [ + "windows-link", + "windows-result 0.3.4", + "windows-strings", +] + +[[package]] +name = "windows-result" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.3", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5fe6031c4041849d7c496a8ded650796e7b6ecc19df1a431c1a363342e5dc91" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] + +[[package]] +name = "windows-threading" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b66463ad2e0ea3bbf808b7f1d371311c80e115c0b71d60efc142cafbcfb057a6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + +[[package]] +name = "winnow" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3edebf492c8125044983378ecb5766203ad3b4c2f7a922bd7dd207f6d443e95" +dependencies = [ + "memchr", +] + +[[package]] +name = "winreg" +version = "0.50.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "winreg" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" +dependencies = [ + "cfg-if", + "serde", + "windows-sys 0.48.0", +] + +[[package]] +name = "wit-bindgen" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a18712ff1ec5bd09da500fe1e91dec11256b310da0ff33f8b4ec92b927cf0c6" +dependencies = [ + "wit-bindgen-rt 0.43.0", + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c53468e077362201de11999c85c07c36e12048a990a3e0d69da2bd61da355d0" +dependencies = [ + "anyhow", + "heck 0.5.0", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags 2.9.1", +] + +[[package]] +name = "wit-bindgen-rt" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fd734226eac1fd7c450956964e3a9094c9cee65e9dafdf126feef8c0096db65" +dependencies = [ + "bitflags 2.9.1", + "futures", + "once_cell", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "531ebfcec48e56473805285febdb450e270fa75b2dacb92816861d0473b4c15f" +dependencies = [ + "anyhow", + "heck 0.5.0", + "indexmap 2.10.0", + "prettyplease", + "syn 2.0.104", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.43.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7852bf8a9d1ea80884d26b864ddebd7b0c7636697c6ca10f4c6c93945e023966" +dependencies = [ + "anyhow", + "prettyplease", + "proc-macro2", + "quote", + "syn 2.0.104", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.235.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a57a11109cc553396f89f3a38a158a97d0b1adaec113bd73e0f64d30fb601f" +dependencies = [ + "anyhow", + "bitflags 2.9.1", + "indexmap 2.10.0", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder 0.235.0", + "wasm-metadata", + "wasmparser 0.235.0", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.235.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a1f95a87d03a33e259af286b857a95911eb46236a0f726cbaec1227b3dfc67a" +dependencies = [ + "anyhow", + "id-arena", + "indexmap 2.10.0", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser 0.235.0", +] + +[[package]] +name = "writeable" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" + +[[package]] +name = "x25519-dalek" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e468321c81fb07fa7f4c636c3972b9100f0346e5b6a9f2bd0603a52f7ed277" +dependencies = [ + "curve25519-dalek", + "rand_core 0.6.4", + "serde", + "zeroize", +] + +[[package]] +name = "x509-cert" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1301e935010a701ae5f8655edc0ad17c44bad3ac5ce8c39185f75453b720ae94" +dependencies = [ + "const-oid", + "der", + "spki", + "tls_codec", +] + +[[package]] +name = "x509-parser" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcbc162f30700d6f3f82a24bf7cc62ffe7caea42c0b2cba8bf7f3ae50cf51f69" +dependencies = [ + "asn1-rs 0.6.2", + "data-encoding", + "der-parser 9.0.0", + "lazy_static", + "nom 7.1.3", + "oid-registry 0.7.1", + "ring", + "rusticata-macros", + "thiserror 1.0.69", + "time", +] + +[[package]] +name = "x509-parser" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4569f339c0c402346d4a75a9e39cf8dad310e287eef1ff56d4c68e5067f53460" +dependencies = [ + "asn1-rs 0.7.1", + "data-encoding", + "der-parser 10.0.0", + "lazy_static", + "nom 7.1.3", + "oid-registry 0.8.1", + "rusticata-macros", + "thiserror 2.0.12", + "time", +] + +[[package]] +name = "xml-rs" +version = "0.8.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fd8403733700263c6eb89f192880191f1b83e332f7a20371ddcf421c4a337c7" + +[[package]] +name = "xmltree" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7d8a75eaf6557bb84a65ace8609883db44a29951042ada9b393151532e41fcb" +dependencies = [ + "xml-rs", +] + +[[package]] +name = "xmlwriter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" + +[[package]] +name = "yamux" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed0164ae619f2dc144909a9f082187ebb5893693d8c0196e8085283ccd4b776" +dependencies = [ + "futures", + "log", + "nohash-hasher", + "parking_lot", + "pin-project", + "rand 0.8.5", + "static_assertions", +] + +[[package]] +name = "yamux" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2dd50a6d6115feb3e5d7d0efd45e8ca364b6c83722c1e9c602f5764e0e9597" +dependencies = [ + "futures", + "log", + "nohash-hasher", + "parking_lot", + "pin-project", + "rand 0.9.2", + "static_assertions", + "web-time", +] + +[[package]] +name = "yansi" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049" + +[[package]] +name = "yasna" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17bb3549cc1321ae1296b9cdc2698e2b6cb1992adfa19a8c72e5b7a738f44cd" +dependencies = [ + "time", +] + +[[package]] +name = "yoke" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +dependencies = [ + "zeroize_derive", +] + +[[package]] +name = "zeroize_derive" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce36e65b0d2999d2aafac989fb249189a141aee1f53c612c1f37d72631959f69" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "zerotrie" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.104", +] + +[[package]] +name = "zlib-rs" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "626bd9fa9734751fc50d6060752170984d7053f5a39061f524cda68023d4db8a" + +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f49c4d5f0abb602a93fb8736af2a4f4dd9512e36f7f570d66e65ff867ed3b9d" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.15+zstd.1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb81183ddd97d0c74cedf1d50d85c8d08c1b8b68ee863bdee9e706eedba1a237" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/hermes/bin/Cargo.toml b/hermes/bin/Cargo.toml index 14da5be8fe..80ab65b832 100644 --- a/hermes/bin/Cargo.toml +++ b/hermes/bin/Cargo.toml @@ -3,7 +3,7 @@ name = "hermes" description = "The Hermes Node" keywords = ["cardano", "catalyst", "hermes"] categories = ["command-line-utilities"] -version.workspace = true +version = "0.0.5" authors.workspace = true edition.workspace = true license.workspace = true @@ -31,82 +31,80 @@ path = "tests/integration/tests/mod.rs" [dependencies] # specific commit from the `catalyst` branch +# Point to latest pallas when we eliminate the dependency on the old chain follower. pallas = { git = "https://github.com/input-output-hk/catalyst-pallas.git", rev = "709acb19c52c6b789279ecc4bc8793b5d8b5abe9", version = "0.25.0" } +# Our custom crates +hermes-ipfs = { version = "0.0.5", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "hermes-ipfs/v0.0.5" } +cardano-chain-follower = { path = "../crates/cardano-chain-follower", version = "0.0.1" } + # HDF5 is consumed using a git tag, because the latest release is very old, but the code is much more advanced. hdf5 = { package = "hdf5-metno", version = "0.10.1", features = [ "static", "blosc", "blosc-zstd" ] } # needs to enable blosc compression functionality for hdf5 crate -blosc-src = { version = "0.3.4", features = ["lz4", "zlib", "zstd"] } - -# fixes the dependency of libp2p of hermes-ipfs, because latest version uses MSRV higher than ours. -yamux = "=0.13.5" - -criterion = {version = "0.6.0", optional=true} - -cardano-chain-follower = { path = "../crates/cardano-chain-follower", version = "0.0.1" } -hermes-ipfs = { version = "0.0.5", git = "https://github.com/input-output-hk/catalyst-libs.git", tag = "hermes-ipfs/v0.0.5" } +blosc-src = { version = "0.3.6", features = ["lz4", "zlib", "zstd"] } +criterion = {version = "0.7.0", optional=true} wasmtime = { version = "35.0.0", default-features = false, features = ["runtime", "cranelift", "component-model"] } rusty_ulid = "2.0.0" -anyhow = "1.0.89" +anyhow = "1.0.98" hex-literal = "1.0.0" thiserror = "2.0.12" hex = "0.4.3" tracing = {version="0.1.41", features = ["log"] } -tracing-subscriber = { version = "0.3.18", features = ["fmt", "json", "time", "env-filter"] } +tracing-subscriber = { version = "0.3.19", features = ["fmt", "json", "time", "env-filter"] } libtest-mimic = "0.8.1" -crossbeam-queue = "0.3.11" -bip39 = { version="2.1.0", features = ["chinese-simplified", "chinese-traditional", "czech", "french", "italian", "japanese", "korean", "spanish" ] } -iana-time-zone = "0.1.61" -rand = "0.9.1" -bip32 = "0.5.2" +crossbeam-queue = "0.3.12" +bip39 = { version="2.2.0", features = ["chinese-simplified", "chinese-traditional", "czech", "french", "italian", "japanese", "korean", "spanish" ] } +iana-time-zone = "0.1.63" +rand = "0.9.2" +bip32 = "0.5.3" ed25519-bip32 = "0.4.1" dashmap = "6.1.0" -once_cell = "1.20.2" -clap = "4.5.20" -build-info = "0.0.40" +once_cell = "1.21.3" +clap = "4.5.42" +build-info = "0.0.41" derive_more = "2.0.1" -chrono = { version = "0.4.38", features = ["now"] } -chrono-tz = "0.10.0" +chrono = { version = "0.4.41", features = ["now"] } +chrono-tz = "0.10.4" saffron = "0.1.0" -tokio = { version = "1.45.1", features = ["macros", "sync", "rt-multi-thread", "rt", "net"] } -libsqlite3-sys = {version="0.34.0", features = ["bundled"] } -stringzilla = "3.9.8" -temp-dir = "0.1.14" -num_cpus = "1.16.0" -console = "0.15.8" -serde = { version="1.0.210", features = ["derive"] } -serde_json = "1.0.128" -jsonschema = "0.30.0" +tokio = { version = "1.47.0", features = ["macros", "sync", "rt-multi-thread", "rt", "net"] } +libsqlite3-sys = {version="0.35.0", features = ["bundled"] } +stringzilla = "3.12.5" +temp-dir = "0.1.16" +num_cpus = "1.17.0" +console = "0.16.0" +serde = { version="1.0.219", features = ["derive"] } +serde_json = "1.0.141" +jsonschema = "0.32.0" hyper = { version = "1.6.0", features = ["full"] } http-body-util = "0.1.3" -hyper-util = { version = "0.1.13", features = ["server-auto"] } +hyper-util = { version = "0.1.16", features = ["server-auto"] } hmac = "0.12.1" pbkdf2 = "0.12.2" -blake2b_simd = "1.0.2" -sha2 = "0.10.8" -ed25519-dalek = { version="2.1.1", features = ["pem"] } +blake2b_simd = "1.0.3" +sha2 = "0.10.9" +ed25519-dalek = { version="2.2.0", features = ["pem"] } x509-cert = { version="0.2.5", features = ["pem"] } coset = "0.3.8" dirs = "6.0.0" -regex = "1.11.0" -rustls = { version = "0.23.28", default-features = false, features = ["ring"] } -webpki-roots = "1.0.1" +regex = "1.11.1" +rustls = { version = "0.23.31", default-features = false, features = ["ring","brotli","zlib"] } +webpki-roots = "1.0.2" tokio-rustls = { version = "0.26.2", default-features = false, features = ["ring"] } usvg = "0.45.1" uuid = { version = "1.17.0", features = ["v4"] } reqwest = "0.12.22" -url = "2.5.0" +url = "2.5.4" [build-dependencies] -build-info-build = "0.0.40" +build-info-build = "0.0.41" [dev-dependencies] -serial_test = { version = "3.1.1", features = ["file_locks"] } +serial_test = { version = "3.2.0", features = ["file_locks"] } # An override with the "wat" feature added. wasmtime = { version = "35.0.0", default-features = false, features = ["runtime", "cranelift", "component-model", "wat"] } httpmock = "0.7.0" [package.metadata.cargo-machete] -# This is required for HDF5 and hermes-ipfs. -ignored = ["blosc-src", "yamux"] +# This is required for HDF5. +ignored = ["blosc-src"] diff --git a/wasm/.cspell.json b/wasm/.cspell.json index cbd307e7ec..7ca45655ec 100644 --- a/wasm/.cspell.json +++ b/wasm/.cspell.json @@ -6,8 +6,8 @@ "ACCEPTCONN", "ACCES", "ADDRFAMILY", - "ATIM", "atim", + "ATIM", "BADF", "badfd", "bindgen", @@ -16,8 +16,8 @@ "bytestream", "cabi", "Ciovec", - "CLOCKID", "Clockid", + "CLOCKID", "consistient", "constness", "CREAT", @@ -29,13 +29,13 @@ "datalen", "DEADLK", "DGRAM", - "DIRCOOKIE", "Dircookie", + "DIRCOOKIE", "dirflags", "disginguish", "doews", - "Dont", "dont", + "Dont", "DONTNEED", "DQUOT", "DSYNC", @@ -95,12 +95,12 @@ "EPERM", "EPIPE", "epresents", - "Equivelant", "equivelant", + "Equivelant", "EROFS", - "ERRNO", - "Errno", "errno", + "Errno", + "ERRNO", "ESPIPE", "ETIMEDOUT", "ETXTBSY", @@ -115,25 +115,25 @@ "FBIG", "fcntl", "fdatasync", - "FDFLAGS", - "Fdflags", "fdflags", - "FDSTAT", - "Fdstat", + "Fdflags", + "FDFLAGS", "fdstat", + "Fdstat", + "FDSTAT", "Filedelta", - "Filesize", "filesize", - "FILESTAT", - "Filestat", + "Filesize", "filestat", + "Filestat", + "FILESTAT", "filesystems", "flowinfo", "freelist", "fstat", "fstatat", - "FSTFLAGS", "Fstflags", + "FSTFLAGS", "ftruncate", "futimens", "getaddrinfo", @@ -147,14 +147,14 @@ "INADDR", "inducating", "integrety", - "INVAL", "inval", + "INVAL", "Iovec", "iovs", "ipfs", "IPPROTO", - "ISDIR", "isdir", + "ISDIR", "KEEPCNT", "KEEPIDLE", "KEEPINTVL", @@ -162,15 +162,15 @@ "libfoo", "libwasm", "linkat", - "LOOKUPFLAGS", - "Lookupflags", "lookupflags", + "Lookupflags", + "LOOKUPFLAGS", "lseek", "mkdirat", "MLINK", "MSGSIZE", - "MTIM", "mtim", + "MTIM", "NAMETOOLONG", "namlen", "nbytes", @@ -190,8 +190,8 @@ "NOSPC", "nostack", "NOTDIR", - "NOTEMPTY", "notempty", + "NOTEMPTY", "NOTRECOVERABLE", "NOTSUP", "NOTTY", @@ -200,25 +200,25 @@ "nwritten", "NXIO", "occured", - "OFLAGS", - "Oflags", "oflags", + "Oflags", + "OFLAGS", "oneoff", "openat", "outparam", - "Pollable", "pollable", - "Pollables", + "Pollable", "pollables", + "Pollables", "pread", "preadv", - "Preopen", "preopen", - "Preopened", + "Preopen", "preopened", + "Preopened", "preopens", - "Prestat", "prestat", + "Prestat", "propogate", "Punct", "pwrite", @@ -226,8 +226,8 @@ "rcode", "RCVBUF", "RDWR", - "READDIR", "readdir", + "READDIR", "readlinkat", "readv", "reaedy", @@ -256,13 +256,13 @@ "sunfishcode", "symlinkat", "syms", - "SYMTAB", "symtab", + "SYMTAB", "systimespec", "transfered", "TXTBSY", - "Uninit", "uninit", + "Uninit", "unlinkat", "unrepresentable", "unroutable", @@ -273,6 +273,7 @@ "utimensat", "Vecs", "vtables", + "wasi", "wasmtime", "wasmtime's", "WILLNEED", @@ -281,4 +282,4 @@ "XDEV", "zstack" ] -} \ No newline at end of file +}