diff --git a/crates/compose/deny-all/src/bindings.rs b/crates/compose/deny-all/src/bindings.rs index ad3b2ebbc4..e8fc41397e 100644 --- a/crates/compose/deny-all/src/bindings.rs +++ b/crates/compose/deny-all/src/bindings.rs @@ -1,5 +1,3 @@ -// Generated by `wit-bindgen` 0.25.0. DO NOT EDIT! -// Options used: #[allow(dead_code)] pub mod wasi { #[allow(dead_code)] @@ -8,9 +6,7 @@ pub mod wasi { pub mod wall_clock { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; #[repr(C)] #[derive(Clone, Copy)] pub struct Datetime { @@ -18,7 +14,10 @@ pub mod wasi { pub nanoseconds: u32, } impl ::core::fmt::Debug for Datetime { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("Datetime") .field("seconds", &self.seconds) .field("nanoseconds", &self.nanoseconds) @@ -38,7 +37,6 @@ pub mod wasi { #[link_name = "now"] fn wit_import(_: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: *mut u8) { unreachable!() @@ -65,7 +63,6 @@ pub mod wasi { #[link_name = "resolution"] fn wit_import(_: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: *mut u8) { unreachable!() @@ -80,14 +77,11 @@ pub mod wasi { } } } - #[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; + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; use super::super::super::_rt; pub type Pollable = super::super::super::wasi::io0_2_0::poll::Pollable; pub type Instant = u64; @@ -101,7 +95,6 @@ pub mod wasi { #[link_name = "now"] fn wit_import() -> i64; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import() -> i64 { unreachable!() @@ -119,7 +112,6 @@ pub mod wasi { #[link_name = "resolution"] fn wit_import() -> i64; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import() -> i64 { unreachable!() @@ -137,13 +129,14 @@ pub mod wasi { #[link_name = "subscribe-instant"] fn wit_import(_: i64) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i64) -> i32 { unreachable!() } let ret = wit_import(_rt::as_i64(when)); - super::super::super::wasi::io0_2_0::poll::Pollable::from_handle(ret as u32) + super::super::super::wasi::io0_2_0::poll::Pollable::from_handle( + ret as u32, + ) } } #[allow(unused_unsafe, clippy::all)] @@ -155,13 +148,14 @@ pub mod wasi { #[link_name = "subscribe-duration"] fn wit_import(_: i64) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i64) -> i32 { unreachable!() } let ret = wit_import(_rt::as_i64(when)); - super::super::super::wasi::io0_2_0::poll::Pollable::from_handle(ret as u32) + super::super::super::wasi::io0_2_0::poll::Pollable::from_handle( + ret as u32, + ) } } } @@ -172,29 +166,43 @@ pub mod wasi { pub mod types { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + 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::io0_2_0::streams::InputStream; pub type OutputStream = super::super::super::wasi::io0_2_0::streams::OutputStream; pub type Error = super::super::super::wasi::io0_2_0::streams::Error; pub type Datetime = super::super::super::wasi::clocks0_2_0::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)] + #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] 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 { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { DescriptorType::Unknown => { f.debug_tuple("DescriptorType::Unknown").finish() @@ -208,25 +216,27 @@ pub mod wasi { DescriptorType::Directory => { f.debug_tuple("DescriptorType::Directory").finish() } - DescriptorType::Fifo => f.debug_tuple("DescriptorType::Fifo").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(), + 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, @@ -236,51 +246,110 @@ pub mod wasi { 5 => DescriptorType::SymbolicLink, 6 => DescriptorType::RegularFile, 7 => DescriptorType::Socket, - _ => panic!("invalid enum discriminant"), } } } - wit_bindgen_rt::bitflags::bitflags! { - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] - pub struct DescriptorFlags: u8 { - const READ = 1 << 0; - const WRITE = 1 << 1; - const FILE_INTEGRITY_SYNC = 1 << 2; - const DATA_INTEGRITY_SYNC = 1 << 3; - const REQUESTED_WRITE_SYNC = 1 << 4; - const MUTATE_DIRECTORY = 1 << 5; - } + #[doc = " Descriptor flags."] #[doc = ""] #[doc = + " Note: This was called `fdflags` in earlier versions of WASI."] + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] pub + struct DescriptorFlags : u8 { #[doc = " Read mode: Data can be read."] + const READ = 1 << 0; #[doc = " Write mode: Data can be written to."] + const WRITE = 1 << 1; #[doc = + " Request that writes be performed according to synchronized I/O file"] + #[doc = + " integrity completion. The data stored in the file and the file's"] + #[doc = + " metadata are synchronized. This is similar to `O_SYNC` in POSIX."] + #[doc = ""] #[doc = + " The precise semantics of this operation have not yet been defined for"] + #[doc = + " WASI. At this time, it should be interpreted as a request, and not a"] + #[doc = " requirement."] const FILE_INTEGRITY_SYNC = 1 << 2; #[doc = + " Request that writes be performed according to synchronized I/O data"] + #[doc = " integrity completion. Only the data stored in the file is"] + #[doc = " synchronized. This is similar to `O_DSYNC` in POSIX."] #[doc = + ""] #[doc = + " The precise semantics of this operation have not yet been defined for"] + #[doc = + " WASI. At this time, it should be interpreted as a request, and not a"] + #[doc = " requirement."] const DATA_INTEGRITY_SYNC = 1 << 3; #[doc = + " Requests that reads be performed at the same level of integrety"] #[doc + = " requested for writes. This is similar to `O_RSYNC` in POSIX."] #[doc + = ""] #[doc = + " The precise semantics of this operation have not yet been defined for"] + #[doc = + " WASI. At this time, it should be interpreted as a request, and not a"] + #[doc = " requirement."] const REQUESTED_WRITE_SYNC = 1 << 4; #[doc = + " Mutating directories mode: Directory contents may be mutated."] #[doc = + ""] #[doc = + " When this flag is unset on a descriptor, operations using the"] #[doc = + " descriptor which would create, rename, delete, modify the data or"] + #[doc = + " metadata of filesystem objects, or obtain another handle which"] #[doc + = + " would permit any of those, shall fail with `error-code::read-only` if"] + #[doc = " they would otherwise succeed."] #[doc = ""] #[doc = + " This may only be set on directories."] const MUTATE_DIRECTORY = 1 << 5; + } } wit_bindgen_rt::bitflags::bitflags! { - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] - pub struct PathFlags: u8 { - const SYMLINK_FOLLOW = 1 << 0; - } + #[doc = " Flags determining the method of how paths are resolved."] + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] pub + struct PathFlags : u8 { #[doc = + " As long as the resolved path corresponds to a symbolic link, it is"] + #[doc = " expanded."] const SYMLINK_FOLLOW = 1 << 0; } } wit_bindgen_rt::bitflags::bitflags! { - #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] - pub struct OpenFlags: u8 { - const CREATE = 1 << 0; - const DIRECTORY = 1 << 1; - const EXCLUSIVE = 1 << 2; - const TRUNCATE = 1 << 3; - } + #[doc = " Open flags used by `open-at`."] #[derive(PartialEq, Eq, + PartialOrd, Ord, Hash, Debug, Clone, Copy)] pub struct OpenFlags : u8 { + #[doc = + " Create file if it does not exist, similar to `O_CREAT` in POSIX."] + const CREATE = 1 << 0; #[doc = + " Fail if not a directory, similar to `O_DIRECTORY` in POSIX."] const + DIRECTORY = 1 << 1; #[doc = + " Fail if file already exists, similar to `O_EXCL` in POSIX."] const + EXCLUSIVE = 1 << 2; #[doc = + " 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 { + 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) @@ -294,16 +363,26 @@ pub mod wasi { .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 { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { - NewTimestamp::NoChange => f.debug_tuple("NewTimestamp::NoChange").finish(), + 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() @@ -311,58 +390,105 @@ pub mod wasi { } } } + /// 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 { + 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)] + #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] 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 { @@ -409,48 +535,119 @@ pub mod wasi { } pub fn message(&self) -> &'static str { match self { - ErrorCode::Access => "", - ErrorCode::WouldBlock => "", - ErrorCode::Already => "", - ErrorCode::BadDescriptor => "", - ErrorCode::Busy => "", - ErrorCode::Deadlock => "", - ErrorCode::Quota => "", - ErrorCode::Exist => "", - ErrorCode::FileTooLarge => "", - ErrorCode::IllegalByteSequence => "", - ErrorCode::InProgress => "", - ErrorCode::Interrupted => "", - ErrorCode::Invalid => "", - ErrorCode::Io => "", - ErrorCode::IsDirectory => "", - ErrorCode::Loop => "", - ErrorCode::TooManyLinks => "", - ErrorCode::MessageSize => "", - ErrorCode::NameTooLong => "", - ErrorCode::NoDevice => "", - ErrorCode::NoEntry => "", - ErrorCode::NoLock => "", - ErrorCode::InsufficientMemory => "", - ErrorCode::InsufficientSpace => "", - ErrorCode::NotDirectory => "", - ErrorCode::NotEmpty => "", - ErrorCode::NotRecoverable => "", - ErrorCode::Unsupported => "", - ErrorCode::NoTty => "", - ErrorCode::NoSuchDevice => "", - ErrorCode::Overflow => "", - ErrorCode::NotPermitted => "", - ErrorCode::Pipe => "", - ErrorCode::ReadOnly => "", - ErrorCode::InvalidSeek => "", - ErrorCode::TextFileBusy => "", - ErrorCode::CrossDevice => "", + 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 { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("ErrorCode") .field("code", &(*self as i32)) .field("name", &self.name()) @@ -459,20 +656,20 @@ pub mod wasi { } } 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) + 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, @@ -511,27 +708,43 @@ pub mod wasi { 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)] + #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] 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 { + 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::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(), @@ -539,14 +752,12 @@ pub mod wasi { } } } - 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, @@ -554,33 +765,39 @@ pub mod wasi { 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 { + 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 { @@ -588,24 +805,20 @@ pub mod wasi { 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")] @@ -613,18 +826,16 @@ pub mod wasi { #[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 { @@ -632,24 +843,20 @@ pub mod wasi { 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")] @@ -657,19 +864,30 @@ pub mod wasi { #[link_name = "[resource-drop]directory-entry-stream"] fn drop(_: u32); } - drop(_handle); } } } - impl Descriptor { #[allow(unused_unsafe, clippy::all)] - pub fn read_via_stream(&self, offset: Filesize) -> Result { + /// 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 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")] @@ -677,7 +895,6 @@ pub mod wasi { #[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!() @@ -688,15 +905,15 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(4).cast::(); - - super::super::super::wasi::io0_2_0::streams::InputStream::from_handle(l2 as u32) + super::super::super::wasi::io0_2_0::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) @@ -708,6 +925,12 @@ pub mod wasi { } 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, @@ -715,7 +938,9 @@ pub mod wasi { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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")] @@ -723,7 +948,6 @@ pub mod wasi { #[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!() @@ -734,15 +958,15 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(4).cast::(); - - super::super::super::wasi::io0_2_0::streams::OutputStream::from_handle(l2 as u32) + super::super::super::wasi::io0_2_0::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) @@ -754,11 +978,19 @@ pub mod wasi { } 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 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")] @@ -766,7 +998,6 @@ pub mod wasi { #[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!() @@ -777,15 +1008,15 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(4).cast::(); - - super::super::super::wasi::io0_2_0::streams::OutputStream::from_handle(l2 as u32) + super::super::super::wasi::io0_2_0::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) @@ -797,6 +1028,9 @@ pub mod wasi { } 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, @@ -806,7 +1040,9 @@ pub mod wasi { unsafe { #[repr(align(1))] struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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")] @@ -814,7 +1050,6 @@ pub mod wasi { #[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!() @@ -835,7 +1070,6 @@ pub mod wasi { 1 => { let e = { let l2 = i32::from(*ptr0.add(1).cast::()); - ErrorCode::_lift(l2 as u8) }; Err(e) @@ -847,11 +1081,19 @@ pub mod wasi { } 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 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")] @@ -859,7 +1101,6 @@ pub mod wasi { #[link_name = "[method]descriptor.sync-data"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -874,7 +1115,6 @@ pub mod wasi { 1 => { let e = { let l2 = i32::from(*ptr0.add(1).cast::()); - ErrorCode::_lift(l2 as u8) }; Err(e) @@ -886,11 +1126,19 @@ pub mod wasi { } 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 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")] @@ -898,7 +1146,6 @@ pub mod wasi { #[link_name = "[method]descriptor.get-flags"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -909,7 +1156,6 @@ pub mod wasi { 0 => { let e = { let l2 = i32::from(*ptr0.add(1).cast::()); - DescriptorFlags::empty() | DescriptorFlags::from_bits_retain(((l2 as u8) << 0) as _) }; @@ -918,7 +1164,6 @@ pub mod wasi { 1 => { let e = { let l3 = i32::from(*ptr0.add(1).cast::()); - ErrorCode::_lift(l3 as u8) }; Err(e) @@ -930,11 +1175,23 @@ pub mod wasi { } 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 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")] @@ -942,7 +1199,6 @@ pub mod wasi { #[link_name = "[method]descriptor.get-type"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -953,7 +1209,6 @@ pub mod wasi { 0 => { let e = { let l2 = i32::from(*ptr0.add(1).cast::()); - DescriptorType::_lift(l2 as u8) }; Ok(e) @@ -961,7 +1216,6 @@ pub mod wasi { 1 => { let e = { let l3 = i32::from(*ptr0.add(1).cast::()); - ErrorCode::_lift(l3 as u8) }; Err(e) @@ -973,11 +1227,17 @@ pub mod wasi { } 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 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")] @@ -985,7 +1245,6 @@ pub mod wasi { #[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!() @@ -1000,7 +1259,6 @@ pub mod wasi { 1 => { let e = { let l2 = i32::from(*ptr0.add(1).cast::()); - ErrorCode::_lift(l2 as u8) }; Err(e) @@ -1012,6 +1270,11 @@ pub mod wasi { } 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, @@ -1020,7 +1283,9 @@ pub mod wasi { unsafe { #[repr(align(1))] struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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), @@ -1029,7 +1294,6 @@ pub mod wasi { seconds: seconds0, nanoseconds: nanoseconds0, } = e; - (2i32, _rt::as_i64(seconds0), _rt::as_i32(nanoseconds0)) } }; @@ -1041,7 +1305,6 @@ pub mod wasi { seconds: seconds2, nanoseconds: nanoseconds2, } = e; - (2i32, _rt::as_i64(seconds2), _rt::as_i32(nanoseconds2)) } }; @@ -1061,7 +1324,6 @@ pub mod wasi { _: *mut u8, ); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import( _: i32, @@ -1094,7 +1356,6 @@ pub mod wasi { 1 => { let e = { let l6 = i32::from(*ptr4.add(1).cast::()); - ErrorCode::_lift(l6 as u8) }; Err(e) @@ -1106,6 +1367,17 @@ pub mod wasi { } 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, @@ -1114,7 +1386,9 @@ pub mod wasi { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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")] @@ -1122,7 +1396,6 @@ pub mod wasi { #[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!() @@ -1141,7 +1414,6 @@ pub mod wasi { 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), @@ -1152,7 +1424,6 @@ pub mod wasi { 1 => { let e = { let l6 = i32::from(*ptr0.add(4).cast::()); - ErrorCode::_lift(l6 as u8) }; Err(e) @@ -1164,6 +1435,15 @@ pub mod wasi { } 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], @@ -1172,7 +1452,9 @@ pub mod wasi { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 16], + ); let vec0 = buffer; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); @@ -1181,9 +1463,14 @@ pub mod wasi { #[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); + 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!() @@ -1200,7 +1487,6 @@ pub mod wasi { 0 => { let e = { let l3 = *ptr1.add(8).cast::(); - l3 as u64 }; Ok(e) @@ -1208,7 +1494,6 @@ pub mod wasi { 1 => { let e = { let l4 = i32::from(*ptr1.add(8).cast::()); - ErrorCode::_lift(l4 as u8) }; Err(e) @@ -1220,11 +1505,22 @@ pub mod wasi { } 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 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")] @@ -1232,7 +1528,6 @@ pub mod wasi { #[link_name = "[method]descriptor.read-directory"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -1243,7 +1538,6 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(4).cast::(); - DirectoryEntryStream::from_handle(l2 as u32) }; Ok(e) @@ -1251,7 +1545,6 @@ pub mod wasi { 1 => { let e = { let l3 = i32::from(*ptr0.add(4).cast::()); - ErrorCode::_lift(l3 as u8) }; Err(e) @@ -1263,11 +1556,19 @@ pub mod wasi { } 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 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")] @@ -1275,7 +1576,6 @@ pub mod wasi { #[link_name = "[method]descriptor.sync"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -1290,7 +1590,6 @@ pub mod wasi { 1 => { let e = { let l2 = i32::from(*ptr0.add(1).cast::()); - ErrorCode::_lift(l2 as u8) }; Err(e) @@ -1302,11 +1601,16 @@ pub mod wasi { } 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 mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 2], + ); let vec0 = path; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); @@ -1317,7 +1621,6 @@ pub mod wasi { #[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!() @@ -1332,7 +1635,6 @@ pub mod wasi { 1 => { let e = { let l3 = i32::from(*ptr1.add(1).cast::()); - ErrorCode::_lift(l3 as u8) }; Err(e) @@ -1344,11 +1646,22 @@ pub mod wasi { } 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 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")] @@ -1356,7 +1669,6 @@ pub mod wasi { #[link_name = "[method]descriptor.stat"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -1372,7 +1684,6 @@ pub mod wasi { 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, @@ -1383,11 +1694,10 @@ pub mod wasi { let e = { let l6 = *ptr0.add(40).cast::(); let l7 = *ptr0.add(48).cast::(); - - super::super::super::wasi::clocks0_2_0::wall_clock::Datetime{ - seconds: l6 as u64, - nanoseconds: l7 as u32, - } + super::super::super::wasi::clocks0_2_0::wall_clock::Datetime { + seconds: l6 as u64, + nanoseconds: l7 as u32, + } }; Some(e) } @@ -1399,11 +1709,10 @@ pub mod wasi { let e = { let l9 = *ptr0.add(64).cast::(); let l10 = *ptr0.add(72).cast::(); - - super::super::super::wasi::clocks0_2_0::wall_clock::Datetime{ - seconds: l9 as u64, - nanoseconds: l10 as u32, - } + super::super::super::wasi::clocks0_2_0::wall_clock::Datetime { + seconds: l9 as u64, + nanoseconds: l10 as u32, + } }; Some(e) } @@ -1415,11 +1724,10 @@ pub mod wasi { let e = { let l12 = *ptr0.add(88).cast::(); let l13 = *ptr0.add(96).cast::(); - - super::super::super::wasi::clocks0_2_0::wall_clock::Datetime{ - seconds: l12 as u64, - nanoseconds: l13 as u32, - } + super::super::super::wasi::clocks0_2_0::wall_clock::Datetime { + seconds: l12 as u64, + nanoseconds: l13 as u32, + } }; Some(e) } @@ -1432,7 +1740,6 @@ pub mod wasi { 1 => { let e = { let l14 = i32::from(*ptr0.add(8).cast::()); - ErrorCode::_lift(l14 as u8) }; Err(e) @@ -1444,6 +1751,13 @@ pub mod wasi { } 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, @@ -1452,7 +1766,9 @@ pub mod wasi { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit; 104]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 104]); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 104], + ); let flags0 = path_flags; let vec1 = path; let ptr1 = vec1.as_ptr().cast::(); @@ -1462,9 +1778,14 @@ pub mod wasi { #[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); + 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!() @@ -1486,7 +1807,6 @@ pub mod wasi { 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, @@ -1497,11 +1817,10 @@ pub mod wasi { let e = { let l8 = *ptr2.add(40).cast::(); let l9 = *ptr2.add(48).cast::(); - - super::super::super::wasi::clocks0_2_0::wall_clock::Datetime{ - seconds: l8 as u64, - nanoseconds: l9 as u32, - } + super::super::super::wasi::clocks0_2_0::wall_clock::Datetime { + seconds: l8 as u64, + nanoseconds: l9 as u32, + } }; Some(e) } @@ -1513,11 +1832,10 @@ pub mod wasi { let e = { let l11 = *ptr2.add(64).cast::(); let l12 = *ptr2.add(72).cast::(); - - super::super::super::wasi::clocks0_2_0::wall_clock::Datetime{ - seconds: l11 as u64, - nanoseconds: l12 as u32, - } + super::super::super::wasi::clocks0_2_0::wall_clock::Datetime { + seconds: l11 as u64, + nanoseconds: l12 as u32, + } }; Some(e) } @@ -1529,11 +1847,10 @@ pub mod wasi { let e = { let l14 = *ptr2.add(88).cast::(); let l15 = *ptr2.add(96).cast::(); - - super::super::super::wasi::clocks0_2_0::wall_clock::Datetime{ - seconds: l14 as u64, - nanoseconds: l15 as u32, - } + super::super::super::wasi::clocks0_2_0::wall_clock::Datetime { + seconds: l14 as u64, + nanoseconds: l15 as u32, + } }; Some(e) } @@ -1546,7 +1863,6 @@ pub mod wasi { 1 => { let e = { let l16 = i32::from(*ptr2.add(8).cast::()); - ErrorCode::_lift(l16 as u8) }; Err(e) @@ -1558,6 +1874,12 @@ pub mod wasi { } 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, @@ -1568,7 +1890,9 @@ pub mod wasi { unsafe { #[repr(align(1))] struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 2], + ); let flags0 = path_flags; let vec1 = path; let ptr1 = vec1.as_ptr().cast::(); @@ -1581,7 +1905,6 @@ pub mod wasi { seconds: seconds2, nanoseconds: nanoseconds2, } = e; - (2i32, _rt::as_i64(seconds2), _rt::as_i32(nanoseconds2)) } }; @@ -1593,7 +1916,6 @@ pub mod wasi { seconds: seconds4, nanoseconds: nanoseconds4, } = e; - (2i32, _rt::as_i64(seconds4), _rt::as_i32(nanoseconds4)) } }; @@ -1616,7 +1938,6 @@ pub mod wasi { _: *mut u8, ); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import( _: i32, @@ -1655,7 +1976,6 @@ pub mod wasi { 1 => { let e = { let l8 = i32::from(*ptr6.add(1).cast::()); - ErrorCode::_lift(l8 as u8) }; Err(e) @@ -1667,6 +1987,9 @@ pub mod wasi { } 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, @@ -1677,7 +2000,9 @@ pub mod wasi { unsafe { #[repr(align(1))] struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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::(); @@ -1701,7 +2026,6 @@ pub mod wasi { _: *mut u8, ); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import( _: i32, @@ -1734,7 +2058,6 @@ pub mod wasi { 1 => { let e = { let l5 = i32::from(*ptr3.add(1).cast::()); - ErrorCode::_lift(l5 as u8) }; Err(e) @@ -1746,6 +2069,24 @@ pub mod wasi { } 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, @@ -1756,7 +2097,9 @@ pub mod wasi { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit; 8]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 8], + ); let flags0 = path_flags; let vec1 = path; let ptr1 = vec1.as_ptr().cast::(); @@ -1778,7 +2121,6 @@ pub mod wasi { _: *mut u8, ); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import( _: i32, @@ -1805,7 +2147,6 @@ pub mod wasi { 0 => { let e = { let l6 = *ptr4.add(4).cast::(); - Descriptor::from_handle(l6 as u32) }; Ok(e) @@ -1813,7 +2154,6 @@ pub mod wasi { 1 => { let e = { let l7 = i32::from(*ptr4.add(4).cast::()); - ErrorCode::_lift(l7 as u8) }; Err(e) @@ -1825,11 +2165,19 @@ pub mod wasi { } 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 mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 12], + ); let vec0 = path; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); @@ -1840,7 +2188,6 @@ pub mod wasi { #[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!() @@ -1853,8 +2200,11 @@ pub mod wasi { let l3 = *ptr1.add(4).cast::<*mut u8>(); let l4 = *ptr1.add(8).cast::(); let len5 = l4; - let bytes5 = _rt::Vec::from_raw_parts(l3.cast(), len5, len5); - + let bytes5 = _rt::Vec::from_raw_parts( + l3.cast(), + len5, + len5, + ); _rt::string_lift(bytes5) }; Ok(e) @@ -1862,7 +2212,6 @@ pub mod wasi { 1 => { let e = { let l6 = i32::from(*ptr1.add(4).cast::()); - ErrorCode::_lift(l6 as u8) }; Err(e) @@ -1874,11 +2223,18 @@ pub mod wasi { } 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 mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 2], + ); let vec0 = path; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); @@ -1889,7 +2245,6 @@ pub mod wasi { #[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!() @@ -1904,7 +2259,6 @@ pub mod wasi { 1 => { let e = { let l3 = i32::from(*ptr1.add(1).cast::()); - ErrorCode::_lift(l3 as u8) }; Err(e) @@ -1916,6 +2270,9 @@ pub mod wasi { } 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, @@ -1925,7 +2282,9 @@ pub mod wasi { unsafe { #[repr(align(1))] struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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(); @@ -1947,7 +2306,6 @@ pub mod wasi { _: *mut u8, ); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import( _: i32, @@ -1978,7 +2336,6 @@ pub mod wasi { 1 => { let e = { let l4 = i32::from(*ptr2.add(1).cast::()); - ErrorCode::_lift(l4 as u8) }; Err(e) @@ -1990,11 +2347,23 @@ pub mod wasi { } impl Descriptor { #[allow(unused_unsafe, clippy::all)] - pub fn symlink_at(&self, old_path: &str, new_path: &str) -> Result<(), ErrorCode> { + /// 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 mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 2], + ); let vec0 = old_path; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); @@ -2015,7 +2384,6 @@ pub mod wasi { _: *mut u8, ); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import( _: i32, @@ -2044,7 +2412,6 @@ pub mod wasi { 1 => { let e = { let l4 = i32::from(*ptr2.add(1).cast::()); - ErrorCode::_lift(l4 as u8) }; Err(e) @@ -2056,11 +2423,17 @@ pub mod wasi { } 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 mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 2], + ); let vec0 = path; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); @@ -2071,7 +2444,6 @@ pub mod wasi { #[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!() @@ -2086,7 +2458,6 @@ pub mod wasi { 1 => { let e = { let l3 = i32::from(*ptr1.add(1).cast::()); - ErrorCode::_lift(l3 as u8) }; Err(e) @@ -2098,6 +2469,12 @@ pub mod wasi { } 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")] @@ -2106,23 +2483,46 @@ pub mod wasi { #[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); + 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 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")] @@ -2130,7 +2530,6 @@ pub mod wasi { #[link_name = "[method]descriptor.metadata-hash"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -2142,7 +2541,6 @@ pub mod wasi { let e = { let l2 = *ptr0.add(8).cast::(); let l3 = *ptr0.add(16).cast::(); - MetadataHashValue { lower: l2 as u64, upper: l3 as u64, @@ -2153,7 +2551,6 @@ pub mod wasi { 1 => { let e = { let l4 = i32::from(*ptr0.add(8).cast::()); - ErrorCode::_lift(l4 as u8) }; Err(e) @@ -2165,6 +2562,10 @@ pub mod wasi { } 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, @@ -2173,7 +2574,9 @@ pub mod wasi { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit; 24]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 24]); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 24], + ); let flags0 = path_flags; let vec1 = path; let ptr1 = vec1.as_ptr().cast::(); @@ -2183,9 +2586,14 @@ pub mod wasi { #[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); + 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!() @@ -2203,7 +2611,6 @@ pub mod wasi { let e = { let l4 = *ptr2.add(8).cast::(); let l5 = *ptr2.add(16).cast::(); - MetadataHashValue { lower: l4 as u64, upper: l5 as u64, @@ -2214,7 +2621,6 @@ pub mod wasi { 1 => { let e = { let l6 = i32::from(*ptr2.add(8).cast::()); - ErrorCode::_lift(l6 as u8) }; Err(e) @@ -2226,11 +2632,16 @@ pub mod wasi { } impl DirectoryEntryStream { #[allow(unused_unsafe, clippy::all)] - pub fn read_directory_entry(&self) -> Result, ErrorCode> { + /// 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 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")] @@ -2238,7 +2649,6 @@ pub mod wasi { #[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!() @@ -2249,7 +2659,6 @@ pub mod wasi { 0 => { let e = { let l2 = i32::from(*ptr0.add(4).cast::()); - match l2 { 0 => None, 1 => { @@ -2258,9 +2667,11 @@ pub mod wasi { 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); - + let bytes6 = _rt::Vec::from_raw_parts( + l4.cast(), + len6, + len6, + ); DirectoryEntry { type_: DescriptorType::_lift(l3 as u8), name: _rt::string_lift(bytes6), @@ -2276,7 +2687,6 @@ pub mod wasi { 1 => { let e = { let l7 = i32::from(*ptr0.add(4).cast::()); - ErrorCode::_lift(l7 as u8) }; Err(e) @@ -2287,6 +2697,16 @@ pub mod wasi { } } #[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))] @@ -2299,7 +2719,6 @@ pub mod wasi { #[link_name = "filesystem-error-code"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -2311,7 +2730,6 @@ pub mod wasi { 1 => { let e = { let l2 = i32::from(*ptr0.add(1).cast::()); - ErrorCode::_lift(l2 as u8) }; Some(e) @@ -2328,15 +2746,14 @@ pub mod wasi { pub mod types { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + 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::clocks0_2_0::monotonic_clock::Duration; pub type InputStream = super::super::super::wasi::io0_2_0::streams::InputStream; pub type OutputStream = super::super::super::wasi::io0_2_0::streams::OutputStream; pub type IoError = super::super::super::wasi::io0_2_0::error::Error; pub type Pollable = super::super::super::wasi::io0_2_0::poll::Pollable; + /// This type corresponds to HTTP standard Methods. #[derive(Clone)] pub enum Method { Get, @@ -2351,7 +2768,10 @@ pub mod wasi { Other(_rt::String), } impl ::core::fmt::Debug for Method { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + 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(), @@ -2362,10 +2782,13 @@ pub mod wasi { 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(), + 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, @@ -2373,53 +2796,72 @@ pub mod wasi { Other(_rt::String), } impl ::core::fmt::Debug for Scheme { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + 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(), + 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 { + 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 { + 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 { + 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, @@ -2460,12 +2902,22 @@ pub mod wasi { 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 { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { - ErrorCode::DnsTimeout => f.debug_tuple("ErrorCode::DnsTimeout").finish(), + ErrorCode::DnsTimeout => { + f.debug_tuple("ErrorCode::DnsTimeout").finish() + } ErrorCode::DnsError(e) => { f.debug_tuple("ErrorCode::DnsError").field(e).finish() } @@ -2505,80 +2957,94 @@ pub mod wasi { ErrorCode::TlsCertificateError => { f.debug_tuple("ErrorCode::TlsCertificateError").finish() } - ErrorCode::TlsAlertReceived(e) => f - .debug_tuple("ErrorCode::TlsAlertReceived") - .field(e) - .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::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::HttpRequestHeaderSectionSize(e) => { + f.debug_tuple("ErrorCode::HttpRequestHeaderSectionSize") + .field(e) + .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::HttpRequestHeaderSize(e) => { + f.debug_tuple("ErrorCode::HttpRequestHeaderSize") + .field(e) + .finish() } - ErrorCode::HttpUpgradeFailed => { + 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 => { @@ -2597,45 +3063,77 @@ pub mod wasi { } } impl ::core::fmt::Display for ErrorCode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + 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 { + 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(), + 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 { + 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 { @@ -2643,24 +3141,20 @@ pub mod wasi { 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")] @@ -2668,21 +3162,20 @@ pub mod wasi { #[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 { @@ -2690,24 +3183,20 @@ pub mod wasi { 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")] @@ -2715,18 +3204,16 @@ pub mod wasi { #[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 { @@ -2734,24 +3221,20 @@ pub mod wasi { 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")] @@ -2759,18 +3242,21 @@ pub mod wasi { #[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 { @@ -2778,24 +3264,20 @@ pub mod wasi { 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")] @@ -2803,18 +3285,20 @@ pub mod wasi { #[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 { @@ -2822,24 +3306,20 @@ pub mod wasi { 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")] @@ -2847,20 +3327,18 @@ pub mod wasi { #[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 { @@ -2868,24 +3346,20 @@ pub mod wasi { 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")] @@ -2893,18 +3367,23 @@ pub mod wasi { #[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 { @@ -2912,24 +3391,20 @@ pub mod wasi { 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")] @@ -2937,18 +3412,20 @@ pub mod wasi { #[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 { @@ -2956,24 +3433,20 @@ pub mod wasi { 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")] @@ -2981,18 +3454,16 @@ pub mod wasi { #[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 { @@ -3000,24 +3471,20 @@ pub mod wasi { 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")] @@ -3025,18 +3492,31 @@ pub mod wasi { #[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 { @@ -3044,24 +3524,20 @@ pub mod wasi { 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")] @@ -3069,18 +3545,20 @@ pub mod wasi { #[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 { @@ -3088,24 +3566,20 @@ pub mod wasi { 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")] @@ -3113,14 +3587,15 @@ pub mod wasi { #[link_name = "[resource-drop]future-incoming-response"] fn drop(_: u32); } - drop(_handle); } } } - 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")] @@ -3129,7 +3604,6 @@ pub mod wasi { #[link_name = "[constructor]fields"] fn wit_import() -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import() -> i32 { unreachable!() @@ -3141,17 +3615,34 @@ pub mod wasi { } 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. + /// + /// An error result will be returned if any `field-key` or `field-value` is + /// syntactically invalid, or if a field is 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 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 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() { @@ -3159,9 +3650,7 @@ pub mod wasi { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec3.into_iter().enumerate() { let base = result3.add(i * 16); @@ -3186,7 +3675,6 @@ pub mod wasi { #[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!() @@ -3200,7 +3688,6 @@ pub mod wasi { 0 => { let e = { let l6 = *ptr4.add(4).cast::(); - Fields::from_handle(l6 as u32) }; Ok(e) @@ -3216,7 +3703,6 @@ pub mod wasi { HeaderError::Immutable } }; - v8 }; Err(e) @@ -3228,11 +3714,17 @@ pub mod wasi { } 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` or is syntactically invalid, 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 mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 8], + ); let vec0 = name; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); @@ -3243,7 +3735,6 @@ pub mod wasi { #[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!() @@ -3260,7 +3751,6 @@ pub mod wasi { 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); @@ -3272,30 +3762,41 @@ pub mod wasi { } 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); + 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. + /// + /// Fails with `header-error.invalid-syntax` if the `field-key` or any of + /// the `field-value`s are syntactically invalid. pub fn set( &self, name: &FieldKey, @@ -3304,14 +3805,18 @@ pub mod wasi { unsafe { #[repr(align(1))] struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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 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() { @@ -3319,9 +3824,7 @@ pub mod wasi { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec2.into_iter().enumerate() { let base = result2.add(i * 8); @@ -3347,7 +3850,6 @@ pub mod wasi { _: *mut u8, ); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import( _: i32, @@ -3387,7 +3889,6 @@ pub mod wasi { HeaderError::Immutable } }; - v6 }; Err(e) @@ -3399,11 +3900,20 @@ pub mod wasi { } 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. + /// + /// Fails with `header-error.invalid-syntax` if the `field-key` is + /// syntactically invalid. 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 mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 2], + ); let vec0 = name; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); @@ -3414,7 +3924,6 @@ pub mod wasi { #[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!() @@ -3437,7 +3946,6 @@ pub mod wasi { HeaderError::Immutable } }; - v4 }; Err(e) @@ -3449,6 +3957,13 @@ pub mod wasi { } 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. + /// + /// Fails with `header-error.invalid-syntax` if the `field-key` or + /// `field-value` are syntactically invalid. pub fn append( &self, name: &FieldKey, @@ -3457,7 +3972,9 @@ pub mod wasi { unsafe { #[repr(align(1))] struct RetArea([::core::mem::MaybeUninit; 2]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 2], + ); let vec0 = name; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); @@ -3478,7 +3995,6 @@ pub mod wasi { _: *mut u8, ); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import( _: i32, @@ -3515,7 +4031,6 @@ pub mod wasi { HeaderError::Immutable } }; - v5 }; Err(e) @@ -3527,11 +4042,19 @@ pub mod wasi { } 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 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")] @@ -3539,7 +4062,6 @@ pub mod wasi { #[link_name = "[method]fields.entries"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -3556,11 +4078,14 @@ pub mod wasi { 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 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), @@ -3575,6 +4100,9 @@ pub mod wasi { } 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")] @@ -3583,7 +4111,6 @@ pub mod wasi { #[link_name = "[method]fields.clone"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() @@ -3595,11 +4122,14 @@ pub mod wasi { } 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 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")] @@ -3607,7 +4137,6 @@ pub mod wasi { #[link_name = "[method]incoming-request.method"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -3630,8 +4159,11 @@ pub mod wasi { let l2 = *ptr0.add(4).cast::<*mut u8>(); let l3 = *ptr0.add(8).cast::(); let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - + let bytes4 = _rt::Vec::from_raw_parts( + l2.cast(), + len4, + len4, + ); _rt::string_lift(bytes4) }; Method::Other(e5) @@ -3643,11 +4175,14 @@ pub mod wasi { } 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 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")] @@ -3655,7 +4190,6 @@ pub mod wasi { #[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!() @@ -3669,8 +4203,11 @@ pub mod wasi { let l2 = *ptr0.add(4).cast::<*mut u8>(); let l3 = *ptr0.add(8).cast::(); let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - + let bytes4 = _rt::Vec::from_raw_parts( + l2.cast(), + len4, + len4, + ); _rt::string_lift(bytes4) }; Some(e) @@ -3682,11 +4219,14 @@ pub mod wasi { } 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 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")] @@ -3694,7 +4234,6 @@ pub mod wasi { #[link_name = "[method]incoming-request.scheme"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -3715,15 +4254,16 @@ pub mod wasi { 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); - + let bytes5 = _rt::Vec::from_raw_parts( + l3.cast(), + len5, + len5, + ); _rt::string_lift(bytes5) }; Scheme::Other(e6) } }; - v6 }; Some(e) @@ -3735,11 +4275,14 @@ pub mod wasi { } 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 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")] @@ -3747,7 +4290,6 @@ pub mod wasi { #[link_name = "[method]incoming-request.authority"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -3761,8 +4303,11 @@ pub mod wasi { let l2 = *ptr0.add(4).cast::<*mut u8>(); let l3 = *ptr0.add(8).cast::(); let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - + let bytes4 = _rt::Vec::from_raw_parts( + l2.cast(), + len4, + len4, + ); _rt::string_lift(bytes4) }; Some(e) @@ -3774,6 +4319,14 @@ pub mod wasi { } 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")] @@ -3782,7 +4335,6 @@ pub mod wasi { #[link_name = "[method]incoming-request.headers"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() @@ -3794,11 +4346,15 @@ pub mod wasi { } 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 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")] @@ -3806,7 +4362,6 @@ pub mod wasi { #[link_name = "[method]incoming-request.consume"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -3817,7 +4372,6 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(4).cast::(); - IncomingBody::from_handle(l2 as u32) }; Ok(e) @@ -3833,6 +4387,16 @@ pub mod wasi { } 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")] @@ -3841,7 +4405,6 @@ pub mod wasi { #[link_name = "[constructor]outgoing-request"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() @@ -3853,11 +4416,19 @@ pub mod wasi { } 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 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")] @@ -3865,7 +4436,6 @@ pub mod wasi { #[link_name = "[method]outgoing-request.body"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -3876,7 +4446,6 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(4).cast::(); - OutgoingBody::from_handle(l2 as u32) }; Ok(e) @@ -3892,11 +4461,14 @@ pub mod wasi { } 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 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")] @@ -3904,7 +4476,6 @@ pub mod wasi { #[link_name = "[method]outgoing-request.method"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -3927,8 +4498,11 @@ pub mod wasi { let l2 = *ptr0.add(4).cast::<*mut u8>(); let l3 = *ptr0.add(8).cast::(); let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - + let bytes4 = _rt::Vec::from_raw_parts( + l2.cast(), + len4, + len4, + ); _rt::string_lift(bytes4) }; Method::Other(e5) @@ -3940,6 +4514,8 @@ pub mod wasi { } 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 { @@ -3956,24 +4532,25 @@ pub mod wasi { 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); + let ret = wit_import( + (self).handle() as i32, + result1_0, + result1_1, + result1_2, + ); match ret { 0 => { let e = (); @@ -3990,11 +4567,15 @@ pub mod wasi { } 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 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")] @@ -4002,7 +4583,6 @@ pub mod wasi { #[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!() @@ -4016,8 +4596,11 @@ pub mod wasi { let l2 = *ptr0.add(4).cast::<*mut u8>(); let l3 = *ptr0.add(8).cast::(); let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - + let bytes4 = _rt::Vec::from_raw_parts( + l2.cast(), + len4, + len4, + ); _rt::string_lift(bytes4) }; Some(e) @@ -4029,14 +4612,19 @@ pub mod wasi { } impl OutgoingRequest { #[allow(unused_unsafe, clippy::all)] - pub fn set_path_with_query(&self, path_with_query: Option<&str>) -> Result<(), ()> { + /// 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), @@ -4047,13 +4635,16 @@ pub mod wasi { #[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); + let ret = wit_import( + (self).handle() as i32, + result1_0, + result1_1, + result1_2, + ); match ret { 0 => { let e = (); @@ -4070,11 +4661,15 @@ pub mod wasi { } 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 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")] @@ -4082,7 +4677,6 @@ pub mod wasi { #[link_name = "[method]outgoing-request.scheme"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -4103,15 +4697,16 @@ pub mod wasi { 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); - + let bytes5 = _rt::Vec::from_raw_parts( + l3.cast(), + len5, + len5, + ); _rt::string_lift(bytes5) }; Scheme::Other(e6) } }; - v6 }; Some(e) @@ -4123,6 +4718,9 @@ pub mod wasi { } 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 { @@ -4134,11 +4732,9 @@ pub mod wasi { 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), @@ -4147,11 +4743,22 @@ pub mod wasi { #[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; + 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 { + fn wit_import( + _: i32, + _: i32, + _: i32, + _: *mut u8, + _: usize, + ) -> i32 { unreachable!() } let ret = wit_import( @@ -4177,11 +4784,16 @@ pub mod wasi { } 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 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")] @@ -4189,7 +4801,6 @@ pub mod wasi { #[link_name = "[method]outgoing-request.authority"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -4203,8 +4814,11 @@ pub mod wasi { let l2 = *ptr0.add(4).cast::<*mut u8>(); let l3 = *ptr0.add(8).cast::(); let len4 = l3; - let bytes4 = _rt::Vec::from_raw_parts(l2.cast(), len4, len4); - + let bytes4 = _rt::Vec::from_raw_parts( + l2.cast(), + len4, + len4, + ); _rt::string_lift(bytes4) }; Some(e) @@ -4216,6 +4830,10 @@ pub mod wasi { } 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 { @@ -4223,7 +4841,6 @@ pub mod wasi { 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), @@ -4234,13 +4851,16 @@ pub mod wasi { #[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); + let ret = wit_import( + (self).handle() as i32, + result1_0, + result1_1, + result1_2, + ); match ret { 0 => { let e = (); @@ -4257,6 +4877,14 @@ pub mod wasi { } 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")] @@ -4265,7 +4893,6 @@ pub mod wasi { #[link_name = "[method]outgoing-request.headers"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() @@ -4277,6 +4904,7 @@ pub mod wasi { } impl RequestOptions { #[allow(unused_unsafe, clippy::all)] + /// Construct a default `request-options` value. pub fn new() -> Self { unsafe { #[cfg(target_arch = "wasm32")] @@ -4285,7 +4913,6 @@ pub mod wasi { #[link_name = "[constructor]request-options"] fn wit_import() -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import() -> i32 { unreachable!() @@ -4297,11 +4924,14 @@ pub mod wasi { } 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 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")] @@ -4309,7 +4939,6 @@ pub mod wasi { #[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!() @@ -4321,7 +4950,6 @@ pub mod wasi { 1 => { let e = { let l2 = *ptr0.add(8).cast::(); - l2 as u64 }; Some(e) @@ -4333,7 +4961,12 @@ pub mod wasi { } impl RequestOptions { #[allow(unused_unsafe, clippy::all)] - pub fn set_connect_timeout(&self, duration: Option) -> Result<(), ()> { + /// 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)), @@ -4345,12 +4978,15 @@ pub mod wasi { #[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); + let ret = wit_import( + (self).handle() as i32, + result0_0, + result0_1, + ); match ret { 0 => { let e = (); @@ -4367,11 +5003,14 @@ pub mod wasi { } 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 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")] @@ -4379,7 +5018,6 @@ pub mod wasi { #[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!() @@ -4391,7 +5029,6 @@ pub mod wasi { 1 => { let e = { let l2 = *ptr0.add(8).cast::(); - l2 as u64 }; Some(e) @@ -4403,7 +5040,12 @@ pub mod wasi { } impl RequestOptions { #[allow(unused_unsafe, clippy::all)] - pub fn set_first_byte_timeout(&self, duration: Option) -> Result<(), ()> { + /// 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)), @@ -4415,12 +5057,15 @@ pub mod wasi { #[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); + let ret = wit_import( + (self).handle() as i32, + result0_0, + result0_1, + ); match ret { 0 => { let e = (); @@ -4437,11 +5082,15 @@ pub mod wasi { } 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 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")] @@ -4449,7 +5098,6 @@ pub mod wasi { #[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!() @@ -4461,7 +5109,6 @@ pub mod wasi { 1 => { let e = { let l2 = *ptr0.add(8).cast::(); - l2 as u64 }; Some(e) @@ -4473,6 +5120,9 @@ pub mod wasi { } 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, @@ -4488,12 +5138,15 @@ pub mod wasi { #[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); + let ret = wit_import( + (self).handle() as i32, + result0_0, + result0_1, + ); match ret { 0 => { let e = (); @@ -4510,7 +5163,19 @@ pub mod wasi { } impl ResponseOutparam { #[allow(unused_unsafe, clippy::all)] - pub fn set(param: ResponseOutparam, response: Result) { + /// 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, @@ -4522,16 +5187,18 @@ pub mod wasi { 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, - ), + 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, @@ -4542,15 +5209,17 @@ pub mod wasi { 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::DnsTimeout => { + ( + 0i32, + 0i32, + ::core::mem::MaybeUninit::::zeroed(), + ::core::ptr::null_mut(), + ::core::ptr::null_mut(), + 0usize, + 0i32, + ) + } ErrorCode::DnsError(e) => { let DnsErrorPayload { rcode: rcode0, @@ -4561,7 +5230,6 @@ pub mod wasi { 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), @@ -4574,8 +5242,7 @@ pub mod wasi { 1i32, result2_0, { - let mut t = - ::core::mem::MaybeUninit::::uninit(); + let mut t = ::core::mem::MaybeUninit::::uninit(); t.as_mut_ptr().cast::<*mut u8>().write(result2_1); t }, @@ -4585,114 +5252,138 @@ pub mod wasi { 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::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, @@ -4702,13 +5393,11 @@ pub mod wasi { Some(e) => (1i32, _rt::as_i32(e)), None => (0i32, 0i32), }; - let (result7_0, result7_1, result7_2) = match alert_message4 - { + 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), @@ -4716,33 +5405,35 @@ pub mod wasi { ( 14i32, result5_0, - ::core::mem::MaybeUninit::new( - i64::from(result5_1) as u64 - ), + ::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::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)), @@ -4758,33 +5449,39 @@ pub mod wasi { 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::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)), @@ -4793,9 +5490,7 @@ pub mod wasi { ( 21i32, result9_0, - ::core::mem::MaybeUninit::new( - i64::from(result9_1) as u64 - ), + ::core::mem::MaybeUninit::new(i64::from(result9_1) as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, @@ -4816,43 +5511,36 @@ pub mod wasi { 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 (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, + 1i32, + result12_0, + result12_1, + result12_2, + result13_0, + result13_1, ) } - None => ( - 0i32, - 0i32, - ::core::ptr::null_mut(), - 0usize, - 0i32, - 0i32, - ), + None => { + (0i32, 0i32, ::core::ptr::null_mut(), 0usize, 0i32, 0i32) + } }; ( 22i32, result14_0, - ::core::mem::MaybeUninit::new( - i64::from(result14_1) as u64 - ), + ::core::mem::MaybeUninit::new(i64::from(result14_1) as u64), result14_2, result14_3 as *mut u8, result14_4 as usize, @@ -4867,9 +5555,7 @@ pub mod wasi { ( 23i32, result15_0, - ::core::mem::MaybeUninit::new( - i64::from(result15_1) as u64 - ), + ::core::mem::MaybeUninit::new(i64::from(result15_1) as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, @@ -4881,17 +5567,15 @@ pub mod wasi { 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 (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), @@ -4900,8 +5584,7 @@ pub mod wasi { 24i32, result18_0, { - let mut t = - ::core::mem::MaybeUninit::::uninit(); + let mut t = ::core::mem::MaybeUninit::::uninit(); t.as_mut_ptr().cast::<*mut u8>().write(result18_1); t }, @@ -4911,15 +5594,17 @@ pub mod wasi { 0i32, ) } - ErrorCode::HttpResponseIncomplete => ( - 25i32, - 0i32, - ::core::mem::MaybeUninit::::zeroed(), - ::core::ptr::null_mut(), - ::core::ptr::null_mut(), - 0usize, - 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)), @@ -4928,9 +5613,7 @@ pub mod wasi { ( 26i32, result20_0, - ::core::mem::MaybeUninit::new( - i64::from(result20_1) as u64 - ), + ::core::mem::MaybeUninit::new(i64::from(result20_1) as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, @@ -4942,17 +5625,15 @@ pub mod wasi { 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 (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), @@ -4961,8 +5642,7 @@ pub mod wasi { 27i32, result23_0, { - let mut t = - ::core::mem::MaybeUninit::::uninit(); + let mut t = ::core::mem::MaybeUninit::::uninit(); t.as_mut_ptr().cast::<*mut u8>().write(result23_1); t }, @@ -4995,9 +5675,7 @@ pub mod wasi { ( 29i32, result26_0, - ::core::mem::MaybeUninit::new( - i64::from(result26_1) as u64 - ), + ::core::mem::MaybeUninit::new(i64::from(result26_1) as u64), ::core::ptr::null_mut(), ::core::ptr::null_mut(), 0usize, @@ -5009,17 +5687,15 @@ pub mod wasi { 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 (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), @@ -5028,8 +5704,7 @@ pub mod wasi { 30i32, result29_0, { - let mut t = - ::core::mem::MaybeUninit::::uninit(); + let mut t = ::core::mem::MaybeUninit::::uninit(); t.as_mut_ptr().cast::<*mut u8>().write(result29_1); t }, @@ -5045,7 +5720,6 @@ pub mod wasi { 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), @@ -5054,8 +5728,7 @@ pub mod wasi { 31i32, result32_0, { - let mut t = - ::core::mem::MaybeUninit::::uninit(); + let mut t = ::core::mem::MaybeUninit::::uninit(); t.as_mut_ptr().cast::<*mut u8>().write(result32_1); t }, @@ -5071,7 +5744,6 @@ pub mod wasi { 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), @@ -5080,8 +5752,7 @@ pub mod wasi { 32i32, result34_0, { - let mut t = - ::core::mem::MaybeUninit::::uninit(); + let mut t = ::core::mem::MaybeUninit::::uninit(); t.as_mut_ptr().cast::<*mut u8>().write(result34_1); t }, @@ -5091,58 +5762,67 @@ pub mod wasi { 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::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), @@ -5151,8 +5831,7 @@ pub mod wasi { 38i32, result36_0, { - let mut t = - ::core::mem::MaybeUninit::::uninit(); + let mut t = ::core::mem::MaybeUninit::::uninit(); t.as_mut_ptr().cast::<*mut u8>().write(result36_1); t }, @@ -5163,10 +5842,15 @@ pub mod wasi { ) } }; - ( - 1i32, result37_0, result37_1, result37_2, result37_3, - result37_4, result37_5, result37_6, + 1i32, + result37_0, + result37_1, + result37_2, + result37_3, + result37_4, + result37_5, + result37_6, ) } }; @@ -5186,7 +5870,6 @@ pub mod wasi { _: i32, ); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import( _: i32, @@ -5217,6 +5900,7 @@ pub mod wasi { } 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")] @@ -5225,7 +5909,6 @@ pub mod wasi { #[link_name = "[method]incoming-response.status"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() @@ -5237,6 +5920,13 @@ pub mod wasi { } 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")] @@ -5245,7 +5935,6 @@ pub mod wasi { #[link_name = "[method]incoming-response.headers"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() @@ -5257,11 +5946,15 @@ pub mod wasi { } 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 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")] @@ -5269,7 +5962,6 @@ pub mod wasi { #[link_name = "[method]incoming-response.consume"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -5280,7 +5972,6 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(4).cast::(); - IncomingBody::from_handle(l2 as u32) }; Ok(e) @@ -5296,11 +5987,28 @@ pub mod wasi { } 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 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")] @@ -5308,7 +6016,6 @@ pub mod wasi { #[link_name = "[method]incoming-body.stream"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -5319,8 +6026,9 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(4).cast::(); - - super::super::super::wasi::io0_2_0::streams::InputStream::from_handle(l2 as u32) + super::super::super::wasi::io0_2_0::streams::InputStream::from_handle( + l2 as u32, + ) }; Ok(e) } @@ -5335,6 +6043,8 @@ pub mod wasi { } 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")] @@ -5343,7 +6053,6 @@ pub mod wasi { #[link_name = "[static]incoming-body.finish"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() @@ -5355,6 +6064,9 @@ pub mod wasi { } 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`. pub fn subscribe(&self) -> Pollable { unsafe { #[cfg(target_arch = "wasm32")] @@ -5363,23 +6075,47 @@ pub mod wasi { #[link_name = "[method]future-trailers.subscribe"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() } let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io0_2_0::poll::Pollable::from_handle(ret as u32) + super::super::super::wasi::io0_2_0::poll::Pollable::from_handle( + ret as u32, + ) } } } impl FutureTrailers { #[allow(unused_unsafe, clippy::all)] - pub fn get(&self) -> Option, ErrorCode>, ()>> { + /// 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 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")] @@ -5387,7 +6123,6 @@ pub mod wasi { #[link_name = "[method]future-trailers.get"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -5399,529 +6134,470 @@ pub mod wasi { 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(), - } - }; + 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 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) - } - }; - + 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) @@ -5947,6 +6623,11 @@ pub mod wasi { } 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")] @@ -5955,7 +6636,6 @@ pub mod wasi { #[link_name = "[constructor]outgoing-response"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() @@ -5967,6 +6647,7 @@ pub mod wasi { } 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")] @@ -5975,7 +6656,6 @@ pub mod wasi { #[link_name = "[method]outgoing-response.status-code"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() @@ -5987,7 +6667,12 @@ pub mod wasi { } impl OutgoingResponse { #[allow(unused_unsafe, clippy::all)] - pub fn set_status_code(&self, status_code: StatusCode) -> Result<(), ()> { + /// 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")] @@ -5995,12 +6680,14 @@ pub mod wasi { #[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)); + let ret = wit_import( + (self).handle() as i32, + _rt::as_i32(status_code), + ); match ret { 0 => { let e = (); @@ -6017,6 +6704,14 @@ pub mod wasi { } 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")] @@ -6025,7 +6720,6 @@ pub mod wasi { #[link_name = "[method]outgoing-response.headers"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() @@ -6037,11 +6731,18 @@ pub mod wasi { } 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 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")] @@ -6049,7 +6750,6 @@ pub mod wasi { #[link_name = "[method]outgoing-response.body"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -6060,7 +6760,6 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(4).cast::(); - OutgoingBody::from_handle(l2 as u32) }; Ok(e) @@ -6076,11 +6775,22 @@ pub mod wasi { } 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 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")] @@ -6088,7 +6798,6 @@ pub mod wasi { #[link_name = "[method]outgoing-body.write"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -6099,8 +6808,9 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(4).cast::(); - - super::super::super::wasi::io0_2_0::streams::OutputStream::from_handle(l2 as u32) + super::super::super::wasi::io0_2_0::streams::OutputStream::from_handle( + l2 as u32, + ) }; Ok(e) } @@ -6115,6 +6825,15 @@ pub mod wasi { } 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, @@ -6122,7 +6841,9 @@ pub mod wasi { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit; 40]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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), @@ -6134,12 +6855,16 @@ pub mod wasi { #[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); + wit_import( + (&this).take_handle() as i32, + result0_0, + result0_1, + ptr1, + ); let l2 = i32::from(*ptr1.add(0).cast::()); match l2 { 0 => { @@ -6155,24 +6880,19 @@ pub mod wasi { 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 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, - ); - + let bytes7 = _rt::Vec::from_raw_parts( + l5.cast(), + len7, + len7, + ); _rt::string_lift(bytes7) }; Some(e) @@ -6183,10 +6903,7 @@ pub mod wasi { 0 => None, 1 => { let e = { - let l9 = i32::from( - *ptr1.add(30).cast::(), - ); - + let l9 = i32::from(*ptr1.add(30).cast::()); l9 as u16 }; Some(e) @@ -6213,16 +6930,12 @@ pub mod wasi { 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::(), - ); - + let l11 = i32::from(*ptr1.add(17).cast::()); l11 as u8 }; Some(e) @@ -6233,18 +6946,14 @@ pub mod wasi { 0 => None, 1 => { let e = { - let l13 = - *ptr1.add(24).cast::<*mut u8>(); - let l14 = - *ptr1.add(28).cast::(); + 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, - ); - + let bytes15 = _rt::Vec::from_raw_parts( + l13.cast(), + len15, + len15, + ); _rt::string_lift(bytes15) }; Some(e) @@ -6260,13 +6969,11 @@ pub mod wasi { 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) @@ -6282,13 +6989,11 @@ pub mod wasi { 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) @@ -6301,47 +7006,43 @@ pub mod wasi { 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(), - }, - } + 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) } @@ -6353,13 +7054,11 @@ pub mod wasi { 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) @@ -6373,24 +7072,19 @@ pub mod wasi { 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 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, - ); - + let bytes32 = _rt::Vec::from_raw_parts( + l30.cast(), + len32, + len32, + ); _rt::string_lift(bytes32) }; Some(e) @@ -6401,9 +7095,7 @@ pub mod wasi { 0 => None, 1 => { let e = { - let l34 = - *ptr1.add(32).cast::(); - + let l34 = *ptr1.add(32).cast::(); l34 as u32 }; Some(e) @@ -6418,13 +7110,11 @@ pub mod wasi { 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) @@ -6438,24 +7128,19 @@ pub mod wasi { 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 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, - ); - + let bytes40 = _rt::Vec::from_raw_parts( + l38.cast(), + len40, + len40, + ); _rt::string_lift(bytes40) }; Some(e) @@ -6466,9 +7151,7 @@ pub mod wasi { 0 => None, 1 => { let e = { - let l42 = - *ptr1.add(32).cast::(); - + let l42 = *ptr1.add(32).cast::(); l42 as u32 }; Some(e) @@ -6482,13 +7165,11 @@ pub mod wasi { 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) @@ -6501,13 +7182,11 @@ pub mod wasi { 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) @@ -6521,24 +7200,19 @@ pub mod wasi { 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 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, - ); - + let bytes50 = _rt::Vec::from_raw_parts( + l48.cast(), + len50, + len50, + ); _rt::string_lift(bytes50) }; Some(e) @@ -6549,9 +7223,7 @@ pub mod wasi { 0 => None, 1 => { let e = { - let l52 = - *ptr1.add(32).cast::(); - + let l52 = *ptr1.add(32).cast::(); l52 as u32 }; Some(e) @@ -6565,13 +7237,11 @@ pub mod wasi { 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 l54 = *ptr1.add(20).cast::<*mut u8>(); let l55 = *ptr1.add(24).cast::(); let len56 = l55; let bytes56 = _rt::Vec::from_raw_parts( @@ -6579,7 +7249,6 @@ pub mod wasi { len56, len56, ); - _rt::string_lift(bytes56) }; Some(e) @@ -6592,13 +7261,11 @@ pub mod wasi { 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 l58 = *ptr1.add(20).cast::<*mut u8>(); let l59 = *ptr1.add(24).cast::(); let len60 = l59; let bytes60 = _rt::Vec::from_raw_parts( @@ -6606,7 +7273,6 @@ pub mod wasi { len60, len60, ); - _rt::string_lift(bytes60) }; Some(e) @@ -6625,13 +7291,11 @@ pub mod wasi { 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 l62 = *ptr1.add(20).cast::<*mut u8>(); let l63 = *ptr1.add(24).cast::(); let len64 = l63; let bytes64 = _rt::Vec::from_raw_parts( @@ -6639,7 +7303,6 @@ pub mod wasi { len64, len64, ); - _rt::string_lift(bytes64) }; Some(e) @@ -6650,7 +7313,6 @@ pub mod wasi { ErrorCode::InternalError(e65) } }; - v65 }; Err(e) @@ -6662,6 +7324,9 @@ pub mod wasi { } 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`. pub fn subscribe(&self) -> Pollable { unsafe { #[cfg(target_arch = "wasm32")] @@ -6670,23 +7335,42 @@ pub mod wasi { #[link_name = "[method]future-incoming-response.subscribe"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() } let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io0_2_0::poll::Pollable::from_handle(ret as u32) + super::super::super::wasi::io0_2_0::poll::Pollable::from_handle( + ret as u32, + ) } } } impl FutureIncomingResponse { #[allow(unused_unsafe, clippy::all)] - pub fn get(&self) -> Option, ()>> { + /// 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 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")] @@ -6694,527 +7378,471 @@ pub mod wasi { #[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) - } - }; - + 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) @@ -7239,6 +7867,17 @@ pub mod wasi { } } #[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))] @@ -7251,7 +7890,6 @@ pub mod wasi { #[link_name = "http-error-code"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -7269,14 +7907,12 @@ pub mod wasi { 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 l4 = *ptr0.add(20).cast::<*mut u8>(); let l5 = *ptr0.add(24).cast::(); let len6 = l5; let bytes6 = _rt::Vec::from_raw_parts( @@ -7284,7 +7920,6 @@ pub mod wasi { len6, len6, ); - _rt::string_lift(bytes6) }; Some(e) @@ -7295,10 +7930,7 @@ pub mod wasi { 0 => None, 1 => { let e = { - let l8 = i32::from( - *ptr0.add(30).cast::(), - ); - + let l8 = i32::from(*ptr0.add(30).cast::()); l8 as u16 }; Some(e) @@ -7325,16 +7957,12 @@ pub mod wasi { 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::(), - ); - + let l10 = i32::from(*ptr0.add(17).cast::()); l10 as u8 }; Some(e) @@ -7345,8 +7973,7 @@ pub mod wasi { 0 => None, 1 => { let e = { - let l12 = - *ptr0.add(24).cast::<*mut u8>(); + let l12 = *ptr0.add(24).cast::<*mut u8>(); let l13 = *ptr0.add(28).cast::(); let len14 = l13; let bytes14 = _rt::Vec::from_raw_parts( @@ -7354,7 +7981,6 @@ pub mod wasi { len14, len14, ); - _rt::string_lift(bytes14) }; Some(e) @@ -7370,13 +7996,11 @@ pub mod wasi { 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) @@ -7392,13 +8016,11 @@ pub mod wasi { 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) @@ -7411,54 +8033,41 @@ pub mod wasi { 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::()); - + 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 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); - + let bytes23 = _rt::Vec::from_raw_parts( + l21.cast(), + len23, + len23, + ); _rt::string_lift(bytes23) }; Some(e) } - _ => { - _rt::invalid_enum_discriminant() - } + _ => _rt::invalid_enum_discriminant(), }, field_size: match l24 { 0 => None, 1 => { let e = { - let l25 = *ptr0 - .add(36) - .cast::(); - + let l25 = *ptr0.add(36).cast::(); l25 as u32 }; Some(e) } - _ => { - _rt::invalid_enum_discriminant() - } + _ => _rt::invalid_enum_discriminant(), }, } }; @@ -7472,13 +8081,11 @@ pub mod wasi { 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) @@ -7492,14 +8099,12 @@ pub mod wasi { 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 l29 = *ptr0.add(20).cast::<*mut u8>(); let l30 = *ptr0.add(24).cast::(); let len31 = l30; let bytes31 = _rt::Vec::from_raw_parts( @@ -7507,7 +8112,6 @@ pub mod wasi { len31, len31, ); - _rt::string_lift(bytes31) }; Some(e) @@ -7519,7 +8123,6 @@ pub mod wasi { 1 => { let e = { let l33 = *ptr0.add(32).cast::(); - l33 as u32 }; Some(e) @@ -7534,13 +8137,11 @@ pub mod wasi { 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) @@ -7554,14 +8155,12 @@ pub mod wasi { 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 l37 = *ptr0.add(20).cast::<*mut u8>(); let l38 = *ptr0.add(24).cast::(); let len39 = l38; let bytes39 = _rt::Vec::from_raw_parts( @@ -7569,7 +8168,6 @@ pub mod wasi { len39, len39, ); - _rt::string_lift(bytes39) }; Some(e) @@ -7581,7 +8179,6 @@ pub mod wasi { 1 => { let e = { let l41 = *ptr0.add(32).cast::(); - l41 as u32 }; Some(e) @@ -7595,13 +8192,11 @@ pub mod wasi { 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) @@ -7614,13 +8209,11 @@ pub mod wasi { 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) @@ -7634,14 +8227,12 @@ pub mod wasi { 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 l47 = *ptr0.add(20).cast::<*mut u8>(); let l48 = *ptr0.add(24).cast::(); let len49 = l48; let bytes49 = _rt::Vec::from_raw_parts( @@ -7649,7 +8240,6 @@ pub mod wasi { len49, len49, ); - _rt::string_lift(bytes49) }; Some(e) @@ -7661,7 +8251,6 @@ pub mod wasi { 1 => { let e = { let l51 = *ptr0.add(32).cast::(); - l51 as u32 }; Some(e) @@ -7675,7 +8264,6 @@ pub mod wasi { 31 => { let e64 = { let l52 = i32::from(*ptr0.add(16).cast::()); - match l52 { 0 => None, 1 => { @@ -7688,7 +8276,6 @@ pub mod wasi { len55, len55, ); - _rt::string_lift(bytes55) }; Some(e) @@ -7701,7 +8288,6 @@ pub mod wasi { 32 => { let e64 = { let l56 = i32::from(*ptr0.add(16).cast::()); - match l56 { 0 => None, 1 => { @@ -7714,7 +8300,6 @@ pub mod wasi { len59, len59, ); - _rt::string_lift(bytes59) }; Some(e) @@ -7733,7 +8318,6 @@ pub mod wasi { debug_assert_eq!(n, 38, "invalid enum discriminant"); let e64 = { let l60 = i32::from(*ptr0.add(16).cast::()); - match l60 { 0 => None, 1 => { @@ -7746,7 +8330,6 @@ pub mod wasi { len63, len63, ); - _rt::string_lift(bytes63) }; Some(e) @@ -7757,7 +8340,6 @@ pub mod wasi { ErrorCode::InternalError(e64) } }; - v64 }; Some(e) @@ -7774,17 +8356,13 @@ pub mod wasi { pub mod error { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; use super::super::super::_rt; - #[derive(Debug)] #[repr(transparent)] pub struct Error { handle: _rt::Resource, } - impl Error { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { @@ -7792,24 +8370,20 @@ pub mod wasi { 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")] @@ -7817,19 +8391,19 @@ pub mod wasi { #[link_name = "[resource-drop]error"] fn drop(_: u32); } - drop(_handle); } } } - impl Error { #[allow(unused_unsafe, clippy::all)] 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 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")] @@ -7837,7 +8411,6 @@ pub mod wasi { #[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!() @@ -7852,22 +8425,17 @@ pub mod wasi { } } } - #[allow(dead_code, clippy::all)] pub mod poll { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; use super::super::super::_rt; - #[derive(Debug)] #[repr(transparent)] pub struct Pollable { handle: _rt::Resource, } - impl Pollable { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { @@ -7875,24 +8443,20 @@ pub mod wasi { 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 Pollable { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - #[cfg(target_arch = "wasm32")] { #[link(wasm_import_module = "wasi:io/poll@0.2.0")] @@ -7900,12 +8464,10 @@ pub mod wasi { #[link_name = "[resource-drop]pollable"] fn drop(_: u32); } - drop(_handle); } } } - impl Pollable { #[allow(unused_unsafe, clippy::all)] pub fn ready(&self) -> bool { @@ -7916,7 +8478,6 @@ pub mod wasi { #[link_name = "[method]pollable.ready"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() @@ -7936,7 +8497,6 @@ pub mod wasi { #[link_name = "[method]pollable.block"] fn wit_import(_: i32); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) { unreachable!() @@ -7953,7 +8513,10 @@ pub mod wasi { let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let vec0 = in_; let len0 = vec0.len(); - let layout0 = _rt::alloc::Layout::from_size_align_unchecked(vec0.len() * 4, 4); + let layout0 = _rt::alloc::Layout::from_size_align_unchecked( + vec0.len() * 4, + 4, + ); let result0 = if layout0.size() != 0 { let ptr = _rt::alloc::alloc(layout0).cast::(); if ptr.is_null() { @@ -7961,9 +8524,7 @@ pub mod wasi { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec0.into_iter().enumerate() { let base = result0.add(i * 4); @@ -7978,7 +8539,6 @@ pub mod wasi { #[link_name = "poll"] fn wit_import(_: *mut u8, _: usize, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: *mut u8, _: usize, _: *mut u8) { unreachable!() @@ -7994,14 +8554,11 @@ pub mod wasi { } } } - #[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; + 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::io0_2_0::error::Error; pub type Pollable = super::super::super::wasi::io0_2_0::poll::Pollable; @@ -8010,30 +8567,36 @@ pub mod wasi { Closed, } impl ::core::fmt::Debug for StreamError { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + 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(), + 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 { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { write!(f, "{:?}", self) } } - impl std::error::Error for StreamError {} - #[derive(Debug)] #[repr(transparent)] pub struct InputStream { handle: _rt::Resource, } - impl InputStream { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { @@ -8041,24 +8604,20 @@ pub mod wasi { 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")] @@ -8066,18 +8625,15 @@ pub mod wasi { #[link_name = "[resource-drop]input-stream"] fn drop(_: u32); } - drop(_handle); } } } - #[derive(Debug)] #[repr(transparent)] pub struct OutputStream { handle: _rt::Resource, } - impl OutputStream { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { @@ -8085,24 +8641,20 @@ pub mod wasi { 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")] @@ -8110,19 +8662,19 @@ pub mod wasi { #[link_name = "[resource-drop]output-stream"] fn drop(_: u32); } - drop(_handle); } } } - impl InputStream { #[allow(unused_unsafe, clippy::all)] 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 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")] @@ -8130,7 +8682,6 @@ pub mod wasi { #[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!() @@ -8143,7 +8694,6 @@ pub mod wasi { 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) @@ -8155,8 +8705,9 @@ pub mod wasi { 0 => { let e7 = { let l6 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io0_2_0::error::Error::from_handle(l6 as u32) + super::super::super::wasi::io0_2_0::error::Error::from_handle( + l6 as u32, + ) }; StreamError::LastOperationFailed(e7) } @@ -8165,7 +8716,6 @@ pub mod wasi { StreamError::Closed } }; - v7 }; Err(e) @@ -8177,11 +8727,16 @@ pub mod wasi { } impl InputStream { #[allow(unused_unsafe, clippy::all)] - pub fn blocking_read(&self, len: u64) -> Result<_rt::Vec, StreamError> { + 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 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")] @@ -8189,7 +8744,6 @@ pub mod wasi { #[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!() @@ -8202,7 +8756,6 @@ pub mod wasi { 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) @@ -8214,8 +8767,9 @@ pub mod wasi { 0 => { let e7 = { let l6 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io0_2_0::error::Error::from_handle(l6 as u32) + super::super::super::wasi::io0_2_0::error::Error::from_handle( + l6 as u32, + ) }; StreamError::LastOperationFailed(e7) } @@ -8224,7 +8778,6 @@ pub mod wasi { StreamError::Closed } }; - v7 }; Err(e) @@ -8240,7 +8793,9 @@ pub mod wasi { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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")] @@ -8248,7 +8803,6 @@ pub mod wasi { #[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!() @@ -8259,7 +8813,6 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(8).cast::(); - l2 as u64 }; Ok(e) @@ -8271,8 +8824,9 @@ pub mod wasi { 0 => { let e5 = { let l4 = *ptr0.add(12).cast::(); - - super::super::super::wasi::io0_2_0::error::Error::from_handle(l4 as u32) + super::super::super::wasi::io0_2_0::error::Error::from_handle( + l4 as u32, + ) }; StreamError::LastOperationFailed(e5) } @@ -8281,7 +8835,6 @@ pub mod wasi { StreamError::Closed } }; - v5 }; Err(e) @@ -8297,7 +8850,9 @@ pub mod wasi { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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")] @@ -8305,7 +8860,6 @@ pub mod wasi { #[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!() @@ -8316,7 +8870,6 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(8).cast::(); - l2 as u64 }; Ok(e) @@ -8328,8 +8881,9 @@ pub mod wasi { 0 => { let e5 = { let l4 = *ptr0.add(12).cast::(); - - super::super::super::wasi::io0_2_0::error::Error::from_handle(l4 as u32) + super::super::super::wasi::io0_2_0::error::Error::from_handle( + l4 as u32, + ) }; StreamError::LastOperationFailed(e5) } @@ -8338,7 +8892,6 @@ pub mod wasi { StreamError::Closed } }; - v5 }; Err(e) @@ -8358,13 +8911,14 @@ pub mod wasi { #[link_name = "[method]input-stream.subscribe"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() } let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io0_2_0::poll::Pollable::from_handle(ret as u32) + super::super::super::wasi::io0_2_0::poll::Pollable::from_handle( + ret as u32, + ) } } } @@ -8374,7 +8928,9 @@ pub mod wasi { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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")] @@ -8382,7 +8938,6 @@ pub mod wasi { #[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!() @@ -8393,7 +8948,6 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(8).cast::(); - l2 as u64 }; Ok(e) @@ -8405,8 +8959,9 @@ pub mod wasi { 0 => { let e5 = { let l4 = *ptr0.add(12).cast::(); - - super::super::super::wasi::io0_2_0::error::Error::from_handle(l4 as u32) + super::super::super::wasi::io0_2_0::error::Error::from_handle( + l4 as u32, + ) }; StreamError::LastOperationFailed(e5) } @@ -8415,7 +8970,6 @@ pub mod wasi { StreamError::Closed } }; - v5 }; Err(e) @@ -8431,7 +8985,9 @@ pub mod wasi { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); + let mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 12], + ); let vec0 = contents; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); @@ -8442,7 +8998,6 @@ pub mod wasi { #[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!() @@ -8461,8 +9016,9 @@ pub mod wasi { 0 => { let e5 = { let l4 = *ptr1.add(8).cast::(); - - super::super::super::wasi::io0_2_0::error::Error::from_handle(l4 as u32) + super::super::super::wasi::io0_2_0::error::Error::from_handle( + l4 as u32, + ) }; StreamError::LastOperationFailed(e5) } @@ -8471,7 +9027,6 @@ pub mod wasi { StreamError::Closed } }; - v5 }; Err(e) @@ -8483,11 +9038,16 @@ pub mod wasi { } impl OutputStream { #[allow(unused_unsafe, clippy::all)] - pub fn blocking_write_and_flush(&self, contents: &[u8]) -> Result<(), StreamError> { + 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 mut ret_area = RetArea( + [::core::mem::MaybeUninit::uninit(); 12], + ); let vec0 = contents; let ptr0 = vec0.as_ptr().cast::(); let len0 = vec0.len(); @@ -8498,7 +9058,6 @@ pub mod wasi { #[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!() @@ -8517,8 +9076,9 @@ pub mod wasi { 0 => { let e5 = { let l4 = *ptr1.add(8).cast::(); - - super::super::super::wasi::io0_2_0::error::Error::from_handle(l4 as u32) + super::super::super::wasi::io0_2_0::error::Error::from_handle( + l4 as u32, + ) }; StreamError::LastOperationFailed(e5) } @@ -8527,7 +9087,6 @@ pub mod wasi { StreamError::Closed } }; - v5 }; Err(e) @@ -8543,7 +9102,9 @@ pub mod wasi { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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")] @@ -8551,7 +9112,6 @@ pub mod wasi { #[link_name = "[method]output-stream.flush"] fn wit_import(_: i32, _: *mut u8); } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32, _: *mut u8) { unreachable!() @@ -8570,8 +9130,9 @@ pub mod wasi { 0 => { let e4 = { let l3 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io0_2_0::error::Error::from_handle(l3 as u32) + super::super::super::wasi::io0_2_0::error::Error::from_handle( + l3 as u32, + ) }; StreamError::LastOperationFailed(e4) } @@ -8580,7 +9141,6 @@ pub mod wasi { StreamError::Closed } }; - v4 }; Err(e) @@ -8596,7 +9156,9 @@ pub mod wasi { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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")] @@ -8604,7 +9166,6 @@ pub mod wasi { #[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!() @@ -8623,8 +9184,9 @@ pub mod wasi { 0 => { let e4 = { let l3 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io0_2_0::error::Error::from_handle(l3 as u32) + super::super::super::wasi::io0_2_0::error::Error::from_handle( + l3 as u32, + ) }; StreamError::LastOperationFailed(e4) } @@ -8633,7 +9195,6 @@ pub mod wasi { StreamError::Closed } }; - v4 }; Err(e) @@ -8653,13 +9214,14 @@ pub mod wasi { #[link_name = "[method]output-stream.subscribe"] fn wit_import(_: i32) -> i32; } - #[cfg(not(target_arch = "wasm32"))] fn wit_import(_: i32) -> i32 { unreachable!() } let ret = wit_import((self).handle() as i32); - super::super::super::wasi::io0_2_0::poll::Pollable::from_handle(ret as u32) + super::super::super::wasi::io0_2_0::poll::Pollable::from_handle( + ret as u32, + ) } } } @@ -8669,7 +9231,9 @@ pub mod wasi { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit; 12]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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")] @@ -8677,7 +9241,6 @@ pub mod wasi { #[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!() @@ -8696,8 +9259,9 @@ pub mod wasi { 0 => { let e4 = { let l3 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io0_2_0::error::Error::from_handle(l3 as u32) + super::super::super::wasi::io0_2_0::error::Error::from_handle( + l3 as u32, + ) }; StreamError::LastOperationFailed(e4) } @@ -8706,7 +9270,6 @@ pub mod wasi { StreamError::Closed } }; - v4 }; Err(e) @@ -8718,11 +9281,16 @@ pub mod wasi { } impl OutputStream { #[allow(unused_unsafe, clippy::all)] - pub fn blocking_write_zeroes_and_flush(&self, len: u64) -> Result<(), StreamError> { + 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 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")] @@ -8730,7 +9298,6 @@ pub mod wasi { #[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!() @@ -8749,8 +9316,9 @@ pub mod wasi { 0 => { let e4 = { let l3 = *ptr0.add(8).cast::(); - - super::super::super::wasi::io0_2_0::error::Error::from_handle(l3 as u32) + super::super::super::wasi::io0_2_0::error::Error::from_handle( + l3 as u32, + ) }; StreamError::LastOperationFailed(e4) } @@ -8759,7 +9327,6 @@ pub mod wasi { StreamError::Closed } }; - v4 }; Err(e) @@ -8771,11 +9338,17 @@ pub mod wasi { } impl OutputStream { #[allow(unused_unsafe, clippy::all)] - pub fn splice(&self, src: &InputStream, len: u64) -> Result { + 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 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")] @@ -8783,7 +9356,6 @@ pub mod wasi { #[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!() @@ -8799,7 +9371,6 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(8).cast::(); - l2 as u64 }; Ok(e) @@ -8811,8 +9382,9 @@ pub mod wasi { 0 => { let e5 = { let l4 = *ptr0.add(12).cast::(); - - super::super::super::wasi::io0_2_0::error::Error::from_handle(l4 as u32) + super::super::super::wasi::io0_2_0::error::Error::from_handle( + l4 as u32, + ) }; StreamError::LastOperationFailed(e5) } @@ -8821,7 +9393,6 @@ pub mod wasi { StreamError::Closed } }; - v5 }; Err(e) @@ -8841,7 +9412,9 @@ pub mod wasi { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit; 16]); - let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 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")] @@ -8849,7 +9422,6 @@ pub mod wasi { #[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!() @@ -8865,7 +9437,6 @@ pub mod wasi { 0 => { let e = { let l2 = *ptr0.add(8).cast::(); - l2 as u64 }; Ok(e) @@ -8877,8 +9448,9 @@ pub mod wasi { 0 => { let e5 = { let l4 = *ptr0.add(12).cast::(); - - super::super::super::wasi::io0_2_0::error::Error::from_handle(l4 as u32) + super::super::super::wasi::io0_2_0::error::Error::from_handle( + l4 as u32, + ) }; StreamError::LastOperationFailed(e5) } @@ -8887,7 +9459,6 @@ pub mod wasi { StreamError::Closed } }; - v5 }; Err(e) @@ -8905,17 +9476,16 @@ pub mod wasi { pub mod network { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; use super::super::super::_rt; - + /// An opaque resource that represents access to (a subset of) the network. + /// This enables context-based security for networking. + /// There is no need for this to map 1:1 to a physical network interface. #[derive(Debug)] #[repr(transparent)] pub struct Network { handle: _rt::Resource, } - impl Network { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { @@ -8923,24 +9493,20 @@ pub mod wasi { 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 Network { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - #[cfg(target_arch = "wasm32")] { #[link(wasm_import_module = "wasi:sockets/network@0.2.0")] @@ -8948,35 +9514,83 @@ pub mod wasi { #[link_name = "[resource-drop]network"] fn drop(_: u32); } - drop(_handle); } } } - + /// Error codes. + /// + /// In theory, every API can return any error code. + /// In practice, API's typically only return the errors documented per API + /// combined with a couple of errors that are always possible: + /// - `unknown` + /// - `access-denied` + /// - `not-supported` + /// - `out-of-memory` + /// - `concurrency-conflict` + /// + /// See each individual API for what the POSIX equivalents are. They sometimes differ per API. #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] + #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] pub enum ErrorCode { + /// Unknown error Unknown, + /// Access denied. + /// + /// POSIX equivalent: EACCES, EPERM AccessDenied, + /// The operation is not supported. + /// + /// POSIX equivalent: EOPNOTSUPP NotSupported, + /// One of the arguments is invalid. + /// + /// POSIX equivalent: EINVAL InvalidArgument, + /// Not enough memory to complete the operation. + /// + /// POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY OutOfMemory, + /// The operation timed out before it could finish completely. Timeout, + /// This operation is incompatible with another asynchronous operation that is already in progress. + /// + /// POSIX equivalent: EALREADY ConcurrencyConflict, + /// Trying to finish an asynchronous operation that: + /// - has not been started yet, or: + /// - was already finished by a previous `finish-*` call. + /// + /// Note: this is scheduled to be removed when `future`s are natively supported. NotInProgress, + /// The operation has been aborted because it could not be completed immediately. + /// + /// Note: this is scheduled to be removed when `future`s are natively supported. WouldBlock, + /// The operation is not valid in the socket's current state. InvalidState, + /// A new socket resource could not be created because of a system limit. NewSocketLimit, + /// A bind operation failed because the provided address is not an address that the `network` can bind to. AddressNotBindable, + /// A bind operation failed because the provided address is already in use or because there are no ephemeral ports available. AddressInUse, + /// The remote address is not reachable RemoteUnreachable, + /// The TCP connection was forcefully rejected ConnectionRefused, + /// The TCP connection was reset. ConnectionReset, + /// A TCP connection was aborted. ConnectionAborted, + /// The size of a datagram sent to a UDP socket exceeded the maximum + /// supported size. DatagramTooLarge, + /// Name does not exist or has no suitable associated IP addresses. NameUnresolvable, + /// A temporary failure in name resolution occurred. TemporaryResolverFailure, + /// A permanent failure in name resolution occurred. PermanentResolverFailure, } impl ErrorCode { @@ -9001,38 +9615,98 @@ pub mod wasi { ErrorCode::ConnectionAborted => "connection-aborted", ErrorCode::DatagramTooLarge => "datagram-too-large", ErrorCode::NameUnresolvable => "name-unresolvable", - ErrorCode::TemporaryResolverFailure => "temporary-resolver-failure", - ErrorCode::PermanentResolverFailure => "permanent-resolver-failure", + ErrorCode::TemporaryResolverFailure => { + "temporary-resolver-failure" + } + ErrorCode::PermanentResolverFailure => { + "permanent-resolver-failure" + } } } pub fn message(&self) -> &'static str { match self { - ErrorCode::Unknown => "", - ErrorCode::AccessDenied => "", - ErrorCode::NotSupported => "", - ErrorCode::InvalidArgument => "", - ErrorCode::OutOfMemory => "", - ErrorCode::Timeout => "", - ErrorCode::ConcurrencyConflict => "", - ErrorCode::NotInProgress => "", - ErrorCode::WouldBlock => "", - ErrorCode::InvalidState => "", - ErrorCode::NewSocketLimit => "", - ErrorCode::AddressNotBindable => "", - ErrorCode::AddressInUse => "", - ErrorCode::RemoteUnreachable => "", - ErrorCode::ConnectionRefused => "", - ErrorCode::ConnectionReset => "", - ErrorCode::ConnectionAborted => "", - ErrorCode::DatagramTooLarge => "", - ErrorCode::NameUnresolvable => "", - ErrorCode::TemporaryResolverFailure => "", - ErrorCode::PermanentResolverFailure => "", + ErrorCode::Unknown => "Unknown error", + ErrorCode::AccessDenied => { + "Access denied. + + POSIX equivalent: EACCES, EPERM" + } + ErrorCode::NotSupported => { + "The operation is not supported. + + POSIX equivalent: EOPNOTSUPP" + } + ErrorCode::InvalidArgument => { + "One of the arguments is invalid. + + POSIX equivalent: EINVAL" + } + ErrorCode::OutOfMemory => { + "Not enough memory to complete the operation. + + POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY" + } + ErrorCode::Timeout => { + "The operation timed out before it could finish completely." + } + ErrorCode::ConcurrencyConflict => { + "This operation is incompatible with another asynchronous operation that is already in progress. + + POSIX equivalent: EALREADY" + } + ErrorCode::NotInProgress => { + "Trying to finish an asynchronous operation that: + - has not been started yet, or: + - was already finished by a previous `finish-*` call. + + Note: this is scheduled to be removed when `future`s are natively supported." + } + ErrorCode::WouldBlock => { + "The operation has been aborted because it could not be completed immediately. + + Note: this is scheduled to be removed when `future`s are natively supported." + } + ErrorCode::InvalidState => { + "The operation is not valid in the socket's current state." + } + ErrorCode::NewSocketLimit => { + "A new socket resource could not be created because of a system limit." + } + ErrorCode::AddressNotBindable => { + "A bind operation failed because the provided address is not an address that the `network` can bind to." + } + ErrorCode::AddressInUse => { + "A bind operation failed because the provided address is already in use or because there are no ephemeral ports available." + } + ErrorCode::RemoteUnreachable => { + "The remote address is not reachable" + } + ErrorCode::ConnectionRefused => { + "The TCP connection was forcefully rejected" + } + ErrorCode::ConnectionReset => "The TCP connection was reset.", + ErrorCode::ConnectionAborted => "A TCP connection was aborted.", + ErrorCode::DatagramTooLarge => { + "The size of a datagram sent to a UDP socket exceeded the maximum + supported size." + } + ErrorCode::NameUnresolvable => { + "Name does not exist or has no suitable associated IP addresses." + } + ErrorCode::TemporaryResolverFailure => { + "A temporary failure in name resolution occurred." + } + ErrorCode::PermanentResolverFailure => { + "A permanent failure in name resolution occurred." + } } } } impl ::core::fmt::Debug for ErrorCode { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("ErrorCode") .field("code", &(*self as i32)) .field("name", &self.name()) @@ -9041,20 +9715,20 @@ pub mod wasi { } } 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) + 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::Unknown, 1 => ErrorCode::AccessDenied, @@ -9077,43 +9751,46 @@ pub mod wasi { 18 => ErrorCode::NameUnresolvable, 19 => ErrorCode::TemporaryResolverFailure, 20 => ErrorCode::PermanentResolverFailure, - _ => panic!("invalid enum discriminant"), } } } - #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] + #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] pub enum IpAddressFamily { + /// Similar to `AF_INET` in POSIX. Ipv4, + /// Similar to `AF_INET6` in POSIX. Ipv6, } impl ::core::fmt::Debug for IpAddressFamily { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { - IpAddressFamily::Ipv4 => f.debug_tuple("IpAddressFamily::Ipv4").finish(), - IpAddressFamily::Ipv6 => f.debug_tuple("IpAddressFamily::Ipv6").finish(), + IpAddressFamily::Ipv4 => { + f.debug_tuple("IpAddressFamily::Ipv4").finish() + } + IpAddressFamily::Ipv6 => { + f.debug_tuple("IpAddressFamily::Ipv6").finish() + } } } } - impl IpAddressFamily { #[doc(hidden)] pub unsafe fn _lift(val: u8) -> IpAddressFamily { if !cfg!(debug_assertions) { return ::core::mem::transmute(val); } - match val { 0 => IpAddressFamily::Ipv4, 1 => IpAddressFamily::Ipv6, - _ => panic!("invalid enum discriminant"), } } } - pub type Ipv4Address = (u8, u8, u8, u8); pub type Ipv6Address = (u16, u16, u16, u16, u16, u16, u16, u16); #[derive(Clone, Copy)] @@ -9122,21 +9799,33 @@ pub mod wasi { Ipv6(Ipv6Address), } impl ::core::fmt::Debug for IpAddress { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { - IpAddress::Ipv4(e) => f.debug_tuple("IpAddress::Ipv4").field(e).finish(), - IpAddress::Ipv6(e) => f.debug_tuple("IpAddress::Ipv6").field(e).finish(), + IpAddress::Ipv4(e) => { + f.debug_tuple("IpAddress::Ipv4").field(e).finish() + } + IpAddress::Ipv6(e) => { + f.debug_tuple("IpAddress::Ipv6").field(e).finish() + } } } } #[repr(C)] #[derive(Clone, Copy)] pub struct Ipv4SocketAddress { + /// sin_port pub port: u16, + /// sin_addr pub address: Ipv4Address, } impl ::core::fmt::Debug for Ipv4SocketAddress { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("Ipv4SocketAddress") .field("port", &self.port) .field("address", &self.address) @@ -9146,13 +9835,20 @@ pub mod wasi { #[repr(C)] #[derive(Clone, Copy)] pub struct Ipv6SocketAddress { + /// sin6_port pub port: u16, + /// sin6_flowinfo pub flow_info: u32, + /// sin6_addr pub address: Ipv6Address, + /// sin6_scope_id pub scope_id: u32, } impl ::core::fmt::Debug for Ipv6SocketAddress { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("Ipv6SocketAddress") .field("port", &self.port) .field("flow-info", &self.flow_info) @@ -9167,7 +9863,10 @@ pub mod wasi { Ipv6(Ipv6SocketAddress), } impl ::core::fmt::Debug for IpSocketAddress { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { IpSocketAddress::Ipv4(e) => { f.debug_tuple("IpSocketAddress::Ipv4").field(e).finish() @@ -9191,9 +9890,7 @@ pub mod exports { pub mod llm { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; /// A Large Language Model. pub type InferencingModel = _rt::String; @@ -9217,7 +9914,10 @@ pub mod exports { pub top_p: f32, } impl ::core::fmt::Debug for InferencingParams { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("InferencingParams") .field("max-tokens", &self.max_tokens) .field("repeat-penalty", &self.repeat_penalty) @@ -9239,7 +9939,10 @@ pub mod exports { InvalidInput(_rt::String), } impl ::core::fmt::Debug for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { Error::ModelNotSupported => { f.debug_tuple("Error::ModelNotSupported").finish() @@ -9254,11 +9957,13 @@ pub mod exports { } } impl ::core::fmt::Display for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { write!(f, "{:?}", self) } } - impl std::error::Error for Error {} /// Usage information related to the inferencing result #[repr(C)] @@ -9270,7 +9975,10 @@ pub mod exports { pub generated_token_count: u32, } impl ::core::fmt::Debug for InferencingUsage { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("InferencingUsage") .field("prompt-token-count", &self.prompt_token_count) .field("generated-token-count", &self.generated_token_count) @@ -9287,7 +9995,10 @@ pub mod exports { pub usage: InferencingUsage, } impl ::core::fmt::Debug for InferencingResult { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("InferencingResult") .field("text", &self.text) .field("usage", &self.usage) @@ -9304,7 +10015,10 @@ pub mod exports { pub prompt_token_count: u32, } impl ::core::fmt::Debug for EmbeddingsUsage { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("EmbeddingsUsage") .field("prompt-token-count", &self.prompt_token_count) .finish() @@ -9319,7 +10033,10 @@ pub mod exports { pub usage: EmbeddingsUsage, } impl ::core::fmt::Debug for EmbeddingsResult { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("EmbeddingsResult") .field("embeddings", &self.embeddings) .field("usage", &self.usage) @@ -9341,8 +10058,7 @@ pub mod exports { arg9: i32, arg10: f32, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[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; @@ -9370,10 +10086,7 @@ pub mod exports { match result2 { Ok(e) => { *ptr3.add(0).cast::() = (0i32) as u8; - let InferencingResult { - text: text4, - usage: usage4, - } = e; + let InferencingResult { text: text4, usage: usage4 } = e; let vec5 = (text4.into_bytes()).into_boxed_slice(); let ptr5 = vec5.as_ptr().cast::(); let len5 = vec5.len(); @@ -9384,8 +10097,12 @@ pub mod exports { prompt_token_count: prompt_token_count6, generated_token_count: generated_token_count6, } = usage4; - *ptr3.add(12).cast::() = _rt::as_i32(prompt_token_count6); - *ptr3.add(16).cast::() = _rt::as_i32(generated_token_count6); + *ptr3.add(12).cast::() = _rt::as_i32( + prompt_token_count6, + ); + *ptr3.add(16).cast::() = _rt::as_i32( + generated_token_count6, + ); } Err(e) => { *ptr3.add(0).cast::() = (1i32) as u8; @@ -9429,7 +10146,7 @@ pub mod exports { _ => { let l3 = i32::from(*arg0.add(4).cast::()); match l3 { - 0 => (), + 0 => {} 1 => { let l4 = *arg0.add(8).cast::<*mut u8>(); let l5 = *arg0.add(12).cast::(); @@ -9452,8 +10169,7 @@ pub mod exports { arg2: *mut u8, arg3: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg1; let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); let base4 = arg2; @@ -9466,13 +10182,15 @@ pub mod exports { let l2 = *base.add(4).cast::(); let len3 = l2; let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); - _rt::string_lift(bytes3) }; result4.push(e4); } _rt::cabi_dealloc(base4, len4 * 8, 4); - let result5 = T::generate_embeddings(_rt::string_lift(bytes0), result4); + let result5 = T::generate_embeddings( + _rt::string_lift(bytes0), + result4, + ); let ptr6 = _RET_AREA.0.as_mut_ptr().cast::(); match result5 { Ok(e) => { @@ -9483,8 +10201,10 @@ pub mod exports { } = e; let vec9 = embeddings7; let len9 = vec9.len(); - let layout9 = - _rt::alloc::Layout::from_size_align_unchecked(vec9.len() * 8, 4); + let layout9 = _rt::alloc::Layout::from_size_align_unchecked( + vec9.len() * 8, + 4, + ); let result9 = if layout9.size() != 0 { let ptr = _rt::alloc::alloc(layout9).cast::(); if ptr.is_null() { @@ -9492,9 +10212,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec9.into_iter().enumerate() { let base = result9.add(i * 8); @@ -9512,7 +10230,9 @@ pub mod exports { let EmbeddingsUsage { prompt_token_count: prompt_token_count10, } = usage7; - *ptr6.add(12).cast::() = _rt::as_i32(prompt_token_count10); + *ptr6.add(12).cast::() = _rt::as_i32( + prompt_token_count10, + ); } Err(e) => { *ptr6.add(0).cast::() = (1i32) as u8; @@ -9545,22 +10265,24 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_generate_embeddings(arg0: *mut u8) { + pub unsafe fn __post_return_generate_embeddings( + arg0: *mut u8, + ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { 0 => { - let l4 = *arg0.add(4).cast::<*mut u8>(); - let l5 = *arg0.add(8).cast::(); - let base6 = l4; - let len6 = l5; + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + let base6 = l1; + let len6 = l2; for i in 0..len6 { let base = base6.add(i * 8); { - let l1 = *base.add(0).cast::<*mut u8>(); - let l2 = *base.add(4).cast::(); - let base3 = l1; - let len3 = l2; - _rt::cabi_dealloc(base3, len3 * 4, 4); + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + let base5 = l3; + let len5 = l4; + _rt::cabi_dealloc(base5, len5 * 4, 4); } } _rt::cabi_dealloc(base6, len6 * 8, 4); @@ -9568,7 +10290,7 @@ pub mod exports { _ => { let l7 = i32::from(*arg0.add(4).cast::()); match l7 { - 0 => (), + 0 => {} 1 => { let l8 = *arg0.add(8).cast::<*mut u8>(); let l9 = *arg0.add(12).cast::(); @@ -9597,42 +10319,41 @@ pub mod exports { ) -> Result; } #[doc(hidden)] - - macro_rules! __export_fermyon_spin_llm_2_0_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "fermyon:spin/llm@2.0.0#infer"] - unsafe extern "C" fn export_infer(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: i32,arg5: i32,arg6: f32,arg7: i32,arg8: f32,arg9: i32,arg10: f32,) -> *mut u8 { - $($path_to_types)*::_export_infer_cabi::<$ty>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) - } - #[export_name = "cabi_post_fermyon:spin/llm@2.0.0#infer"] - unsafe extern "C" fn _post_return_infer(arg0: *mut u8,) { - $($path_to_types)*::__post_return_infer::<$ty>(arg0) - } - #[export_name = "fermyon:spin/llm@2.0.0#generate-embeddings"] - unsafe extern "C" fn export_generate_embeddings(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,) -> *mut u8 { - $($path_to_types)*::_export_generate_embeddings_cabi::<$ty>(arg0, arg1, arg2, arg3) - } - #[export_name = "cabi_post_fermyon:spin/llm@2.0.0#generate-embeddings"] - unsafe extern "C" fn _post_return_generate_embeddings(arg0: *mut u8,) { - $($path_to_types)*::__post_return_generate_embeddings::<$ty>(arg0) - } - };); - } + macro_rules! __export_fermyon_spin_llm_2_0_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = "fermyon:spin/llm@2.0.0#infer"] + unsafe extern "C" fn export_infer(arg0 : * mut u8, arg1 : usize, + arg2 : * mut u8, arg3 : usize, arg4 : i32, arg5 : i32, arg6 : + f32, arg7 : i32, arg8 : f32, arg9 : i32, arg10 : f32,) -> * mut + u8 { $($path_to_types)*:: _export_infer_cabi::<$ty > (arg0, arg1, + arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) } + #[export_name = "cabi_post_fermyon:spin/llm@2.0.0#infer"] unsafe + extern "C" fn _post_return_infer(arg0 : * mut u8,) { + $($path_to_types)*:: __post_return_infer::<$ty > (arg0) } + #[export_name = "fermyon:spin/llm@2.0.0#generate-embeddings"] + unsafe extern "C" fn export_generate_embeddings(arg0 : * mut u8, + arg1 : usize, arg2 : * mut u8, arg3 : usize,) -> * mut u8 { + $($path_to_types)*:: _export_generate_embeddings_cabi::<$ty > + (arg0, arg1, arg2, arg3) } #[export_name = + "cabi_post_fermyon:spin/llm@2.0.0#generate-embeddings"] unsafe + extern "C" fn _post_return_generate_embeddings(arg0 : * mut u8,) + { $($path_to_types)*:: __post_return_generate_embeddings::<$ty > + (arg0) } }; + }; + } #[doc(hidden)] pub(crate) use __export_fermyon_spin_llm_2_0_0_cabi; #[repr(align(4))] struct _RetArea([::core::mem::MaybeUninit; 20]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 20]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 20], + ); } - #[allow(dead_code, clippy::all)] pub mod redis { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; /// Errors related to interacting with Redis #[derive(Clone)] @@ -9647,7 +10368,10 @@ pub mod exports { Other(_rt::String), } impl ::core::fmt::Debug for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { Error::InvalidAddress => { f.debug_tuple("Error::InvalidAddress").finish() @@ -9655,27 +10379,30 @@ pub mod exports { Error::TooManyConnections => { f.debug_tuple("Error::TooManyConnections").finish() } - Error::TypeError => f.debug_tuple("Error::TypeError").finish(), - Error::Other(e) => f.debug_tuple("Error::Other").field(e).finish(), + Error::TypeError => { + f.debug_tuple("Error::TypeError").finish() + } + Error::Other(e) => { + f.debug_tuple("Error::Other").field(e).finish() + } } } } impl ::core::fmt::Display for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { write!(f, "{:?}", self) } } - impl std::error::Error for Error {} - #[derive(Debug)] #[repr(transparent)] pub struct Connection { handle: _rt::Resource, } - type _ConnectionRep = Option; - impl Connection { /// Creates a new resource from the specified representation. /// @@ -9685,77 +10412,68 @@ pub mod exports { pub fn new(val: T) -> Self { Self::type_guard::(); let val: _ConnectionRep = Some(val); - let ptr: *mut _ConnectionRep = _rt::Box::into_raw(_rt::Box::new(val)); + let ptr: *mut _ConnectionRep = _rt::Box::into_raw( + _rt::Box::new(val), + ); unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } } - /// Gets access to the underlying `T` which represents this resource. pub fn get(&self) -> &T { let ptr = unsafe { &*self.as_ptr::() }; ptr.as_ref().unwrap() } - /// Gets mutable access to the underlying `T` which represents this /// resource. pub fn get_mut(&mut self) -> &mut T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_mut().unwrap() } - /// Consumes this resource and returns the underlying `T`. pub fn into_inner(self) -> T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.take().unwrap() } - #[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) } - - // It's theoretically possible to implement the `GuestConnection` trait twice - // so guard against using it with two different types here. #[doc(hidden)] fn type_guard() { use core::any::TypeId; static mut LAST_TYPE: Option = None; unsafe { - assert!(!cfg!(target_feature = "threads")); + assert!(! cfg!(target_feature = "atomics")); let id = TypeId::of::(); match LAST_TYPE { - Some(ty) => assert!( - ty == id, - "cannot use two types with this resource type" - ), + Some(ty) => { + assert!( + ty == id, "cannot use two types with this resource type" + ) + } None => LAST_TYPE = Some(id), } } } - #[doc(hidden)] pub unsafe fn dtor(handle: *mut u8) { Self::type_guard::(); let _ = _rt::Box::from_raw(handle as *mut _ConnectionRep); } - fn as_ptr(&self) -> *mut _ConnectionRep { Connection::type_guard::(); T::_resource_rep(self.handle()).cast() } } - /// A borrowed version of [`Connection`] which represents a borrowed value /// with the lifetime `'a`. #[derive(Debug)] @@ -9764,7 +10482,6 @@ pub mod exports { rep: *mut u8, _marker: core::marker::PhantomData<&'a Connection>, } - impl<'a> ConnectionBorrow<'a> { #[doc(hidden)] pub unsafe fn lift(rep: usize) -> Self { @@ -9773,41 +10490,34 @@ pub mod exports { _marker: core::marker::PhantomData, } } - /// Gets access to the underlying `T` in this resource. pub fn get(&self) -> &T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_ref().unwrap() } - - // NB: mutable access is not allowed due to the component model allowing - // multiple borrows of the same resource. - fn as_ptr(&self) -> *mut _ConnectionRep { Connection::type_guard::(); self.rep.cast() } } - unsafe impl _rt::WasmResource for Connection { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/redis@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/redis@2.0.0" + )] extern "C" { #[link_name = "[resource-drop]connection"] fn drop(_: u32); } - drop(_handle); } } } - /// The message payload. pub type Payload = _rt::Vec; /// A parameter type for the general-purpose `execute` function. @@ -9817,7 +10527,10 @@ pub mod exports { Binary(Payload), } impl ::core::fmt::Debug for RedisParameter { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { RedisParameter::Int64(e) => { f.debug_tuple("RedisParameter::Int64").field(e).finish() @@ -9837,9 +10550,14 @@ pub mod exports { Binary(Payload), } impl ::core::fmt::Debug for RedisResult { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { - RedisResult::Nil => f.debug_tuple("RedisResult::Nil").finish(), + RedisResult::Nil => { + f.debug_tuple("RedisResult::Nil").finish() + } RedisResult::Status(e) => { f.debug_tuple("RedisResult::Status").field(e).finish() } @@ -9858,8 +10576,7 @@ pub mod exports { arg0: *mut u8, arg1: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg1; let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); let result1 = T::open(_rt::string_lift(bytes0)); @@ -9902,13 +10619,13 @@ pub mod exports { ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -9927,8 +10644,7 @@ pub mod exports { arg3: *mut u8, arg4: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let len1 = arg4; @@ -9970,18 +10686,18 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_method_connection_publish( - arg0: *mut u8, - ) { + pub unsafe fn __post_return_method_connection_publish< + T: GuestConnection, + >(arg0: *mut u8) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -9998,8 +10714,7 @@ pub mod exports { arg1: *mut u8, arg2: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let result1 = T::get( @@ -10061,7 +10776,7 @@ pub mod exports { 0 => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), + 0 => {} _ => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -10074,9 +10789,9 @@ pub mod exports { _ => { let l5 = i32::from(*arg0.add(4).cast::()); match l5 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l6 = *arg0.add(8).cast::<*mut u8>(); let l7 = *arg0.add(12).cast::(); @@ -10095,8 +10810,7 @@ pub mod exports { arg3: *mut u8, arg4: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let len1 = arg4; @@ -10143,13 +10857,13 @@ pub mod exports { ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -10166,8 +10880,7 @@ pub mod exports { arg1: *mut u8, arg2: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let result1 = T::incr( @@ -10213,13 +10926,13 @@ pub mod exports { ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(8).cast::()); match l1 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l2 = *arg0.add(12).cast::<*mut u8>(); let l3 = *arg0.add(16).cast::(); @@ -10236,8 +10949,7 @@ pub mod exports { arg1: *mut u8, arg2: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let base3 = arg1; let len3 = arg2; let mut result3 = _rt::Vec::with_capacity(len3); @@ -10248,14 +10960,15 @@ pub mod exports { let l1 = *base.add(4).cast::(); let len2 = l1; let bytes2 = _rt::Vec::from_raw_parts(l0.cast(), len2, len2); - _rt::string_lift(bytes2) }; result3.push(e3); } _rt::cabi_dealloc(base3, len3 * 8, 4); - let result4 = - T::del(ConnectionBorrow::lift(arg0 as u32 as usize).get(), result3); + let result4 = T::del( + ConnectionBorrow::lift(arg0 as u32 as usize).get(), + result3, + ); let ptr5 = _RET_AREA.0.as_mut_ptr().cast::(); match result4 { Ok(e) => { @@ -10295,13 +11008,13 @@ pub mod exports { ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -10320,8 +11033,7 @@ pub mod exports { arg3: *mut u8, arg4: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let base4 = arg3; @@ -10334,7 +11046,6 @@ pub mod exports { let l2 = *base.add(4).cast::(); let len3 = l2; let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); - _rt::string_lift(bytes3) }; result4.push(e4); @@ -10384,13 +11095,13 @@ pub mod exports { ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -10402,13 +11113,10 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_connection_smembers_cabi( - arg0: *mut u8, - arg1: *mut u8, - arg2: usize, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + pub unsafe fn _export_method_connection_smembers_cabi< + T: GuestConnection, + >(arg0: *mut u8, arg1: *mut u8, arg2: usize) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let result1 = T::smembers( @@ -10421,8 +11129,10 @@ pub mod exports { *ptr2.add(0).cast::() = (0i32) as u8; let vec4 = e; let len4 = vec4.len(); - let layout4 = - _rt::alloc::Layout::from_size_align_unchecked(vec4.len() * 8, 4); + let layout4 = _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 8, + 4, + ); let result4 = if layout4.size() != 0 { let ptr = _rt::alloc::alloc(layout4).cast::(); if ptr.is_null() { @@ -10430,9 +11140,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec4.into_iter().enumerate() { let base = result4.add(i * 8); @@ -10476,22 +11184,22 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_method_connection_smembers( - arg0: *mut u8, - ) { + pub unsafe fn __post_return_method_connection_smembers< + T: GuestConnection, + >(arg0: *mut u8) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { 0 => { - let l3 = *arg0.add(4).cast::<*mut u8>(); - let l4 = *arg0.add(8).cast::(); - let base5 = l3; - let len5 = l4; + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + let base5 = l1; + let len5 = l2; for i in 0..len5 { let base = base5.add(i * 8); { - let l1 = *base.add(0).cast::<*mut u8>(); - let l2 = *base.add(4).cast::(); - _rt::cabi_dealloc(l1, l2, 1); + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + _rt::cabi_dealloc(l3, l4, 1); } } _rt::cabi_dealloc(base5, len5 * 8, 4); @@ -10499,9 +11207,9 @@ pub mod exports { _ => { let l6 = i32::from(*arg0.add(4).cast::()); match l6 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l7 = *arg0.add(8).cast::<*mut u8>(); let l8 = *arg0.add(12).cast::(); @@ -10520,8 +11228,7 @@ pub mod exports { arg3: *mut u8, arg4: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let base4 = arg3; @@ -10534,7 +11241,6 @@ pub mod exports { let l2 = *base.add(4).cast::(); let len3 = l2; let bytes3 = _rt::Vec::from_raw_parts(l1.cast(), len3, len3); - _rt::string_lift(bytes3) }; result4.push(e4); @@ -10584,13 +11290,13 @@ pub mod exports { ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -10609,8 +11315,7 @@ pub mod exports { arg3: *mut u8, arg4: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let base7 = arg3; @@ -10624,7 +11329,6 @@ pub mod exports { 0 => { let e6 = { let l2 = *base.add(8).cast::(); - l2 }; RedisParameter::Int64(e6) @@ -10635,13 +11339,11 @@ pub mod exports { let l3 = *base.add(8).cast::<*mut u8>(); let l4 = *base.add(12).cast::(); let len5 = l4; - _rt::Vec::from_raw_parts(l3.cast(), len5, len5) }; RedisParameter::Binary(e6) } }; - v6 }; result7.push(e7); @@ -10658,8 +11360,10 @@ pub mod exports { *ptr9.add(0).cast::() = (0i32) as u8; let vec12 = e; let len12 = vec12.len(); - let layout12 = - _rt::alloc::Layout::from_size_align_unchecked(vec12.len() * 16, 8); + let layout12 = _rt::alloc::Layout::from_size_align_unchecked( + vec12.len() * 16, + 8, + ); let result12 = if layout12.size() != 0 { let ptr = _rt::alloc::alloc(layout12).cast::(); if ptr.is_null() { @@ -10667,9 +11371,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec12.into_iter().enumerate() { let base = result12.add(i * 16); @@ -10734,34 +11436,34 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_method_connection_execute( - arg0: *mut u8, - ) { + pub unsafe fn __post_return_method_connection_execute< + T: GuestConnection, + >(arg0: *mut u8) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { 0 => { - let l7 = *arg0.add(4).cast::<*mut u8>(); - let l8 = *arg0.add(8).cast::(); - let base9 = l7; - let len9 = l8; + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + let base9 = l1; + let len9 = l2; for i in 0..len9 { let base = base9.add(i * 16); { - let l1 = i32::from(*base.add(0).cast::()); - match l1 { - 0 => (), + let l3 = i32::from(*base.add(0).cast::()); + match l3 { + 0 => {} 1 => { - let l2 = *base.add(8).cast::<*mut u8>(); - let l3 = *base.add(12).cast::(); - _rt::cabi_dealloc(l2, l3, 1); - } - 2 => (), - _ => { let l4 = *base.add(8).cast::<*mut u8>(); let l5 = *base.add(12).cast::(); - let base6 = l4; - let len6 = l5; - _rt::cabi_dealloc(base6, len6 * 1, 1); + _rt::cabi_dealloc(l4, l5, 1); + } + 2 => {} + _ => { + let l6 = *base.add(8).cast::<*mut u8>(); + let l7 = *base.add(12).cast::(); + let base8 = l6; + let len8 = l7; + _rt::cabi_dealloc(base8, len8 * 1, 1); } } } @@ -10771,9 +11473,9 @@ pub mod exports { _ => { let l10 = i32::from(*arg0.add(4).cast::()); match l10 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l11 = *arg0.add(8).cast::<*mut u8>(); let l12 = *arg0.add(12).cast::(); @@ -10797,10 +11499,11 @@ pub mod exports { let _ = val; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/redis@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/redis@2.0.0" + )] extern "C" { #[link_name = "[resource-new]connection"] fn new(_: *mut u8) -> u32; @@ -10808,7 +11511,6 @@ pub mod exports { new(val) } } - #[doc(hidden)] fn _resource_rep(handle: u32) -> *mut u8 where @@ -10819,10 +11521,11 @@ pub mod exports { let _ = handle; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/redis@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/redis@2.0.0" + )] extern "C" { #[link_name = "[resource-rep]connection"] fn rep(_: u32) -> *mut u8; @@ -10830,11 +11533,14 @@ pub mod exports { unsafe { rep(handle) } } } - /// Open a connection to the Redis instance at `address`. fn open(address: _rt::String) -> Result; /// Publish a Redis message to the specified channel. - fn publish(&self, channel: _rt::String, payload: Payload) -> Result<(), Error>; + fn publish( + &self, + channel: _rt::String, + payload: Payload, + ) -> Result<(), Error>; /// Get the value of a key. fn get(&self, key: _rt::String) -> Result, Error>; /// Set key to value. @@ -10858,7 +11564,10 @@ pub mod exports { values: _rt::Vec<_rt::String>, ) -> Result; /// Retrieve the contents of the set named `key`. - fn smembers(&self, key: _rt::String) -> Result<_rt::Vec<_rt::String>, Error>; + fn smembers( + &self, + key: _rt::String, + ) -> Result<_rt::Vec<_rt::String>, Error>; /// Remove the specified `values` from the set named `key`, returning the number of newly-removed values. fn srem( &self, @@ -10873,118 +11582,143 @@ pub mod exports { ) -> Result<_rt::Vec, Error>; } #[doc(hidden)] - - macro_rules! __export_fermyon_spin_redis_2_0_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "fermyon:spin/redis@2.0.0#[static]connection.open"] - unsafe extern "C" fn export_static_connection_open(arg0: *mut u8,arg1: usize,) -> *mut u8 { - $($path_to_types)*::_export_static_connection_open_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1) - } - #[export_name = "cabi_post_fermyon:spin/redis@2.0.0#[static]connection.open"] - unsafe extern "C" fn _post_return_static_connection_open(arg0: *mut u8,) { - $($path_to_types)*::__post_return_static_connection_open::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/redis@2.0.0#[method]connection.publish"] - unsafe extern "C" fn export_method_connection_publish(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_publish_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2, arg3, arg4) - } - #[export_name = "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.publish"] - unsafe extern "C" fn _post_return_method_connection_publish(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_publish::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/redis@2.0.0#[method]connection.get"] - unsafe extern "C" fn export_method_connection_get(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_get_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2) - } - #[export_name = "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.get"] - unsafe extern "C" fn _post_return_method_connection_get(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_get::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/redis@2.0.0#[method]connection.set"] - unsafe extern "C" fn export_method_connection_set(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_set_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2, arg3, arg4) - } - #[export_name = "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.set"] - unsafe extern "C" fn _post_return_method_connection_set(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_set::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/redis@2.0.0#[method]connection.incr"] - unsafe extern "C" fn export_method_connection_incr(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_incr_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2) - } - #[export_name = "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.incr"] - unsafe extern "C" fn _post_return_method_connection_incr(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_incr::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/redis@2.0.0#[method]connection.del"] - unsafe extern "C" fn export_method_connection_del(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_del_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2) - } - #[export_name = "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.del"] - unsafe extern "C" fn _post_return_method_connection_del(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_del::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/redis@2.0.0#[method]connection.sadd"] - unsafe extern "C" fn export_method_connection_sadd(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_sadd_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2, arg3, arg4) - } - #[export_name = "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.sadd"] - unsafe extern "C" fn _post_return_method_connection_sadd(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_sadd::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/redis@2.0.0#[method]connection.smembers"] - unsafe extern "C" fn export_method_connection_smembers(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_smembers_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2) - } - #[export_name = "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.smembers"] - unsafe extern "C" fn _post_return_method_connection_smembers(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_smembers::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/redis@2.0.0#[method]connection.srem"] - unsafe extern "C" fn export_method_connection_srem(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_srem_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2, arg3, arg4) - } - #[export_name = "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.srem"] - unsafe extern "C" fn _post_return_method_connection_srem(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_srem::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/redis@2.0.0#[method]connection.execute"] - unsafe extern "C" fn export_method_connection_execute(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_execute_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2, arg3, arg4) - } - #[export_name = "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.execute"] - unsafe extern "C" fn _post_return_method_connection_execute(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_execute::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - - const _: () = { - #[doc(hidden)] - #[export_name = "fermyon:spin/redis@2.0.0#[dtor]connection"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: *mut u8) { - $($path_to_types)*::Connection::dtor::< - <$ty as $($path_to_types)*::Guest>::Connection - >(rep) - } - }; - - };); -} + macro_rules! __export_fermyon_spin_redis_2_0_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "fermyon:spin/redis@2.0.0#[static]connection.open"] unsafe extern + "C" fn export_static_connection_open(arg0 : * mut u8, arg1 : + usize,) -> * mut u8 { $($path_to_types)*:: + _export_static_connection_open_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1) } + #[export_name = + "cabi_post_fermyon:spin/redis@2.0.0#[static]connection.open"] + unsafe extern "C" fn _post_return_static_connection_open(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_static_connection_open::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/redis@2.0.0#[method]connection.publish"] unsafe + extern "C" fn export_method_connection_publish(arg0 : * mut u8, + arg1 : * mut u8, arg2 : usize, arg3 : * mut u8, arg4 : usize,) -> + * mut u8 { $($path_to_types)*:: + _export_method_connection_publish_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1, arg2, + arg3, arg4) } #[export_name = + "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.publish"] + unsafe extern "C" fn _post_return_method_connection_publish(arg0 + : * mut u8,) { $($path_to_types)*:: + __post_return_method_connection_publish::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/redis@2.0.0#[method]connection.get"] unsafe + extern "C" fn export_method_connection_get(arg0 : * mut u8, arg1 + : * mut u8, arg2 : usize,) -> * mut u8 { $($path_to_types)*:: + _export_method_connection_get_cabi::<<$ty as $($path_to_types)*:: + Guest >::Connection > (arg0, arg1, arg2) } #[export_name = + "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.get"] + unsafe extern "C" fn _post_return_method_connection_get(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_method_connection_get::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/redis@2.0.0#[method]connection.set"] unsafe + extern "C" fn export_method_connection_set(arg0 : * mut u8, arg1 + : * mut u8, arg2 : usize, arg3 : * mut u8, arg4 : usize,) -> * + mut u8 { $($path_to_types)*:: + _export_method_connection_set_cabi::<<$ty as $($path_to_types)*:: + Guest >::Connection > (arg0, arg1, arg2, arg3, arg4) } + #[export_name = + "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.set"] + unsafe extern "C" fn _post_return_method_connection_set(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_method_connection_set::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/redis@2.0.0#[method]connection.incr"] unsafe + extern "C" fn export_method_connection_incr(arg0 : * mut u8, arg1 + : * mut u8, arg2 : usize,) -> * mut u8 { $($path_to_types)*:: + _export_method_connection_incr_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1, arg2) } + #[export_name = + "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.incr"] + unsafe extern "C" fn _post_return_method_connection_incr(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_method_connection_incr::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/redis@2.0.0#[method]connection.del"] unsafe + extern "C" fn export_method_connection_del(arg0 : * mut u8, arg1 + : * mut u8, arg2 : usize,) -> * mut u8 { $($path_to_types)*:: + _export_method_connection_del_cabi::<<$ty as $($path_to_types)*:: + Guest >::Connection > (arg0, arg1, arg2) } #[export_name = + "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.del"] + unsafe extern "C" fn _post_return_method_connection_del(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_method_connection_del::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/redis@2.0.0#[method]connection.sadd"] unsafe + extern "C" fn export_method_connection_sadd(arg0 : * mut u8, arg1 + : * mut u8, arg2 : usize, arg3 : * mut u8, arg4 : usize,) -> * + mut u8 { $($path_to_types)*:: + _export_method_connection_sadd_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1, arg2, + arg3, arg4) } #[export_name = + "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.sadd"] + unsafe extern "C" fn _post_return_method_connection_sadd(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_method_connection_sadd::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/redis@2.0.0#[method]connection.smembers"] unsafe + extern "C" fn export_method_connection_smembers(arg0 : * mut u8, + arg1 : * mut u8, arg2 : usize,) -> * mut u8 { + $($path_to_types)*:: + _export_method_connection_smembers_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1, arg2) } + #[export_name = + "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.smembers"] + unsafe extern "C" fn _post_return_method_connection_smembers(arg0 + : * mut u8,) { $($path_to_types)*:: + __post_return_method_connection_smembers::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/redis@2.0.0#[method]connection.srem"] unsafe + extern "C" fn export_method_connection_srem(arg0 : * mut u8, arg1 + : * mut u8, arg2 : usize, arg3 : * mut u8, arg4 : usize,) -> * + mut u8 { $($path_to_types)*:: + _export_method_connection_srem_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1, arg2, + arg3, arg4) } #[export_name = + "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.srem"] + unsafe extern "C" fn _post_return_method_connection_srem(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_method_connection_srem::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/redis@2.0.0#[method]connection.execute"] unsafe + extern "C" fn export_method_connection_execute(arg0 : * mut u8, + arg1 : * mut u8, arg2 : usize, arg3 : * mut u8, arg4 : usize,) -> + * mut u8 { $($path_to_types)*:: + _export_method_connection_execute_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1, arg2, + arg3, arg4) } #[export_name = + "cabi_post_fermyon:spin/redis@2.0.0#[method]connection.execute"] + unsafe extern "C" fn _post_return_method_connection_execute(arg0 + : * mut u8,) { $($path_to_types)*:: + __post_return_method_connection_execute::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } const _ : () + = { #[doc(hidden)] #[export_name = + "fermyon:spin/redis@2.0.0#[dtor]connection"] + #[allow(non_snake_case)] unsafe extern "C" fn dtor(rep : * mut + u8) { $($path_to_types)*:: Connection::dtor::< <$ty as + $($path_to_types)*:: Guest >::Connection > (rep) } }; }; + }; + } #[doc(hidden)] pub(crate) use __export_fermyon_spin_redis_2_0_0_cabi; #[repr(align(8))] struct _RetArea([::core::mem::MaybeUninit; 24]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 24]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 24], + ); } - #[allow(dead_code, clippy::all)] pub mod mqtt { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; /// Errors related to interacting with Mqtt #[derive(Clone)] @@ -10999,7 +11733,10 @@ pub mod exports { Other(_rt::String), } impl ::core::fmt::Debug for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { Error::InvalidAddress => { f.debug_tuple("Error::InvalidAddress").finish() @@ -11010,60 +11747,65 @@ pub mod exports { Error::ConnectionFailed(e) => { f.debug_tuple("Error::ConnectionFailed").field(e).finish() } - Error::Other(e) => f.debug_tuple("Error::Other").field(e).finish(), + Error::Other(e) => { + f.debug_tuple("Error::Other").field(e).finish() + } } } } impl ::core::fmt::Display for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { write!(f, "{:?}", self) } } - impl std::error::Error for Error {} /// QoS for publishing Mqtt messages #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] + #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] pub enum Qos { AtMostOnce, AtLeastOnce, ExactlyOnce, } impl ::core::fmt::Debug for Qos { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { Qos::AtMostOnce => f.debug_tuple("Qos::AtMostOnce").finish(), - Qos::AtLeastOnce => f.debug_tuple("Qos::AtLeastOnce").finish(), - Qos::ExactlyOnce => f.debug_tuple("Qos::ExactlyOnce").finish(), + Qos::AtLeastOnce => { + f.debug_tuple("Qos::AtLeastOnce").finish() + } + Qos::ExactlyOnce => { + f.debug_tuple("Qos::ExactlyOnce").finish() + } } } } - impl Qos { #[doc(hidden)] pub unsafe fn _lift(val: u8) -> Qos { if !cfg!(debug_assertions) { return ::core::mem::transmute(val); } - match val { 0 => Qos::AtMostOnce, 1 => Qos::AtLeastOnce, 2 => Qos::ExactlyOnce, - _ => panic!("invalid enum discriminant"), } } } - #[derive(Debug)] #[repr(transparent)] pub struct Connection { handle: _rt::Resource, } - type _ConnectionRep = Option; - impl Connection { /// Creates a new resource from the specified representation. /// @@ -11073,77 +11815,68 @@ pub mod exports { pub fn new(val: T) -> Self { Self::type_guard::(); let val: _ConnectionRep = Some(val); - let ptr: *mut _ConnectionRep = _rt::Box::into_raw(_rt::Box::new(val)); + let ptr: *mut _ConnectionRep = _rt::Box::into_raw( + _rt::Box::new(val), + ); unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } } - /// Gets access to the underlying `T` which represents this resource. pub fn get(&self) -> &T { let ptr = unsafe { &*self.as_ptr::() }; ptr.as_ref().unwrap() } - /// Gets mutable access to the underlying `T` which represents this /// resource. pub fn get_mut(&mut self) -> &mut T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_mut().unwrap() } - /// Consumes this resource and returns the underlying `T`. pub fn into_inner(self) -> T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.take().unwrap() } - #[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) } - - // It's theoretically possible to implement the `GuestConnection` trait twice - // so guard against using it with two different types here. #[doc(hidden)] fn type_guard() { use core::any::TypeId; static mut LAST_TYPE: Option = None; unsafe { - assert!(!cfg!(target_feature = "threads")); + assert!(! cfg!(target_feature = "atomics")); let id = TypeId::of::(); match LAST_TYPE { - Some(ty) => assert!( - ty == id, - "cannot use two types with this resource type" - ), + Some(ty) => { + assert!( + ty == id, "cannot use two types with this resource type" + ) + } None => LAST_TYPE = Some(id), } } } - #[doc(hidden)] pub unsafe fn dtor(handle: *mut u8) { Self::type_guard::(); let _ = _rt::Box::from_raw(handle as *mut _ConnectionRep); } - fn as_ptr(&self) -> *mut _ConnectionRep { Connection::type_guard::(); T::_resource_rep(self.handle()).cast() } } - /// A borrowed version of [`Connection`] which represents a borrowed value /// with the lifetime `'a`. #[derive(Debug)] @@ -11152,7 +11885,6 @@ pub mod exports { rep: *mut u8, _marker: core::marker::PhantomData<&'a Connection>, } - impl<'a> ConnectionBorrow<'a> { #[doc(hidden)] pub unsafe fn lift(rep: usize) -> Self { @@ -11161,41 +11893,34 @@ pub mod exports { _marker: core::marker::PhantomData, } } - /// Gets access to the underlying `T` in this resource. pub fn get(&self) -> &T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_ref().unwrap() } - - // NB: mutable access is not allowed due to the component model allowing - // multiple borrows of the same resource. - fn as_ptr(&self) -> *mut _ConnectionRep { Connection::type_guard::(); self.rep.cast() } } - unsafe impl _rt::WasmResource for Connection { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/mqtt@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/mqtt@2.0.0" + )] extern "C" { #[link_name = "[resource-drop]connection"] fn drop(_: u32); } - drop(_handle); } } } - /// The message payload. pub type Payload = _rt::Vec; #[doc(hidden)] @@ -11209,8 +11934,7 @@ pub mod exports { arg5: usize, arg6: i64, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[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; @@ -11268,12 +11992,12 @@ pub mod exports { ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), - 1 => (), + 0 => {} + 1 => {} 2 => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -11298,8 +12022,7 @@ pub mod exports { arg4: usize, arg5: i32, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let len1 = arg4; @@ -11348,17 +12071,17 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_method_connection_publish( - arg0: *mut u8, - ) { + pub unsafe fn __post_return_method_connection_publish< + T: GuestConnection, + >(arg0: *mut u8) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), - 1 => (), + 0 => {} + 1 => {} 2 => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -11387,10 +12110,11 @@ pub mod exports { let _ = val; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/mqtt@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/mqtt@2.0.0" + )] extern "C" { #[link_name = "[resource-new]connection"] fn new(_: *mut u8) -> u32; @@ -11398,7 +12122,6 @@ pub mod exports { new(val) } } - #[doc(hidden)] fn _resource_rep(handle: u32) -> *mut u8 where @@ -11409,10 +12132,11 @@ pub mod exports { let _ = handle; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/mqtt@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/mqtt@2.0.0" + )] extern "C" { #[link_name = "[resource-rep]connection"] fn rep(_: u32) -> *mut u8; @@ -11420,7 +12144,6 @@ pub mod exports { unsafe { rep(handle) } } } - /// Open a connection to the Mqtt instance at `address`. fn open( address: _rt::String, @@ -11437,54 +12160,53 @@ pub mod exports { ) -> Result<(), Error>; } #[doc(hidden)] - - macro_rules! __export_fermyon_spin_mqtt_2_0_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "fermyon:spin/mqtt@2.0.0#[static]connection.open"] - unsafe extern "C" fn export_static_connection_open(arg0: *mut u8,arg1: usize,arg2: *mut u8,arg3: usize,arg4: *mut u8,arg5: usize,arg6: i64,) -> *mut u8 { - $($path_to_types)*::_export_static_connection_open_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2, arg3, arg4, arg5, arg6) - } - #[export_name = "cabi_post_fermyon:spin/mqtt@2.0.0#[static]connection.open"] - unsafe extern "C" fn _post_return_static_connection_open(arg0: *mut u8,) { - $($path_to_types)*::__post_return_static_connection_open::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/mqtt@2.0.0#[method]connection.publish"] - unsafe extern "C" fn export_method_connection_publish(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,arg5: i32,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_publish_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2, arg3, arg4, arg5) - } - #[export_name = "cabi_post_fermyon:spin/mqtt@2.0.0#[method]connection.publish"] - unsafe extern "C" fn _post_return_method_connection_publish(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_publish::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - - const _: () = { - #[doc(hidden)] - #[export_name = "fermyon:spin/mqtt@2.0.0#[dtor]connection"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: *mut u8) { - $($path_to_types)*::Connection::dtor::< - <$ty as $($path_to_types)*::Guest>::Connection - >(rep) - } - }; - - };); -} - #[doc(hidden)] + macro_rules! __export_fermyon_spin_mqtt_2_0_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "fermyon:spin/mqtt@2.0.0#[static]connection.open"] unsafe extern + "C" fn export_static_connection_open(arg0 : * mut u8, arg1 : + usize, arg2 : * mut u8, arg3 : usize, arg4 : * mut u8, arg5 : + usize, arg6 : i64,) -> * mut u8 { $($path_to_types)*:: + _export_static_connection_open_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1, arg2, + arg3, arg4, arg5, arg6) } #[export_name = + "cabi_post_fermyon:spin/mqtt@2.0.0#[static]connection.open"] + unsafe extern "C" fn _post_return_static_connection_open(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_static_connection_open::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/mqtt@2.0.0#[method]connection.publish"] unsafe + extern "C" fn export_method_connection_publish(arg0 : * mut u8, + arg1 : * mut u8, arg2 : usize, arg3 : * mut u8, arg4 : usize, + arg5 : i32,) -> * mut u8 { $($path_to_types)*:: + _export_method_connection_publish_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1, arg2, + arg3, arg4, arg5) } #[export_name = + "cabi_post_fermyon:spin/mqtt@2.0.0#[method]connection.publish"] + unsafe extern "C" fn _post_return_method_connection_publish(arg0 + : * mut u8,) { $($path_to_types)*:: + __post_return_method_connection_publish::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } const _ : () + = { #[doc(hidden)] #[export_name = + "fermyon:spin/mqtt@2.0.0#[dtor]connection"] + #[allow(non_snake_case)] unsafe extern "C" fn dtor(rep : * mut + u8) { $($path_to_types)*:: Connection::dtor::< <$ty as + $($path_to_types)*:: Guest >::Connection > (rep) } }; }; + }; + } + #[doc(hidden)] pub(crate) use __export_fermyon_spin_mqtt_2_0_0_cabi; #[repr(align(4))] struct _RetArea([::core::mem::MaybeUninit; 16]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 16]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 16], + ); } - #[allow(dead_code, clippy::all)] pub mod rdbms_types { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; /// Errors related to interacting with a database. #[derive(Clone)] @@ -11496,7 +12218,10 @@ pub mod exports { Other(_rt::String), } impl ::core::fmt::Debug for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { Error::ConnectionFailed(e) => { f.debug_tuple("Error::ConnectionFailed").field(e).finish() @@ -11507,24 +12232,29 @@ pub mod exports { Error::QueryFailed(e) => { f.debug_tuple("Error::QueryFailed").field(e).finish() } - Error::ValueConversionFailed(e) => f - .debug_tuple("Error::ValueConversionFailed") - .field(e) - .finish(), - Error::Other(e) => f.debug_tuple("Error::Other").field(e).finish(), + Error::ValueConversionFailed(e) => { + f.debug_tuple("Error::ValueConversionFailed") + .field(e) + .finish() + } + Error::Other(e) => { + f.debug_tuple("Error::Other").field(e).finish() + } } } } impl ::core::fmt::Display for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { write!(f, "{:?}", self) } } - impl std::error::Error for Error {} /// Data types for a database column #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] + #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] pub enum DbDataType { Boolean, Int8, @@ -11542,17 +12272,38 @@ pub mod exports { Other, } impl ::core::fmt::Debug for DbDataType { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { - DbDataType::Boolean => f.debug_tuple("DbDataType::Boolean").finish(), - DbDataType::Int8 => f.debug_tuple("DbDataType::Int8").finish(), - DbDataType::Int16 => f.debug_tuple("DbDataType::Int16").finish(), - DbDataType::Int32 => f.debug_tuple("DbDataType::Int32").finish(), - DbDataType::Int64 => f.debug_tuple("DbDataType::Int64").finish(), - DbDataType::Uint8 => f.debug_tuple("DbDataType::Uint8").finish(), - DbDataType::Uint16 => f.debug_tuple("DbDataType::Uint16").finish(), - DbDataType::Uint32 => f.debug_tuple("DbDataType::Uint32").finish(), - DbDataType::Uint64 => f.debug_tuple("DbDataType::Uint64").finish(), + DbDataType::Boolean => { + f.debug_tuple("DbDataType::Boolean").finish() + } + DbDataType::Int8 => { + f.debug_tuple("DbDataType::Int8").finish() + } + DbDataType::Int16 => { + f.debug_tuple("DbDataType::Int16").finish() + } + DbDataType::Int32 => { + f.debug_tuple("DbDataType::Int32").finish() + } + DbDataType::Int64 => { + f.debug_tuple("DbDataType::Int64").finish() + } + DbDataType::Uint8 => { + f.debug_tuple("DbDataType::Uint8").finish() + } + DbDataType::Uint16 => { + f.debug_tuple("DbDataType::Uint16").finish() + } + DbDataType::Uint32 => { + f.debug_tuple("DbDataType::Uint32").finish() + } + DbDataType::Uint64 => { + f.debug_tuple("DbDataType::Uint64").finish() + } DbDataType::Floating32 => { f.debug_tuple("DbDataType::Floating32").finish() } @@ -11560,19 +12311,21 @@ pub mod exports { f.debug_tuple("DbDataType::Floating64").finish() } DbDataType::Str => f.debug_tuple("DbDataType::Str").finish(), - DbDataType::Binary => f.debug_tuple("DbDataType::Binary").finish(), - DbDataType::Other => f.debug_tuple("DbDataType::Other").finish(), + DbDataType::Binary => { + f.debug_tuple("DbDataType::Binary").finish() + } + DbDataType::Other => { + f.debug_tuple("DbDataType::Other").finish() + } } } } - impl DbDataType { #[doc(hidden)] pub unsafe fn _lift(val: u8) -> DbDataType { if !cfg!(debug_assertions) { return ::core::mem::transmute(val); } - match val { 0 => DbDataType::Boolean, 1 => DbDataType::Int8, @@ -11588,12 +12341,10 @@ pub mod exports { 11 => DbDataType::Str, 12 => DbDataType::Binary, 13 => DbDataType::Other, - _ => panic!("invalid enum discriminant"), } } } - /// Database values #[derive(Clone)] pub enum DbValue { @@ -11614,16 +12365,29 @@ pub mod exports { Unsupported, } impl ::core::fmt::Debug for DbValue { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { DbValue::Boolean(e) => { f.debug_tuple("DbValue::Boolean").field(e).finish() } - DbValue::Int8(e) => f.debug_tuple("DbValue::Int8").field(e).finish(), - DbValue::Int16(e) => f.debug_tuple("DbValue::Int16").field(e).finish(), - DbValue::Int32(e) => f.debug_tuple("DbValue::Int32").field(e).finish(), - DbValue::Int64(e) => f.debug_tuple("DbValue::Int64").field(e).finish(), - DbValue::Uint8(e) => f.debug_tuple("DbValue::Uint8").field(e).finish(), + DbValue::Int8(e) => { + f.debug_tuple("DbValue::Int8").field(e).finish() + } + DbValue::Int16(e) => { + f.debug_tuple("DbValue::Int16").field(e).finish() + } + DbValue::Int32(e) => { + f.debug_tuple("DbValue::Int32").field(e).finish() + } + DbValue::Int64(e) => { + f.debug_tuple("DbValue::Int64").field(e).finish() + } + DbValue::Uint8(e) => { + f.debug_tuple("DbValue::Uint8").field(e).finish() + } DbValue::Uint16(e) => { f.debug_tuple("DbValue::Uint16").field(e).finish() } @@ -11639,12 +12403,16 @@ pub mod exports { DbValue::Floating64(e) => { f.debug_tuple("DbValue::Floating64").field(e).finish() } - DbValue::Str(e) => f.debug_tuple("DbValue::Str").field(e).finish(), + DbValue::Str(e) => { + f.debug_tuple("DbValue::Str").field(e).finish() + } DbValue::Binary(e) => { f.debug_tuple("DbValue::Binary").field(e).finish() } DbValue::DbNull => f.debug_tuple("DbValue::DbNull").finish(), - DbValue::Unsupported => f.debug_tuple("DbValue::Unsupported").finish(), + DbValue::Unsupported => { + f.debug_tuple("DbValue::Unsupported").finish() + } } } } @@ -11667,7 +12435,10 @@ pub mod exports { DbNull, } impl ::core::fmt::Debug for ParameterValue { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { ParameterValue::Boolean(e) => { f.debug_tuple("ParameterValue::Boolean").field(e).finish() @@ -11696,14 +12467,16 @@ pub mod exports { ParameterValue::Uint64(e) => { f.debug_tuple("ParameterValue::Uint64").field(e).finish() } - ParameterValue::Floating32(e) => f - .debug_tuple("ParameterValue::Floating32") - .field(e) - .finish(), - ParameterValue::Floating64(e) => f - .debug_tuple("ParameterValue::Floating64") - .field(e) - .finish(), + ParameterValue::Floating32(e) => { + f.debug_tuple("ParameterValue::Floating32") + .field(e) + .finish() + } + ParameterValue::Floating64(e) => { + f.debug_tuple("ParameterValue::Floating64") + .field(e) + .finish() + } ParameterValue::Str(e) => { f.debug_tuple("ParameterValue::Str").field(e).finish() } @@ -11723,7 +12496,10 @@ pub mod exports { pub data_type: DbDataType, } impl ::core::fmt::Debug for Column { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("Column") .field("name", &self.name) .field("data-type", &self.data_type) @@ -11739,7 +12515,10 @@ pub mod exports { pub rows: _rt::Vec, } impl ::core::fmt::Debug for RowSet { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("RowSet") .field("columns", &self.columns) .field("rows", &self.rows) @@ -11747,40 +12526,30 @@ pub mod exports { } } #[doc(hidden)] - macro_rules! __export_fermyon_spin_rdbms_types_2_0_0_cabi { ($ty:ident with_types_in $($path_to_types:tt)*) => { - const _: () = {}; + const _ : () = {}; }; } #[doc(hidden)] pub(crate) use __export_fermyon_spin_rdbms_types_2_0_0_cabi; } - #[allow(dead_code, clippy::all)] pub mod postgres { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; - pub type ParameterValue = - super::super::super::super::exports::fermyon::spin::rdbms_types::ParameterValue; - pub type RowSet = - super::super::super::super::exports::fermyon::spin::rdbms_types::RowSet; - pub type Error = - super::super::super::super::exports::fermyon::spin::rdbms_types::Error; + pub type ParameterValue = super::super::super::super::exports::fermyon::spin::rdbms_types::ParameterValue; + pub type RowSet = super::super::super::super::exports::fermyon::spin::rdbms_types::RowSet; + pub type Error = super::super::super::super::exports::fermyon::spin::rdbms_types::Error; /// A connection to a postgres database. - #[derive(Debug)] #[repr(transparent)] pub struct Connection { handle: _rt::Resource, } - type _ConnectionRep = Option; - impl Connection { /// Creates a new resource from the specified representation. /// @@ -11790,77 +12559,68 @@ pub mod exports { pub fn new(val: T) -> Self { Self::type_guard::(); let val: _ConnectionRep = Some(val); - let ptr: *mut _ConnectionRep = _rt::Box::into_raw(_rt::Box::new(val)); + let ptr: *mut _ConnectionRep = _rt::Box::into_raw( + _rt::Box::new(val), + ); unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } } - /// Gets access to the underlying `T` which represents this resource. pub fn get(&self) -> &T { let ptr = unsafe { &*self.as_ptr::() }; ptr.as_ref().unwrap() } - /// Gets mutable access to the underlying `T` which represents this /// resource. pub fn get_mut(&mut self) -> &mut T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_mut().unwrap() } - /// Consumes this resource and returns the underlying `T`. pub fn into_inner(self) -> T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.take().unwrap() } - #[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) } - - // It's theoretically possible to implement the `GuestConnection` trait twice - // so guard against using it with two different types here. #[doc(hidden)] fn type_guard() { use core::any::TypeId; static mut LAST_TYPE: Option = None; unsafe { - assert!(!cfg!(target_feature = "threads")); + assert!(! cfg!(target_feature = "atomics")); let id = TypeId::of::(); match LAST_TYPE { - Some(ty) => assert!( - ty == id, - "cannot use two types with this resource type" - ), + Some(ty) => { + assert!( + ty == id, "cannot use two types with this resource type" + ) + } None => LAST_TYPE = Some(id), } } } - #[doc(hidden)] pub unsafe fn dtor(handle: *mut u8) { Self::type_guard::(); let _ = _rt::Box::from_raw(handle as *mut _ConnectionRep); } - fn as_ptr(&self) -> *mut _ConnectionRep { Connection::type_guard::(); T::_resource_rep(self.handle()).cast() } } - /// A borrowed version of [`Connection`] which represents a borrowed value /// with the lifetime `'a`. #[derive(Debug)] @@ -11869,7 +12629,6 @@ pub mod exports { rep: *mut u8, _marker: core::marker::PhantomData<&'a Connection>, } - impl<'a> ConnectionBorrow<'a> { #[doc(hidden)] pub unsafe fn lift(rep: usize) -> Self { @@ -11878,49 +12637,41 @@ pub mod exports { _marker: core::marker::PhantomData, } } - /// Gets access to the underlying `T` in this resource. pub fn get(&self) -> &T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_ref().unwrap() } - - // NB: mutable access is not allowed due to the component model allowing - // multiple borrows of the same resource. - fn as_ptr(&self) -> *mut _ConnectionRep { Connection::type_guard::(); self.rep.cast() } } - unsafe impl _rt::WasmResource for Connection { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/postgres@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/postgres@2.0.0" + )] extern "C" { #[link_name = "[resource-drop]connection"] fn drop(_: u32); } - drop(_handle); } } } - #[doc(hidden)] #[allow(non_snake_case)] pub unsafe fn _export_static_connection_open_cabi( arg0: *mut u8, arg1: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg1; let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); let result1 = T::open(_rt::string_lift(bytes0)); @@ -11991,7 +12742,7 @@ pub mod exports { ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { @@ -12033,8 +12784,7 @@ pub mod exports { arg3: *mut u8, arg4: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let base20 = arg3; @@ -12049,7 +12799,6 @@ pub mod exports { 0 => { let e19 = { let l2 = i32::from(*base.add(8).cast::()); - _rt::bool_lift(l2 as u8) }; V19::Boolean(e19) @@ -12057,7 +12806,6 @@ pub mod exports { 1 => { let e19 = { let l3 = i32::from(*base.add(8).cast::()); - l3 as i8 }; V19::Int8(e19) @@ -12065,7 +12813,6 @@ pub mod exports { 2 => { let e19 = { let l4 = i32::from(*base.add(8).cast::()); - l4 as i16 }; V19::Int16(e19) @@ -12073,7 +12820,6 @@ pub mod exports { 3 => { let e19 = { let l5 = *base.add(8).cast::(); - l5 }; V19::Int32(e19) @@ -12081,7 +12827,6 @@ pub mod exports { 4 => { let e19 = { let l6 = *base.add(8).cast::(); - l6 }; V19::Int64(e19) @@ -12089,7 +12834,6 @@ pub mod exports { 5 => { let e19 = { let l7 = i32::from(*base.add(8).cast::()); - l7 as u8 }; V19::Uint8(e19) @@ -12097,7 +12841,6 @@ pub mod exports { 6 => { let e19 = { let l8 = i32::from(*base.add(8).cast::()); - l8 as u16 }; V19::Uint16(e19) @@ -12105,7 +12848,6 @@ pub mod exports { 7 => { let e19 = { let l9 = *base.add(8).cast::(); - l9 as u32 }; V19::Uint32(e19) @@ -12113,7 +12855,6 @@ pub mod exports { 8 => { let e19 = { let l10 = *base.add(8).cast::(); - l10 as u64 }; V19::Uint64(e19) @@ -12121,7 +12862,6 @@ pub mod exports { 9 => { let e19 = { let l11 = *base.add(8).cast::(); - l11 }; V19::Floating32(e19) @@ -12129,7 +12869,6 @@ pub mod exports { 10 => { let e19 = { let l12 = *base.add(8).cast::(); - l12 }; V19::Floating64(e19) @@ -12139,9 +12878,11 @@ pub mod exports { let l13 = *base.add(8).cast::<*mut u8>(); let l14 = *base.add(12).cast::(); let len15 = l14; - let bytes15 = - _rt::Vec::from_raw_parts(l13.cast(), len15, len15); - + let bytes15 = _rt::Vec::from_raw_parts( + l13.cast(), + len15, + len15, + ); _rt::string_lift(bytes15) }; V19::Str(e19) @@ -12151,7 +12892,6 @@ pub mod exports { let l16 = *base.add(8).cast::<*mut u8>(); let l17 = *base.add(12).cast::(); let len18 = l17; - _rt::Vec::from_raw_parts(l16.cast(), len18, len18) }; V19::Binary(e19) @@ -12161,7 +12901,6 @@ pub mod exports { V19::DbNull } }; - v19 }; result20.push(e20); @@ -12176,11 +12915,16 @@ pub mod exports { match result21 { Ok(e) => { *ptr22.add(0).cast::() = (0i32) as u8; - let super::super::super::super::exports::fermyon::spin::rdbms_types::RowSet{ columns:columns23, rows:rows23, } = e; + let super::super::super::super::exports::fermyon::spin::rdbms_types::RowSet { + columns: columns23, + rows: rows23, + } = e; let vec26 = columns23; let len26 = vec26.len(); - let layout26 = - _rt::alloc::Layout::from_size_align_unchecked(vec26.len() * 12, 4); + let layout26 = _rt::alloc::Layout::from_size_align_unchecked( + vec26.len() * 12, + 4, + ); let result26 = if layout26.size() != 0 { let ptr = _rt::alloc::alloc(layout26).cast::(); if ptr.is_null() { @@ -12188,29 +12932,33 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec26.into_iter().enumerate() { let base = result26.add(i * 12); { - let super::super::super::super::exports::fermyon::spin::rdbms_types::Column{ name:name24, data_type:data_type24, } = e; + let super::super::super::super::exports::fermyon::spin::rdbms_types::Column { + name: name24, + data_type: data_type24, + } = e; let vec25 = (name24.into_bytes()).into_boxed_slice(); let ptr25 = vec25.as_ptr().cast::(); let len25 = vec25.len(); ::core::mem::forget(vec25); *base.add(4).cast::() = len25; *base.add(0).cast::<*mut u8>() = ptr25.cast_mut(); - *base.add(8).cast::() = (data_type24.clone() as i32) as u8; + *base.add(8).cast::() = (data_type24.clone() as i32) + as u8; } } *ptr22.add(8).cast::() = len26; *ptr22.add(4).cast::<*mut u8>() = result26; let vec31 = rows23; let len31 = vec31.len(); - let layout31 = - _rt::alloc::Layout::from_size_align_unchecked(vec31.len() * 8, 4); + let layout31 = _rt::alloc::Layout::from_size_align_unchecked( + vec31.len() * 8, + 4, + ); let result31 = if layout31.size() != 0 { let ptr = _rt::alloc::alloc(layout31).cast::(); if ptr.is_null() { @@ -12218,9 +12966,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec31.into_iter().enumerate() { let base = result31.add(i * 8); @@ -12238,9 +12984,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec30.into_iter().enumerate() { let base = result30.add(i * 16); @@ -12252,18 +12996,15 @@ pub mod exports { *base.add(8).cast::() = (match e { true => 1, false => 0, - }) - as u8; + }) as u8; } V29::Int8(e) => { *base.add(0).cast::() = (1i32) as u8; - *base.add(8).cast::() = - (_rt::as_i32(e)) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; } V29::Int16(e) => { *base.add(0).cast::() = (2i32) as u8; - *base.add(8).cast::() = - (_rt::as_i32(e)) as u16; + *base.add(8).cast::() = (_rt::as_i32(e)) as u16; } V29::Int32(e) => { *base.add(0).cast::() = (3i32) as u8; @@ -12275,13 +13016,11 @@ pub mod exports { } V29::Uint8(e) => { *base.add(0).cast::() = (5i32) as u8; - *base.add(8).cast::() = - (_rt::as_i32(e)) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; } V29::Uint16(e) => { *base.add(0).cast::() = (6i32) as u8; - *base.add(8).cast::() = - (_rt::as_i32(e)) as u16; + *base.add(8).cast::() = (_rt::as_i32(e)) as u16; } V29::Uint32(e) => { *base.add(0).cast::() = (7i32) as u8; @@ -12306,8 +13045,7 @@ pub mod exports { let len27 = vec27.len(); ::core::mem::forget(vec27); *base.add(12).cast::() = len27; - *base.add(8).cast::<*mut u8>() = - ptr27.cast_mut(); + *base.add(8).cast::<*mut u8>() = ptr27.cast_mut(); } V29::Binary(e) => { *base.add(0).cast::() = (12i32) as u8; @@ -12316,8 +13054,7 @@ pub mod exports { let len28 = vec28.len(); ::core::mem::forget(vec28); *base.add(12).cast::() = len28; - *base.add(8).cast::<*mut u8>() = - ptr28.cast_mut(); + *base.add(8).cast::<*mut u8>() = ptr28.cast_mut(); } V29::DbNull => { *base.add(0).cast::() = (13i32) as u8; @@ -12397,64 +13134,64 @@ pub mod exports { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { 0 => { - let l3 = *arg0.add(4).cast::<*mut u8>(); - let l4 = *arg0.add(8).cast::(); - let base5 = l3; - let len5 = l4; + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + let base5 = l1; + let len5 = l2; for i in 0..len5 { let base = base5.add(i * 12); { - let l1 = *base.add(0).cast::<*mut u8>(); - let l2 = *base.add(4).cast::(); - _rt::cabi_dealloc(l1, l2, 1); + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + _rt::cabi_dealloc(l3, l4, 1); } } _rt::cabi_dealloc(base5, len5 * 12, 4); - let l15 = *arg0.add(12).cast::<*mut u8>(); - let l16 = *arg0.add(16).cast::(); - let base17 = l15; - let len17 = l16; + let l6 = *arg0.add(12).cast::<*mut u8>(); + let l7 = *arg0.add(16).cast::(); + let base17 = l6; + let len17 = l7; for i in 0..len17 { let base = base17.add(i * 8); { - let l12 = *base.add(0).cast::<*mut u8>(); - let l13 = *base.add(4).cast::(); - let base14 = l12; - let len14 = l13; - for i in 0..len14 { - let base = base14.add(i * 16); + let l8 = *base.add(0).cast::<*mut u8>(); + let l9 = *base.add(4).cast::(); + let base16 = l8; + let len16 = l9; + for i in 0..len16 { + let base = base16.add(i * 16); { - let l6 = i32::from(*base.add(0).cast::()); - match l6 { - 0 => (), - 1 => (), - 2 => (), - 3 => (), - 4 => (), - 5 => (), - 6 => (), - 7 => (), - 8 => (), - 9 => (), - 10 => (), + let l10 = i32::from(*base.add(0).cast::()); + match l10 { + 0 => {} + 1 => {} + 2 => {} + 3 => {} + 4 => {} + 5 => {} + 6 => {} + 7 => {} + 8 => {} + 9 => {} + 10 => {} 11 => { - let l7 = *base.add(8).cast::<*mut u8>(); - let l8 = *base.add(12).cast::(); - _rt::cabi_dealloc(l7, l8, 1); + let l11 = *base.add(8).cast::<*mut u8>(); + let l12 = *base.add(12).cast::(); + _rt::cabi_dealloc(l11, l12, 1); } 12 => { - let l9 = *base.add(8).cast::<*mut u8>(); - let l10 = *base.add(12).cast::(); - let base11 = l9; - let len11 = l10; - _rt::cabi_dealloc(base11, len11 * 1, 1); + let l13 = *base.add(8).cast::<*mut u8>(); + let l14 = *base.add(12).cast::(); + let base15 = l13; + let len15 = l14; + _rt::cabi_dealloc(base15, len15 * 1, 1); } - 13 => (), - _ => (), + 13 => {} + _ => {} } } } - _rt::cabi_dealloc(base14, len14 * 16, 8); + _rt::cabi_dealloc(base16, len16 * 16, 8); } } _rt::cabi_dealloc(base17, len17 * 8, 4); @@ -12500,8 +13237,7 @@ pub mod exports { arg3: *mut u8, arg4: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let base20 = arg3; @@ -12516,7 +13252,6 @@ pub mod exports { 0 => { let e19 = { let l2 = i32::from(*base.add(8).cast::()); - _rt::bool_lift(l2 as u8) }; V19::Boolean(e19) @@ -12524,7 +13259,6 @@ pub mod exports { 1 => { let e19 = { let l3 = i32::from(*base.add(8).cast::()); - l3 as i8 }; V19::Int8(e19) @@ -12532,7 +13266,6 @@ pub mod exports { 2 => { let e19 = { let l4 = i32::from(*base.add(8).cast::()); - l4 as i16 }; V19::Int16(e19) @@ -12540,7 +13273,6 @@ pub mod exports { 3 => { let e19 = { let l5 = *base.add(8).cast::(); - l5 }; V19::Int32(e19) @@ -12548,7 +13280,6 @@ pub mod exports { 4 => { let e19 = { let l6 = *base.add(8).cast::(); - l6 }; V19::Int64(e19) @@ -12556,7 +13287,6 @@ pub mod exports { 5 => { let e19 = { let l7 = i32::from(*base.add(8).cast::()); - l7 as u8 }; V19::Uint8(e19) @@ -12564,7 +13294,6 @@ pub mod exports { 6 => { let e19 = { let l8 = i32::from(*base.add(8).cast::()); - l8 as u16 }; V19::Uint16(e19) @@ -12572,7 +13301,6 @@ pub mod exports { 7 => { let e19 = { let l9 = *base.add(8).cast::(); - l9 as u32 }; V19::Uint32(e19) @@ -12580,7 +13308,6 @@ pub mod exports { 8 => { let e19 = { let l10 = *base.add(8).cast::(); - l10 as u64 }; V19::Uint64(e19) @@ -12588,7 +13315,6 @@ pub mod exports { 9 => { let e19 = { let l11 = *base.add(8).cast::(); - l11 }; V19::Floating32(e19) @@ -12596,7 +13322,6 @@ pub mod exports { 10 => { let e19 = { let l12 = *base.add(8).cast::(); - l12 }; V19::Floating64(e19) @@ -12606,9 +13331,11 @@ pub mod exports { let l13 = *base.add(8).cast::<*mut u8>(); let l14 = *base.add(12).cast::(); let len15 = l14; - let bytes15 = - _rt::Vec::from_raw_parts(l13.cast(), len15, len15); - + let bytes15 = _rt::Vec::from_raw_parts( + l13.cast(), + len15, + len15, + ); _rt::string_lift(bytes15) }; V19::Str(e19) @@ -12618,7 +13345,6 @@ pub mod exports { let l16 = *base.add(8).cast::<*mut u8>(); let l17 = *base.add(12).cast::(); let len18 = l17; - _rt::Vec::from_raw_parts(l16.cast(), len18, len18) }; V19::Binary(e19) @@ -12628,7 +13354,6 @@ pub mod exports { V19::DbNull } }; - v19 }; result20.push(e20); @@ -12701,12 +13426,12 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_method_connection_execute( - arg0: *mut u8, - ) { + pub unsafe fn __post_return_method_connection_execute< + T: GuestConnection, + >(arg0: *mut u8) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(8).cast::()); match l1 { @@ -12753,10 +13478,11 @@ pub mod exports { let _ = val; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/postgres@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/postgres@2.0.0" + )] extern "C" { #[link_name = "[resource-new]connection"] fn new(_: *mut u8) -> u32; @@ -12764,7 +13490,6 @@ pub mod exports { new(val) } } - #[doc(hidden)] fn _resource_rep(handle: u32) -> *mut u8 where @@ -12775,10 +13500,11 @@ pub mod exports { let _ = handle; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/postgres@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/postgres@2.0.0" + )] extern "C" { #[link_name = "[resource-rep]connection"] fn rep(_: u32) -> *mut u8; @@ -12786,7 +13512,6 @@ pub mod exports { unsafe { rep(handle) } } } - /// Open a connection to the Postgres instance at `address`. fn open(address: _rt::String) -> Result; /// Query the database. @@ -12803,79 +13528,75 @@ pub mod exports { ) -> Result; } #[doc(hidden)] - - macro_rules! __export_fermyon_spin_postgres_2_0_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "fermyon:spin/postgres@2.0.0#[static]connection.open"] - unsafe extern "C" fn export_static_connection_open(arg0: *mut u8,arg1: usize,) -> *mut u8 { - $($path_to_types)*::_export_static_connection_open_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1) - } - #[export_name = "cabi_post_fermyon:spin/postgres@2.0.0#[static]connection.open"] - unsafe extern "C" fn _post_return_static_connection_open(arg0: *mut u8,) { - $($path_to_types)*::__post_return_static_connection_open::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/postgres@2.0.0#[method]connection.query"] - unsafe extern "C" fn export_method_connection_query(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_query_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2, arg3, arg4) - } - #[export_name = "cabi_post_fermyon:spin/postgres@2.0.0#[method]connection.query"] - unsafe extern "C" fn _post_return_method_connection_query(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_query::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/postgres@2.0.0#[method]connection.execute"] - unsafe extern "C" fn export_method_connection_execute(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_execute_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2, arg3, arg4) - } - #[export_name = "cabi_post_fermyon:spin/postgres@2.0.0#[method]connection.execute"] - unsafe extern "C" fn _post_return_method_connection_execute(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_execute::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - - const _: () = { - #[doc(hidden)] - #[export_name = "fermyon:spin/postgres@2.0.0#[dtor]connection"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: *mut u8) { - $($path_to_types)*::Connection::dtor::< - <$ty as $($path_to_types)*::Guest>::Connection - >(rep) - } - }; - - };); -} + macro_rules! __export_fermyon_spin_postgres_2_0_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "fermyon:spin/postgres@2.0.0#[static]connection.open"] unsafe + extern "C" fn export_static_connection_open(arg0 : * mut u8, arg1 + : usize,) -> * mut u8 { $($path_to_types)*:: + _export_static_connection_open_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1) } + #[export_name = + "cabi_post_fermyon:spin/postgres@2.0.0#[static]connection.open"] + unsafe extern "C" fn _post_return_static_connection_open(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_static_connection_open::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/postgres@2.0.0#[method]connection.query"] unsafe + extern "C" fn export_method_connection_query(arg0 : * mut u8, + arg1 : * mut u8, arg2 : usize, arg3 : * mut u8, arg4 : usize,) -> + * mut u8 { $($path_to_types)*:: + _export_method_connection_query_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1, arg2, + arg3, arg4) } #[export_name = + "cabi_post_fermyon:spin/postgres@2.0.0#[method]connection.query"] + unsafe extern "C" fn _post_return_method_connection_query(arg0 : + * mut u8,) { $($path_to_types)*:: + __post_return_method_connection_query::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/postgres@2.0.0#[method]connection.execute"] + unsafe extern "C" fn export_method_connection_execute(arg0 : * + mut u8, arg1 : * mut u8, arg2 : usize, arg3 : * mut u8, arg4 : + usize,) -> * mut u8 { $($path_to_types)*:: + _export_method_connection_execute_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1, arg2, + arg3, arg4) } #[export_name = + "cabi_post_fermyon:spin/postgres@2.0.0#[method]connection.execute"] + unsafe extern "C" fn _post_return_method_connection_execute(arg0 + : * mut u8,) { $($path_to_types)*:: + __post_return_method_connection_execute::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } const _ : () + = { #[doc(hidden)] #[export_name = + "fermyon:spin/postgres@2.0.0#[dtor]connection"] + #[allow(non_snake_case)] unsafe extern "C" fn dtor(rep : * mut + u8) { $($path_to_types)*:: Connection::dtor::< <$ty as + $($path_to_types)*:: Guest >::Connection > (rep) } }; }; + }; + } #[doc(hidden)] pub(crate) use __export_fermyon_spin_postgres_2_0_0_cabi; #[repr(align(8))] struct _RetArea([::core::mem::MaybeUninit; 24]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 24]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 24], + ); } - #[allow(dead_code, clippy::all)] pub mod mysql { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; - pub type ParameterValue = - super::super::super::super::exports::fermyon::spin::rdbms_types::ParameterValue; - pub type RowSet = - super::super::super::super::exports::fermyon::spin::rdbms_types::RowSet; - pub type Error = - super::super::super::super::exports::fermyon::spin::rdbms_types::Error; + pub type ParameterValue = super::super::super::super::exports::fermyon::spin::rdbms_types::ParameterValue; + pub type RowSet = super::super::super::super::exports::fermyon::spin::rdbms_types::RowSet; + pub type Error = super::super::super::super::exports::fermyon::spin::rdbms_types::Error; /// A connection to a MySQL database. - #[derive(Debug)] #[repr(transparent)] pub struct Connection { handle: _rt::Resource, } - type _ConnectionRep = Option; - impl Connection { /// Creates a new resource from the specified representation. /// @@ -12885,77 +13606,68 @@ pub mod exports { pub fn new(val: T) -> Self { Self::type_guard::(); let val: _ConnectionRep = Some(val); - let ptr: *mut _ConnectionRep = _rt::Box::into_raw(_rt::Box::new(val)); + let ptr: *mut _ConnectionRep = _rt::Box::into_raw( + _rt::Box::new(val), + ); unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } } - /// Gets access to the underlying `T` which represents this resource. pub fn get(&self) -> &T { let ptr = unsafe { &*self.as_ptr::() }; ptr.as_ref().unwrap() } - /// Gets mutable access to the underlying `T` which represents this /// resource. pub fn get_mut(&mut self) -> &mut T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_mut().unwrap() } - /// Consumes this resource and returns the underlying `T`. pub fn into_inner(self) -> T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.take().unwrap() } - #[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) } - - // It's theoretically possible to implement the `GuestConnection` trait twice - // so guard against using it with two different types here. #[doc(hidden)] fn type_guard() { use core::any::TypeId; static mut LAST_TYPE: Option = None; unsafe { - assert!(!cfg!(target_feature = "threads")); + assert!(! cfg!(target_feature = "atomics")); let id = TypeId::of::(); match LAST_TYPE { - Some(ty) => assert!( - ty == id, - "cannot use two types with this resource type" - ), + Some(ty) => { + assert!( + ty == id, "cannot use two types with this resource type" + ) + } None => LAST_TYPE = Some(id), } } } - #[doc(hidden)] pub unsafe fn dtor(handle: *mut u8) { Self::type_guard::(); let _ = _rt::Box::from_raw(handle as *mut _ConnectionRep); } - fn as_ptr(&self) -> *mut _ConnectionRep { Connection::type_guard::(); T::_resource_rep(self.handle()).cast() } } - /// A borrowed version of [`Connection`] which represents a borrowed value /// with the lifetime `'a`. #[derive(Debug)] @@ -12964,7 +13676,6 @@ pub mod exports { rep: *mut u8, _marker: core::marker::PhantomData<&'a Connection>, } - impl<'a> ConnectionBorrow<'a> { #[doc(hidden)] pub unsafe fn lift(rep: usize) -> Self { @@ -12973,49 +13684,41 @@ pub mod exports { _marker: core::marker::PhantomData, } } - /// Gets access to the underlying `T` in this resource. pub fn get(&self) -> &T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_ref().unwrap() } - - // NB: mutable access is not allowed due to the component model allowing - // multiple borrows of the same resource. - fn as_ptr(&self) -> *mut _ConnectionRep { Connection::type_guard::(); self.rep.cast() } } - unsafe impl _rt::WasmResource for Connection { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/mysql@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/mysql@2.0.0" + )] extern "C" { #[link_name = "[resource-drop]connection"] fn drop(_: u32); } - drop(_handle); } } } - #[doc(hidden)] #[allow(non_snake_case)] pub unsafe fn _export_static_connection_open_cabi( arg0: *mut u8, arg1: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg1; let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); let result1 = T::open(_rt::string_lift(bytes0)); @@ -13086,7 +13789,7 @@ pub mod exports { ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { @@ -13128,8 +13831,7 @@ pub mod exports { arg3: *mut u8, arg4: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let base20 = arg3; @@ -13144,7 +13846,6 @@ pub mod exports { 0 => { let e19 = { let l2 = i32::from(*base.add(8).cast::()); - _rt::bool_lift(l2 as u8) }; V19::Boolean(e19) @@ -13152,7 +13853,6 @@ pub mod exports { 1 => { let e19 = { let l3 = i32::from(*base.add(8).cast::()); - l3 as i8 }; V19::Int8(e19) @@ -13160,7 +13860,6 @@ pub mod exports { 2 => { let e19 = { let l4 = i32::from(*base.add(8).cast::()); - l4 as i16 }; V19::Int16(e19) @@ -13168,7 +13867,6 @@ pub mod exports { 3 => { let e19 = { let l5 = *base.add(8).cast::(); - l5 }; V19::Int32(e19) @@ -13176,7 +13874,6 @@ pub mod exports { 4 => { let e19 = { let l6 = *base.add(8).cast::(); - l6 }; V19::Int64(e19) @@ -13184,7 +13881,6 @@ pub mod exports { 5 => { let e19 = { let l7 = i32::from(*base.add(8).cast::()); - l7 as u8 }; V19::Uint8(e19) @@ -13192,7 +13888,6 @@ pub mod exports { 6 => { let e19 = { let l8 = i32::from(*base.add(8).cast::()); - l8 as u16 }; V19::Uint16(e19) @@ -13200,7 +13895,6 @@ pub mod exports { 7 => { let e19 = { let l9 = *base.add(8).cast::(); - l9 as u32 }; V19::Uint32(e19) @@ -13208,7 +13902,6 @@ pub mod exports { 8 => { let e19 = { let l10 = *base.add(8).cast::(); - l10 as u64 }; V19::Uint64(e19) @@ -13216,7 +13909,6 @@ pub mod exports { 9 => { let e19 = { let l11 = *base.add(8).cast::(); - l11 }; V19::Floating32(e19) @@ -13224,7 +13916,6 @@ pub mod exports { 10 => { let e19 = { let l12 = *base.add(8).cast::(); - l12 }; V19::Floating64(e19) @@ -13234,9 +13925,11 @@ pub mod exports { let l13 = *base.add(8).cast::<*mut u8>(); let l14 = *base.add(12).cast::(); let len15 = l14; - let bytes15 = - _rt::Vec::from_raw_parts(l13.cast(), len15, len15); - + let bytes15 = _rt::Vec::from_raw_parts( + l13.cast(), + len15, + len15, + ); _rt::string_lift(bytes15) }; V19::Str(e19) @@ -13246,7 +13939,6 @@ pub mod exports { let l16 = *base.add(8).cast::<*mut u8>(); let l17 = *base.add(12).cast::(); let len18 = l17; - _rt::Vec::from_raw_parts(l16.cast(), len18, len18) }; V19::Binary(e19) @@ -13256,7 +13948,6 @@ pub mod exports { V19::DbNull } }; - v19 }; result20.push(e20); @@ -13271,11 +13962,16 @@ pub mod exports { match result21 { Ok(e) => { *ptr22.add(0).cast::() = (0i32) as u8; - let super::super::super::super::exports::fermyon::spin::rdbms_types::RowSet{ columns:columns23, rows:rows23, } = e; + let super::super::super::super::exports::fermyon::spin::rdbms_types::RowSet { + columns: columns23, + rows: rows23, + } = e; let vec26 = columns23; let len26 = vec26.len(); - let layout26 = - _rt::alloc::Layout::from_size_align_unchecked(vec26.len() * 12, 4); + let layout26 = _rt::alloc::Layout::from_size_align_unchecked( + vec26.len() * 12, + 4, + ); let result26 = if layout26.size() != 0 { let ptr = _rt::alloc::alloc(layout26).cast::(); if ptr.is_null() { @@ -13283,29 +13979,33 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec26.into_iter().enumerate() { let base = result26.add(i * 12); { - let super::super::super::super::exports::fermyon::spin::rdbms_types::Column{ name:name24, data_type:data_type24, } = e; + let super::super::super::super::exports::fermyon::spin::rdbms_types::Column { + name: name24, + data_type: data_type24, + } = e; let vec25 = (name24.into_bytes()).into_boxed_slice(); let ptr25 = vec25.as_ptr().cast::(); let len25 = vec25.len(); ::core::mem::forget(vec25); *base.add(4).cast::() = len25; *base.add(0).cast::<*mut u8>() = ptr25.cast_mut(); - *base.add(8).cast::() = (data_type24.clone() as i32) as u8; + *base.add(8).cast::() = (data_type24.clone() as i32) + as u8; } } *ptr22.add(8).cast::() = len26; *ptr22.add(4).cast::<*mut u8>() = result26; let vec31 = rows23; let len31 = vec31.len(); - let layout31 = - _rt::alloc::Layout::from_size_align_unchecked(vec31.len() * 8, 4); + let layout31 = _rt::alloc::Layout::from_size_align_unchecked( + vec31.len() * 8, + 4, + ); let result31 = if layout31.size() != 0 { let ptr = _rt::alloc::alloc(layout31).cast::(); if ptr.is_null() { @@ -13313,9 +14013,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec31.into_iter().enumerate() { let base = result31.add(i * 8); @@ -13333,9 +14031,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec30.into_iter().enumerate() { let base = result30.add(i * 16); @@ -13347,18 +14043,15 @@ pub mod exports { *base.add(8).cast::() = (match e { true => 1, false => 0, - }) - as u8; + }) as u8; } V29::Int8(e) => { *base.add(0).cast::() = (1i32) as u8; - *base.add(8).cast::() = - (_rt::as_i32(e)) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; } V29::Int16(e) => { *base.add(0).cast::() = (2i32) as u8; - *base.add(8).cast::() = - (_rt::as_i32(e)) as u16; + *base.add(8).cast::() = (_rt::as_i32(e)) as u16; } V29::Int32(e) => { *base.add(0).cast::() = (3i32) as u8; @@ -13370,13 +14063,11 @@ pub mod exports { } V29::Uint8(e) => { *base.add(0).cast::() = (5i32) as u8; - *base.add(8).cast::() = - (_rt::as_i32(e)) as u8; + *base.add(8).cast::() = (_rt::as_i32(e)) as u8; } V29::Uint16(e) => { *base.add(0).cast::() = (6i32) as u8; - *base.add(8).cast::() = - (_rt::as_i32(e)) as u16; + *base.add(8).cast::() = (_rt::as_i32(e)) as u16; } V29::Uint32(e) => { *base.add(0).cast::() = (7i32) as u8; @@ -13401,8 +14092,7 @@ pub mod exports { let len27 = vec27.len(); ::core::mem::forget(vec27); *base.add(12).cast::() = len27; - *base.add(8).cast::<*mut u8>() = - ptr27.cast_mut(); + *base.add(8).cast::<*mut u8>() = ptr27.cast_mut(); } V29::Binary(e) => { *base.add(0).cast::() = (12i32) as u8; @@ -13411,8 +14101,7 @@ pub mod exports { let len28 = vec28.len(); ::core::mem::forget(vec28); *base.add(12).cast::() = len28; - *base.add(8).cast::<*mut u8>() = - ptr28.cast_mut(); + *base.add(8).cast::<*mut u8>() = ptr28.cast_mut(); } V29::DbNull => { *base.add(0).cast::() = (13i32) as u8; @@ -13492,64 +14181,64 @@ pub mod exports { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { 0 => { - let l3 = *arg0.add(4).cast::<*mut u8>(); - let l4 = *arg0.add(8).cast::(); - let base5 = l3; - let len5 = l4; + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + let base5 = l1; + let len5 = l2; for i in 0..len5 { let base = base5.add(i * 12); { - let l1 = *base.add(0).cast::<*mut u8>(); - let l2 = *base.add(4).cast::(); - _rt::cabi_dealloc(l1, l2, 1); + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + _rt::cabi_dealloc(l3, l4, 1); } } _rt::cabi_dealloc(base5, len5 * 12, 4); - let l15 = *arg0.add(12).cast::<*mut u8>(); - let l16 = *arg0.add(16).cast::(); - let base17 = l15; - let len17 = l16; + let l6 = *arg0.add(12).cast::<*mut u8>(); + let l7 = *arg0.add(16).cast::(); + let base17 = l6; + let len17 = l7; for i in 0..len17 { let base = base17.add(i * 8); { - let l12 = *base.add(0).cast::<*mut u8>(); - let l13 = *base.add(4).cast::(); - let base14 = l12; - let len14 = l13; - for i in 0..len14 { - let base = base14.add(i * 16); + let l8 = *base.add(0).cast::<*mut u8>(); + let l9 = *base.add(4).cast::(); + let base16 = l8; + let len16 = l9; + for i in 0..len16 { + let base = base16.add(i * 16); { - let l6 = i32::from(*base.add(0).cast::()); - match l6 { - 0 => (), - 1 => (), - 2 => (), - 3 => (), - 4 => (), - 5 => (), - 6 => (), - 7 => (), - 8 => (), - 9 => (), - 10 => (), + let l10 = i32::from(*base.add(0).cast::()); + match l10 { + 0 => {} + 1 => {} + 2 => {} + 3 => {} + 4 => {} + 5 => {} + 6 => {} + 7 => {} + 8 => {} + 9 => {} + 10 => {} 11 => { - let l7 = *base.add(8).cast::<*mut u8>(); - let l8 = *base.add(12).cast::(); - _rt::cabi_dealloc(l7, l8, 1); + let l11 = *base.add(8).cast::<*mut u8>(); + let l12 = *base.add(12).cast::(); + _rt::cabi_dealloc(l11, l12, 1); } 12 => { - let l9 = *base.add(8).cast::<*mut u8>(); - let l10 = *base.add(12).cast::(); - let base11 = l9; - let len11 = l10; - _rt::cabi_dealloc(base11, len11 * 1, 1); + let l13 = *base.add(8).cast::<*mut u8>(); + let l14 = *base.add(12).cast::(); + let base15 = l13; + let len15 = l14; + _rt::cabi_dealloc(base15, len15 * 1, 1); } - 13 => (), - _ => (), + 13 => {} + _ => {} } } } - _rt::cabi_dealloc(base14, len14 * 16, 8); + _rt::cabi_dealloc(base16, len16 * 16, 8); } } _rt::cabi_dealloc(base17, len17 * 8, 4); @@ -13595,8 +14284,7 @@ pub mod exports { arg3: *mut u8, arg4: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let base20 = arg3; @@ -13611,7 +14299,6 @@ pub mod exports { 0 => { let e19 = { let l2 = i32::from(*base.add(8).cast::()); - _rt::bool_lift(l2 as u8) }; V19::Boolean(e19) @@ -13619,7 +14306,6 @@ pub mod exports { 1 => { let e19 = { let l3 = i32::from(*base.add(8).cast::()); - l3 as i8 }; V19::Int8(e19) @@ -13627,7 +14313,6 @@ pub mod exports { 2 => { let e19 = { let l4 = i32::from(*base.add(8).cast::()); - l4 as i16 }; V19::Int16(e19) @@ -13635,7 +14320,6 @@ pub mod exports { 3 => { let e19 = { let l5 = *base.add(8).cast::(); - l5 }; V19::Int32(e19) @@ -13643,7 +14327,6 @@ pub mod exports { 4 => { let e19 = { let l6 = *base.add(8).cast::(); - l6 }; V19::Int64(e19) @@ -13651,7 +14334,6 @@ pub mod exports { 5 => { let e19 = { let l7 = i32::from(*base.add(8).cast::()); - l7 as u8 }; V19::Uint8(e19) @@ -13659,7 +14341,6 @@ pub mod exports { 6 => { let e19 = { let l8 = i32::from(*base.add(8).cast::()); - l8 as u16 }; V19::Uint16(e19) @@ -13667,7 +14348,6 @@ pub mod exports { 7 => { let e19 = { let l9 = *base.add(8).cast::(); - l9 as u32 }; V19::Uint32(e19) @@ -13675,7 +14355,6 @@ pub mod exports { 8 => { let e19 = { let l10 = *base.add(8).cast::(); - l10 as u64 }; V19::Uint64(e19) @@ -13683,7 +14362,6 @@ pub mod exports { 9 => { let e19 = { let l11 = *base.add(8).cast::(); - l11 }; V19::Floating32(e19) @@ -13691,7 +14369,6 @@ pub mod exports { 10 => { let e19 = { let l12 = *base.add(8).cast::(); - l12 }; V19::Floating64(e19) @@ -13701,9 +14378,11 @@ pub mod exports { let l13 = *base.add(8).cast::<*mut u8>(); let l14 = *base.add(12).cast::(); let len15 = l14; - let bytes15 = - _rt::Vec::from_raw_parts(l13.cast(), len15, len15); - + let bytes15 = _rt::Vec::from_raw_parts( + l13.cast(), + len15, + len15, + ); _rt::string_lift(bytes15) }; V19::Str(e19) @@ -13713,7 +14392,6 @@ pub mod exports { let l16 = *base.add(8).cast::<*mut u8>(); let l17 = *base.add(12).cast::(); let len18 = l17; - _rt::Vec::from_raw_parts(l16.cast(), len18, len18) }; V19::Binary(e19) @@ -13723,7 +14401,6 @@ pub mod exports { V19::DbNull } }; - v19 }; result20.push(e20); @@ -13795,12 +14472,12 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_method_connection_execute( - arg0: *mut u8, - ) { + pub unsafe fn __post_return_method_connection_execute< + T: GuestConnection, + >(arg0: *mut u8) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { @@ -13847,10 +14524,11 @@ pub mod exports { let _ = val; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/mysql@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/mysql@2.0.0" + )] extern "C" { #[link_name = "[resource-new]connection"] fn new(_: *mut u8) -> u32; @@ -13858,7 +14536,6 @@ pub mod exports { new(val) } } - #[doc(hidden)] fn _resource_rep(handle: u32) -> *mut u8 where @@ -13869,10 +14546,11 @@ pub mod exports { let _ = handle; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/mysql@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/mysql@2.0.0" + )] extern "C" { #[link_name = "[resource-rep]connection"] fn rep(_: u32) -> *mut u8; @@ -13880,7 +14558,6 @@ pub mod exports { unsafe { rep(handle) } } } - /// Open a connection to the MySQL instance at `address`. fn open(address: _rt::String) -> Result; /// query the database: select @@ -13897,73 +14574,72 @@ pub mod exports { ) -> Result<(), Error>; } #[doc(hidden)] - - macro_rules! __export_fermyon_spin_mysql_2_0_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "fermyon:spin/mysql@2.0.0#[static]connection.open"] - unsafe extern "C" fn export_static_connection_open(arg0: *mut u8,arg1: usize,) -> *mut u8 { - $($path_to_types)*::_export_static_connection_open_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1) - } - #[export_name = "cabi_post_fermyon:spin/mysql@2.0.0#[static]connection.open"] - unsafe extern "C" fn _post_return_static_connection_open(arg0: *mut u8,) { - $($path_to_types)*::__post_return_static_connection_open::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/mysql@2.0.0#[method]connection.query"] - unsafe extern "C" fn export_method_connection_query(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_query_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2, arg3, arg4) - } - #[export_name = "cabi_post_fermyon:spin/mysql@2.0.0#[method]connection.query"] - unsafe extern "C" fn _post_return_method_connection_query(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_query::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/mysql@2.0.0#[method]connection.execute"] - unsafe extern "C" fn export_method_connection_execute(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_execute_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2, arg3, arg4) - } - #[export_name = "cabi_post_fermyon:spin/mysql@2.0.0#[method]connection.execute"] - unsafe extern "C" fn _post_return_method_connection_execute(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_execute::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - - const _: () = { - #[doc(hidden)] - #[export_name = "fermyon:spin/mysql@2.0.0#[dtor]connection"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: *mut u8) { - $($path_to_types)*::Connection::dtor::< - <$ty as $($path_to_types)*::Guest>::Connection - >(rep) - } - }; - - };); -} + macro_rules! __export_fermyon_spin_mysql_2_0_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "fermyon:spin/mysql@2.0.0#[static]connection.open"] unsafe extern + "C" fn export_static_connection_open(arg0 : * mut u8, arg1 : + usize,) -> * mut u8 { $($path_to_types)*:: + _export_static_connection_open_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1) } + #[export_name = + "cabi_post_fermyon:spin/mysql@2.0.0#[static]connection.open"] + unsafe extern "C" fn _post_return_static_connection_open(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_static_connection_open::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/mysql@2.0.0#[method]connection.query"] unsafe + extern "C" fn export_method_connection_query(arg0 : * mut u8, + arg1 : * mut u8, arg2 : usize, arg3 : * mut u8, arg4 : usize,) -> + * mut u8 { $($path_to_types)*:: + _export_method_connection_query_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1, arg2, + arg3, arg4) } #[export_name = + "cabi_post_fermyon:spin/mysql@2.0.0#[method]connection.query"] + unsafe extern "C" fn _post_return_method_connection_query(arg0 : + * mut u8,) { $($path_to_types)*:: + __post_return_method_connection_query::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/mysql@2.0.0#[method]connection.execute"] unsafe + extern "C" fn export_method_connection_execute(arg0 : * mut u8, + arg1 : * mut u8, arg2 : usize, arg3 : * mut u8, arg4 : usize,) -> + * mut u8 { $($path_to_types)*:: + _export_method_connection_execute_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1, arg2, + arg3, arg4) } #[export_name = + "cabi_post_fermyon:spin/mysql@2.0.0#[method]connection.execute"] + unsafe extern "C" fn _post_return_method_connection_execute(arg0 + : * mut u8,) { $($path_to_types)*:: + __post_return_method_connection_execute::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } const _ : () + = { #[doc(hidden)] #[export_name = + "fermyon:spin/mysql@2.0.0#[dtor]connection"] + #[allow(non_snake_case)] unsafe extern "C" fn dtor(rep : * mut + u8) { $($path_to_types)*:: Connection::dtor::< <$ty as + $($path_to_types)*:: Guest >::Connection > (rep) } }; }; + }; + } #[doc(hidden)] pub(crate) use __export_fermyon_spin_mysql_2_0_0_cabi; #[repr(align(4))] struct _RetArea([::core::mem::MaybeUninit; 20]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 20]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 20], + ); } - #[allow(dead_code, clippy::all)] pub mod sqlite { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; /// A handle to an open sqlite instance - #[derive(Debug)] #[repr(transparent)] pub struct Connection { handle: _rt::Resource, } - type _ConnectionRep = Option; - impl Connection { /// Creates a new resource from the specified representation. /// @@ -13973,77 +14649,68 @@ pub mod exports { pub fn new(val: T) -> Self { Self::type_guard::(); let val: _ConnectionRep = Some(val); - let ptr: *mut _ConnectionRep = _rt::Box::into_raw(_rt::Box::new(val)); + let ptr: *mut _ConnectionRep = _rt::Box::into_raw( + _rt::Box::new(val), + ); unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } } - /// Gets access to the underlying `T` which represents this resource. pub fn get(&self) -> &T { let ptr = unsafe { &*self.as_ptr::() }; ptr.as_ref().unwrap() } - /// Gets mutable access to the underlying `T` which represents this /// resource. pub fn get_mut(&mut self) -> &mut T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_mut().unwrap() } - /// Consumes this resource and returns the underlying `T`. pub fn into_inner(self) -> T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.take().unwrap() } - #[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) } - - // It's theoretically possible to implement the `GuestConnection` trait twice - // so guard against using it with two different types here. #[doc(hidden)] fn type_guard() { use core::any::TypeId; static mut LAST_TYPE: Option = None; unsafe { - assert!(!cfg!(target_feature = "threads")); + assert!(! cfg!(target_feature = "atomics")); let id = TypeId::of::(); match LAST_TYPE { - Some(ty) => assert!( - ty == id, - "cannot use two types with this resource type" - ), + Some(ty) => { + assert!( + ty == id, "cannot use two types with this resource type" + ) + } None => LAST_TYPE = Some(id), } } } - #[doc(hidden)] pub unsafe fn dtor(handle: *mut u8) { Self::type_guard::(); let _ = _rt::Box::from_raw(handle as *mut _ConnectionRep); } - fn as_ptr(&self) -> *mut _ConnectionRep { Connection::type_guard::(); T::_resource_rep(self.handle()).cast() } } - /// A borrowed version of [`Connection`] which represents a borrowed value /// with the lifetime `'a`. #[derive(Debug)] @@ -14052,7 +14719,6 @@ pub mod exports { rep: *mut u8, _marker: core::marker::PhantomData<&'a Connection>, } - impl<'a> ConnectionBorrow<'a> { #[doc(hidden)] pub unsafe fn lift(rep: usize) -> Self { @@ -14061,41 +14727,34 @@ pub mod exports { _marker: core::marker::PhantomData, } } - /// Gets access to the underlying `T` in this resource. pub fn get(&self) -> &T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_ref().unwrap() } - - // NB: mutable access is not allowed due to the component model allowing - // multiple borrows of the same resource. - fn as_ptr(&self) -> *mut _ConnectionRep { Connection::type_guard::(); self.rep.cast() } } - unsafe impl _rt::WasmResource for Connection { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/sqlite@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/sqlite@2.0.0" + )] extern "C" { #[link_name = "[resource-drop]connection"] fn drop(_: u32); } - drop(_handle); } } } - /// The set of errors which may be raised by functions in this interface #[derive(Clone)] pub enum Error { @@ -14111,26 +14770,35 @@ pub mod exports { Io(_rt::String), } impl ::core::fmt::Debug for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { Error::NoSuchDatabase => { f.debug_tuple("Error::NoSuchDatabase").finish() } - Error::AccessDenied => f.debug_tuple("Error::AccessDenied").finish(), + Error::AccessDenied => { + f.debug_tuple("Error::AccessDenied").finish() + } Error::InvalidConnection => { f.debug_tuple("Error::InvalidConnection").finish() } - Error::DatabaseFull => f.debug_tuple("Error::DatabaseFull").finish(), + Error::DatabaseFull => { + f.debug_tuple("Error::DatabaseFull").finish() + } Error::Io(e) => f.debug_tuple("Error::Io").field(e).finish(), } } } impl ::core::fmt::Display for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { write!(f, "{:?}", self) } } - impl std::error::Error for Error {} /// A single column's result from a database query #[derive(Clone)] @@ -14142,12 +14810,23 @@ pub mod exports { Null, } impl ::core::fmt::Debug for Value { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { - Value::Integer(e) => f.debug_tuple("Value::Integer").field(e).finish(), - Value::Real(e) => f.debug_tuple("Value::Real").field(e).finish(), - Value::Text(e) => f.debug_tuple("Value::Text").field(e).finish(), - Value::Blob(e) => f.debug_tuple("Value::Blob").field(e).finish(), + Value::Integer(e) => { + f.debug_tuple("Value::Integer").field(e).finish() + } + Value::Real(e) => { + f.debug_tuple("Value::Real").field(e).finish() + } + Value::Text(e) => { + f.debug_tuple("Value::Text").field(e).finish() + } + Value::Blob(e) => { + f.debug_tuple("Value::Blob").field(e).finish() + } Value::Null => f.debug_tuple("Value::Null").finish(), } } @@ -14158,7 +14837,10 @@ pub mod exports { pub values: _rt::Vec, } impl ::core::fmt::Debug for RowResult { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("RowResult") .field("values", &self.values) .finish() @@ -14173,7 +14855,10 @@ pub mod exports { pub rows: _rt::Vec, } impl ::core::fmt::Debug for QueryResult { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("QueryResult") .field("columns", &self.columns) .field("rows", &self.rows) @@ -14186,8 +14871,7 @@ pub mod exports { arg0: *mut u8, arg1: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg1; let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); let result1 = T::open(_rt::string_lift(bytes0)); @@ -14233,14 +14917,14 @@ pub mod exports { ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), - 1 => (), - 2 => (), - 3 => (), + 0 => {} + 1 => {} + 2 => {} + 3 => {} _ => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -14259,8 +14943,7 @@ pub mod exports { arg3: *mut u8, arg4: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let base11 = arg3; @@ -14274,7 +14957,6 @@ pub mod exports { 0 => { let e10 = { let l2 = *base.add(8).cast::(); - l2 }; Value::Integer(e10) @@ -14282,7 +14964,6 @@ pub mod exports { 1 => { let e10 = { let l3 = *base.add(8).cast::(); - l3 }; Value::Real(e10) @@ -14292,9 +14973,11 @@ pub mod exports { let l4 = *base.add(8).cast::<*mut u8>(); let l5 = *base.add(12).cast::(); let len6 = l5; - let bytes6 = - _rt::Vec::from_raw_parts(l4.cast(), len6, len6); - + let bytes6 = _rt::Vec::from_raw_parts( + l4.cast(), + len6, + len6, + ); _rt::string_lift(bytes6) }; Value::Text(e10) @@ -14304,7 +14987,6 @@ pub mod exports { let l7 = *base.add(8).cast::<*mut u8>(); let l8 = *base.add(12).cast::(); let len9 = l8; - _rt::Vec::from_raw_parts(l7.cast(), len9, len9) }; Value::Blob(e10) @@ -14314,7 +14996,6 @@ pub mod exports { Value::Null } }; - v10 }; result11.push(e11); @@ -14329,14 +15010,13 @@ pub mod exports { match result12 { Ok(e) => { *ptr13.add(0).cast::() = (0i32) as u8; - let QueryResult { - columns: columns14, - rows: rows14, - } = e; + let QueryResult { columns: columns14, rows: rows14 } = e; let vec16 = columns14; let len16 = vec16.len(); - let layout16 = - _rt::alloc::Layout::from_size_align_unchecked(vec16.len() * 8, 4); + let layout16 = _rt::alloc::Layout::from_size_align_unchecked( + vec16.len() * 8, + 4, + ); let result16 = if layout16.size() != 0 { let ptr = _rt::alloc::alloc(layout16).cast::(); if ptr.is_null() { @@ -14344,9 +15024,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec16.into_iter().enumerate() { let base = result16.add(i * 8); @@ -14363,8 +15041,10 @@ pub mod exports { *ptr13.add(4).cast::<*mut u8>() = result16; let vec21 = rows14; let len21 = vec21.len(); - let layout21 = - _rt::alloc::Layout::from_size_align_unchecked(vec21.len() * 8, 4); + let layout21 = _rt::alloc::Layout::from_size_align_unchecked( + vec21.len() * 8, + 4, + ); let result21 = if layout21.size() != 0 { let ptr = _rt::alloc::alloc(layout21).cast::(); if ptr.is_null() { @@ -14372,9 +15052,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec21.into_iter().enumerate() { let base = result21.add(i * 8); @@ -14393,9 +15071,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec20.into_iter().enumerate() { let base = result20.add(i * 16); @@ -14416,8 +15092,7 @@ pub mod exports { let len18 = vec18.len(); ::core::mem::forget(vec18); *base.add(12).cast::() = len18; - *base.add(8).cast::<*mut u8>() = - ptr18.cast_mut(); + *base.add(8).cast::<*mut u8>() = ptr18.cast_mut(); } Value::Blob(e) => { *base.add(0).cast::() = (3i32) as u8; @@ -14426,8 +15101,7 @@ pub mod exports { let len19 = vec19.len(); ::core::mem::forget(vec19); *base.add(12).cast::() = len19; - *base.add(8).cast::<*mut u8>() = - ptr19.cast_mut(); + *base.add(8).cast::<*mut u8>() = ptr19.cast_mut(); } Value::Null => { *base.add(0).cast::() = (4i32) as u8; @@ -14473,60 +15147,60 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_method_connection_execute( - arg0: *mut u8, - ) { + pub unsafe fn __post_return_method_connection_execute< + T: GuestConnection, + >(arg0: *mut u8) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { 0 => { - let l3 = *arg0.add(4).cast::<*mut u8>(); - let l4 = *arg0.add(8).cast::(); - let base5 = l3; - let len5 = l4; + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + let base5 = l1; + let len5 = l2; for i in 0..len5 { let base = base5.add(i * 8); { - let l1 = *base.add(0).cast::<*mut u8>(); - let l2 = *base.add(4).cast::(); - _rt::cabi_dealloc(l1, l2, 1); + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + _rt::cabi_dealloc(l3, l4, 1); } } _rt::cabi_dealloc(base5, len5 * 8, 4); - let l15 = *arg0.add(12).cast::<*mut u8>(); - let l16 = *arg0.add(16).cast::(); - let base17 = l15; - let len17 = l16; + let l6 = *arg0.add(12).cast::<*mut u8>(); + let l7 = *arg0.add(16).cast::(); + let base17 = l6; + let len17 = l7; for i in 0..len17 { let base = base17.add(i * 8); { - let l12 = *base.add(0).cast::<*mut u8>(); - let l13 = *base.add(4).cast::(); - let base14 = l12; - let len14 = l13; - for i in 0..len14 { - let base = base14.add(i * 16); + let l8 = *base.add(0).cast::<*mut u8>(); + let l9 = *base.add(4).cast::(); + let base16 = l8; + let len16 = l9; + for i in 0..len16 { + let base = base16.add(i * 16); { - let l6 = i32::from(*base.add(0).cast::()); - match l6 { - 0 => (), - 1 => (), + let l10 = i32::from(*base.add(0).cast::()); + match l10 { + 0 => {} + 1 => {} 2 => { - let l7 = *base.add(8).cast::<*mut u8>(); - let l8 = *base.add(12).cast::(); - _rt::cabi_dealloc(l7, l8, 1); + let l11 = *base.add(8).cast::<*mut u8>(); + let l12 = *base.add(12).cast::(); + _rt::cabi_dealloc(l11, l12, 1); } 3 => { - let l9 = *base.add(8).cast::<*mut u8>(); - let l10 = *base.add(12).cast::(); - let base11 = l9; - let len11 = l10; - _rt::cabi_dealloc(base11, len11 * 1, 1); + let l13 = *base.add(8).cast::<*mut u8>(); + let l14 = *base.add(12).cast::(); + let base15 = l13; + let len15 = l14; + _rt::cabi_dealloc(base15, len15 * 1, 1); } - _ => (), + _ => {} } } } - _rt::cabi_dealloc(base14, len14 * 16, 8); + _rt::cabi_dealloc(base16, len16 * 16, 8); } } _rt::cabi_dealloc(base17, len17 * 8, 4); @@ -14534,10 +15208,10 @@ pub mod exports { _ => { let l18 = i32::from(*arg0.add(4).cast::()); match l18 { - 0 => (), - 1 => (), - 2 => (), - 3 => (), + 0 => {} + 1 => {} + 2 => {} + 3 => {} _ => { let l19 = *arg0.add(8).cast::<*mut u8>(); let l20 = *arg0.add(12).cast::(); @@ -14561,10 +15235,11 @@ pub mod exports { let _ = val; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/sqlite@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/sqlite@2.0.0" + )] extern "C" { #[link_name = "[resource-new]connection"] fn new(_: *mut u8) -> u32; @@ -14572,7 +15247,6 @@ pub mod exports { new(val) } } - #[doc(hidden)] fn _resource_rep(handle: u32) -> *mut u8 where @@ -14583,10 +15257,11 @@ pub mod exports { let _ = handle; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/sqlite@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/sqlite@2.0.0" + )] extern "C" { #[link_name = "[resource-rep]connection"] fn rep(_: u32) -> *mut u8; @@ -14594,7 +15269,6 @@ pub mod exports { unsafe { rep(handle) } } } - /// Open a connection to a named database instance. /// /// If `database` is "default", the default instance is opened. @@ -14609,65 +15283,60 @@ pub mod exports { ) -> Result; } #[doc(hidden)] - - macro_rules! __export_fermyon_spin_sqlite_2_0_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "fermyon:spin/sqlite@2.0.0#[static]connection.open"] - unsafe extern "C" fn export_static_connection_open(arg0: *mut u8,arg1: usize,) -> *mut u8 { - $($path_to_types)*::_export_static_connection_open_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1) - } - #[export_name = "cabi_post_fermyon:spin/sqlite@2.0.0#[static]connection.open"] - unsafe extern "C" fn _post_return_static_connection_open(arg0: *mut u8,) { - $($path_to_types)*::__post_return_static_connection_open::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - #[export_name = "fermyon:spin/sqlite@2.0.0#[method]connection.execute"] - unsafe extern "C" fn export_method_connection_execute(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_connection_execute_cabi::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0, arg1, arg2, arg3, arg4) - } - #[export_name = "cabi_post_fermyon:spin/sqlite@2.0.0#[method]connection.execute"] - unsafe extern "C" fn _post_return_method_connection_execute(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_connection_execute::<<$ty as $($path_to_types)*::Guest>::Connection>(arg0) - } - - const _: () = { - #[doc(hidden)] - #[export_name = "fermyon:spin/sqlite@2.0.0#[dtor]connection"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: *mut u8) { - $($path_to_types)*::Connection::dtor::< - <$ty as $($path_to_types)*::Guest>::Connection - >(rep) - } - }; - - };); -} + macro_rules! __export_fermyon_spin_sqlite_2_0_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "fermyon:spin/sqlite@2.0.0#[static]connection.open"] unsafe + extern "C" fn export_static_connection_open(arg0 : * mut u8, arg1 + : usize,) -> * mut u8 { $($path_to_types)*:: + _export_static_connection_open_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1) } + #[export_name = + "cabi_post_fermyon:spin/sqlite@2.0.0#[static]connection.open"] + unsafe extern "C" fn _post_return_static_connection_open(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_static_connection_open::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } #[export_name + = "fermyon:spin/sqlite@2.0.0#[method]connection.execute"] unsafe + extern "C" fn export_method_connection_execute(arg0 : * mut u8, + arg1 : * mut u8, arg2 : usize, arg3 : * mut u8, arg4 : usize,) -> + * mut u8 { $($path_to_types)*:: + _export_method_connection_execute_cabi::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0, arg1, arg2, + arg3, arg4) } #[export_name = + "cabi_post_fermyon:spin/sqlite@2.0.0#[method]connection.execute"] + unsafe extern "C" fn _post_return_method_connection_execute(arg0 + : * mut u8,) { $($path_to_types)*:: + __post_return_method_connection_execute::<<$ty as + $($path_to_types)*:: Guest >::Connection > (arg0) } const _ : () + = { #[doc(hidden)] #[export_name = + "fermyon:spin/sqlite@2.0.0#[dtor]connection"] + #[allow(non_snake_case)] unsafe extern "C" fn dtor(rep : * mut + u8) { $($path_to_types)*:: Connection::dtor::< <$ty as + $($path_to_types)*:: Guest >::Connection > (rep) } }; }; + }; + } #[doc(hidden)] pub(crate) use __export_fermyon_spin_sqlite_2_0_0_cabi; #[repr(align(4))] struct _RetArea([::core::mem::MaybeUninit; 20]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 20]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 20], + ); } - #[allow(dead_code, clippy::all)] pub mod key_value { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; /// An open key-value store - #[derive(Debug)] #[repr(transparent)] pub struct Store { handle: _rt::Resource, } - type _StoreRep = Option; - impl Store { /// Creates a new resource from the specified representation. /// @@ -14677,77 +15346,68 @@ pub mod exports { pub fn new(val: T) -> Self { Self::type_guard::(); let val: _StoreRep = Some(val); - let ptr: *mut _StoreRep = _rt::Box::into_raw(_rt::Box::new(val)); + let ptr: *mut _StoreRep = _rt::Box::into_raw( + _rt::Box::new(val), + ); unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } } - /// Gets access to the underlying `T` which represents this resource. pub fn get(&self) -> &T { let ptr = unsafe { &*self.as_ptr::() }; ptr.as_ref().unwrap() } - /// Gets mutable access to the underlying `T` which represents this /// resource. pub fn get_mut(&mut self) -> &mut T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_mut().unwrap() } - /// Consumes this resource and returns the underlying `T`. pub fn into_inner(self) -> T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.take().unwrap() } - #[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) } - - // It's theoretically possible to implement the `GuestStore` trait twice - // so guard against using it with two different types here. #[doc(hidden)] fn type_guard() { use core::any::TypeId; static mut LAST_TYPE: Option = None; unsafe { - assert!(!cfg!(target_feature = "threads")); + assert!(! cfg!(target_feature = "atomics")); let id = TypeId::of::(); match LAST_TYPE { - Some(ty) => assert!( - ty == id, - "cannot use two types with this resource type" - ), + Some(ty) => { + assert!( + ty == id, "cannot use two types with this resource type" + ) + } None => LAST_TYPE = Some(id), } } } - #[doc(hidden)] pub unsafe fn dtor(handle: *mut u8) { Self::type_guard::(); let _ = _rt::Box::from_raw(handle as *mut _StoreRep); } - fn as_ptr(&self) -> *mut _StoreRep { Store::type_guard::(); T::_resource_rep(self.handle()).cast() } } - /// A borrowed version of [`Store`] which represents a borrowed value /// with the lifetime `'a`. #[derive(Debug)] @@ -14756,7 +15416,6 @@ pub mod exports { rep: *mut u8, _marker: core::marker::PhantomData<&'a Store>, } - impl<'a> StoreBorrow<'a> { #[doc(hidden)] pub unsafe fn lift(rep: usize) -> Self { @@ -14765,41 +15424,34 @@ pub mod exports { _marker: core::marker::PhantomData, } } - /// Gets access to the underlying `T` in this resource. pub fn get(&self) -> &T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_ref().unwrap() } - - // NB: mutable access is not allowed due to the component model allowing - // multiple borrows of the same resource. - fn as_ptr(&self) -> *mut _StoreRep { Store::type_guard::(); self.rep.cast() } } - unsafe impl _rt::WasmResource for Store { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/key-value@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/key-value@2.0.0" + )] extern "C" { #[link_name = "[resource-drop]store"] fn drop(_: u32); } - drop(_handle); } } } - /// The set of errors which may be raised by functions in this interface #[derive(Clone)] pub enum Error { @@ -14815,23 +15467,34 @@ pub mod exports { Other(_rt::String), } impl ::core::fmt::Debug for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { Error::StoreTableFull => { f.debug_tuple("Error::StoreTableFull").finish() } - Error::NoSuchStore => f.debug_tuple("Error::NoSuchStore").finish(), - Error::AccessDenied => f.debug_tuple("Error::AccessDenied").finish(), - Error::Other(e) => f.debug_tuple("Error::Other").field(e).finish(), + Error::NoSuchStore => { + f.debug_tuple("Error::NoSuchStore").finish() + } + Error::AccessDenied => { + f.debug_tuple("Error::AccessDenied").finish() + } + Error::Other(e) => { + f.debug_tuple("Error::Other").field(e).finish() + } } } } impl ::core::fmt::Display for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { write!(f, "{:?}", self) } } - impl std::error::Error for Error {} #[doc(hidden)] #[allow(non_snake_case)] @@ -14839,8 +15502,7 @@ pub mod exports { arg0: *mut u8, arg1: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg1; let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); let result1 = T::open(_rt::string_lift(bytes0)); @@ -14878,16 +15540,18 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_static_store_open(arg0: *mut u8) { + pub unsafe fn __post_return_static_store_open( + arg0: *mut u8, + ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -14904,8 +15568,7 @@ pub mod exports { arg1: *mut u8, arg2: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let result1 = T::get( @@ -14959,13 +15622,15 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_method_store_get(arg0: *mut u8) { + pub unsafe fn __post_return_method_store_get( + arg0: *mut u8, + ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { 0 => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), + 0 => {} _ => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -14978,9 +15643,9 @@ pub mod exports { _ => { let l5 = i32::from(*arg0.add(4).cast::()); match l5 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l6 = *arg0.add(8).cast::<*mut u8>(); let l7 = *arg0.add(12).cast::(); @@ -14999,8 +15664,7 @@ pub mod exports { arg3: *mut u8, arg4: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let len1 = arg4; @@ -15042,16 +15706,18 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_method_store_set(arg0: *mut u8) { + pub unsafe fn __post_return_method_store_set( + arg0: *mut u8, + ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -15068,8 +15734,7 @@ pub mod exports { arg1: *mut u8, arg2: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let result1 = T::delete( @@ -15109,16 +15774,18 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_method_store_delete(arg0: *mut u8) { + pub unsafe fn __post_return_method_store_delete( + arg0: *mut u8, + ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -15135,8 +15802,7 @@ pub mod exports { arg1: *mut u8, arg2: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg2; let bytes0 = _rt::Vec::from_raw_parts(arg1.cast(), len0, len0); let result1 = T::exists( @@ -15180,16 +15846,18 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_method_store_exists(arg0: *mut u8) { + pub unsafe fn __post_return_method_store_exists( + arg0: *mut u8, + ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(4).cast::()); match l1 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l2 = *arg0.add(8).cast::<*mut u8>(); let l3 = *arg0.add(12).cast::(); @@ -15204,17 +15872,20 @@ pub mod exports { pub unsafe fn _export_method_store_get_keys_cabi( arg0: *mut u8, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = T::get_keys(StoreBorrow::lift(arg0 as u32 as usize).get()); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::get_keys( + StoreBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { *ptr1.add(0).cast::() = (0i32) as u8; let vec3 = e; let len3 = vec3.len(); - let layout3 = - _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 4); + 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() { @@ -15222,9 +15893,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec3.into_iter().enumerate() { let base = result3.add(i * 8); @@ -15268,20 +15937,22 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn __post_return_method_store_get_keys(arg0: *mut u8) { + pub unsafe fn __post_return_method_store_get_keys( + arg0: *mut u8, + ) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { 0 => { - let l3 = *arg0.add(4).cast::<*mut u8>(); - let l4 = *arg0.add(8).cast::(); - let base5 = l3; - let len5 = l4; + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + let base5 = l1; + let len5 = l2; for i in 0..len5 { let base = base5.add(i * 8); { - let l1 = *base.add(0).cast::<*mut u8>(); - let l2 = *base.add(4).cast::(); - _rt::cabi_dealloc(l1, l2, 1); + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + _rt::cabi_dealloc(l3, l4, 1); } } _rt::cabi_dealloc(base5, len5 * 8, 4); @@ -15289,9 +15960,9 @@ pub mod exports { _ => { let l6 = i32::from(*arg0.add(4).cast::()); match l6 { - 0 => (), - 1 => (), - 2 => (), + 0 => {} + 1 => {} + 2 => {} _ => { let l7 = *arg0.add(8).cast::<*mut u8>(); let l8 = *arg0.add(12).cast::(); @@ -15315,10 +15986,11 @@ pub mod exports { let _ = val; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/key-value@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/key-value@2.0.0" + )] extern "C" { #[link_name = "[resource-new]store"] fn new(_: *mut u8) -> u32; @@ -15326,7 +15998,6 @@ pub mod exports { new(val) } } - #[doc(hidden)] fn _resource_rep(handle: u32) -> *mut u8 where @@ -15337,10 +16008,11 @@ pub mod exports { let _ = handle; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]fermyon:spin/key-value@2.0.0")] + #[link( + wasm_import_module = "[export]fermyon:spin/key-value@2.0.0" + )] extern "C" { #[link_name = "[resource-rep]store"] fn rep(_: u32) -> *mut u8; @@ -15348,7 +16020,6 @@ pub mod exports { unsafe { rep(handle) } } } - /// Open the store with the specified label. /// /// `label` must refer to a store allowed in the spin.toml manifest. @@ -15358,9 +16029,16 @@ pub mod exports { /// Get the value associated with the specified `key` /// /// Returns `ok(none)` if the key does not exist. - fn get(&self, key: _rt::String) -> Result>, Error>; + fn get( + &self, + key: _rt::String, + ) -> Result>, Error>; /// Set the `value` associated with the specified `key` overwriting any existing value. - fn set(&self, key: _rt::String, value: _rt::Vec) -> Result<(), Error>; + fn set( + &self, + key: _rt::String, + value: _rt::Vec, + ) -> Result<(), Error>; /// Delete the tuple with the specified `key` /// /// No error is raised if a tuple did not previously exist for `key`. @@ -15371,86 +16049,88 @@ pub mod exports { fn get_keys(&self) -> Result<_rt::Vec<_rt::String>, Error>; } #[doc(hidden)] - - macro_rules! __export_fermyon_spin_key_value_2_0_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "fermyon:spin/key-value@2.0.0#[static]store.open"] - unsafe extern "C" fn export_static_store_open(arg0: *mut u8,arg1: usize,) -> *mut u8 { - $($path_to_types)*::_export_static_store_open_cabi::<<$ty as $($path_to_types)*::Guest>::Store>(arg0, arg1) - } - #[export_name = "cabi_post_fermyon:spin/key-value@2.0.0#[static]store.open"] - unsafe extern "C" fn _post_return_static_store_open(arg0: *mut u8,) { - $($path_to_types)*::__post_return_static_store_open::<<$ty as $($path_to_types)*::Guest>::Store>(arg0) - } - #[export_name = "fermyon:spin/key-value@2.0.0#[method]store.get"] - unsafe extern "C" fn export_method_store_get(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_store_get_cabi::<<$ty as $($path_to_types)*::Guest>::Store>(arg0, arg1, arg2) - } - #[export_name = "cabi_post_fermyon:spin/key-value@2.0.0#[method]store.get"] - unsafe extern "C" fn _post_return_method_store_get(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_store_get::<<$ty as $($path_to_types)*::Guest>::Store>(arg0) - } - #[export_name = "fermyon:spin/key-value@2.0.0#[method]store.set"] - unsafe extern "C" fn export_method_store_set(arg0: *mut u8,arg1: *mut u8,arg2: usize,arg3: *mut u8,arg4: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_store_set_cabi::<<$ty as $($path_to_types)*::Guest>::Store>(arg0, arg1, arg2, arg3, arg4) - } - #[export_name = "cabi_post_fermyon:spin/key-value@2.0.0#[method]store.set"] - unsafe extern "C" fn _post_return_method_store_set(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_store_set::<<$ty as $($path_to_types)*::Guest>::Store>(arg0) - } - #[export_name = "fermyon:spin/key-value@2.0.0#[method]store.delete"] - unsafe extern "C" fn export_method_store_delete(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_store_delete_cabi::<<$ty as $($path_to_types)*::Guest>::Store>(arg0, arg1, arg2) - } - #[export_name = "cabi_post_fermyon:spin/key-value@2.0.0#[method]store.delete"] - unsafe extern "C" fn _post_return_method_store_delete(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_store_delete::<<$ty as $($path_to_types)*::Guest>::Store>(arg0) - } - #[export_name = "fermyon:spin/key-value@2.0.0#[method]store.exists"] - unsafe extern "C" fn export_method_store_exists(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_store_exists_cabi::<<$ty as $($path_to_types)*::Guest>::Store>(arg0, arg1, arg2) - } - #[export_name = "cabi_post_fermyon:spin/key-value@2.0.0#[method]store.exists"] - unsafe extern "C" fn _post_return_method_store_exists(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_store_exists::<<$ty as $($path_to_types)*::Guest>::Store>(arg0) - } - #[export_name = "fermyon:spin/key-value@2.0.0#[method]store.get-keys"] - unsafe extern "C" fn export_method_store_get_keys(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_store_get_keys_cabi::<<$ty as $($path_to_types)*::Guest>::Store>(arg0) - } - #[export_name = "cabi_post_fermyon:spin/key-value@2.0.0#[method]store.get-keys"] - unsafe extern "C" fn _post_return_method_store_get_keys(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_store_get_keys::<<$ty as $($path_to_types)*::Guest>::Store>(arg0) - } - - const _: () = { - #[doc(hidden)] - #[export_name = "fermyon:spin/key-value@2.0.0#[dtor]store"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: *mut u8) { - $($path_to_types)*::Store::dtor::< - <$ty as $($path_to_types)*::Guest>::Store - >(rep) - } - }; - - };); -} + macro_rules! __export_fermyon_spin_key_value_2_0_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "fermyon:spin/key-value@2.0.0#[static]store.open"] unsafe extern + "C" fn export_static_store_open(arg0 : * mut u8, arg1 : usize,) + -> * mut u8 { $($path_to_types)*:: + _export_static_store_open_cabi::<<$ty as $($path_to_types)*:: + Guest >::Store > (arg0, arg1) } #[export_name = + "cabi_post_fermyon:spin/key-value@2.0.0#[static]store.open"] + unsafe extern "C" fn _post_return_static_store_open(arg0 : * mut + u8,) { $($path_to_types)*:: + __post_return_static_store_open::<<$ty as $($path_to_types)*:: + Guest >::Store > (arg0) } #[export_name = + "fermyon:spin/key-value@2.0.0#[method]store.get"] unsafe extern + "C" fn export_method_store_get(arg0 : * mut u8, arg1 : * mut u8, + arg2 : usize,) -> * mut u8 { $($path_to_types)*:: + _export_method_store_get_cabi::<<$ty as $($path_to_types)*:: + Guest >::Store > (arg0, arg1, arg2) } #[export_name = + "cabi_post_fermyon:spin/key-value@2.0.0#[method]store.get"] + unsafe extern "C" fn _post_return_method_store_get(arg0 : * mut + u8,) { $($path_to_types)*:: __post_return_method_store_get::<<$ty + as $($path_to_types)*:: Guest >::Store > (arg0) } #[export_name = + "fermyon:spin/key-value@2.0.0#[method]store.set"] unsafe extern + "C" fn export_method_store_set(arg0 : * mut u8, arg1 : * mut u8, + arg2 : usize, arg3 : * mut u8, arg4 : usize,) -> * mut u8 { + $($path_to_types)*:: _export_method_store_set_cabi::<<$ty as + $($path_to_types)*:: Guest >::Store > (arg0, arg1, arg2, arg3, + arg4) } #[export_name = + "cabi_post_fermyon:spin/key-value@2.0.0#[method]store.set"] + unsafe extern "C" fn _post_return_method_store_set(arg0 : * mut + u8,) { $($path_to_types)*:: __post_return_method_store_set::<<$ty + as $($path_to_types)*:: Guest >::Store > (arg0) } #[export_name = + "fermyon:spin/key-value@2.0.0#[method]store.delete"] unsafe + extern "C" fn export_method_store_delete(arg0 : * mut u8, arg1 : + * mut u8, arg2 : usize,) -> * mut u8 { $($path_to_types)*:: + _export_method_store_delete_cabi::<<$ty as $($path_to_types)*:: + Guest >::Store > (arg0, arg1, arg2) } #[export_name = + "cabi_post_fermyon:spin/key-value@2.0.0#[method]store.delete"] + unsafe extern "C" fn _post_return_method_store_delete(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_method_store_delete::<<$ty as $($path_to_types)*:: + Guest >::Store > (arg0) } #[export_name = + "fermyon:spin/key-value@2.0.0#[method]store.exists"] unsafe + extern "C" fn export_method_store_exists(arg0 : * mut u8, arg1 : + * mut u8, arg2 : usize,) -> * mut u8 { $($path_to_types)*:: + _export_method_store_exists_cabi::<<$ty as $($path_to_types)*:: + Guest >::Store > (arg0, arg1, arg2) } #[export_name = + "cabi_post_fermyon:spin/key-value@2.0.0#[method]store.exists"] + unsafe extern "C" fn _post_return_method_store_exists(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_method_store_exists::<<$ty as $($path_to_types)*:: + Guest >::Store > (arg0) } #[export_name = + "fermyon:spin/key-value@2.0.0#[method]store.get-keys"] unsafe + extern "C" fn export_method_store_get_keys(arg0 : * mut u8,) -> * + mut u8 { $($path_to_types)*:: + _export_method_store_get_keys_cabi::<<$ty as $($path_to_types)*:: + Guest >::Store > (arg0) } #[export_name = + "cabi_post_fermyon:spin/key-value@2.0.0#[method]store.get-keys"] + unsafe extern "C" fn _post_return_method_store_get_keys(arg0 : * + mut u8,) { $($path_to_types)*:: + __post_return_method_store_get_keys::<<$ty as + $($path_to_types)*:: Guest >::Store > (arg0) } const _ : () = { + #[doc(hidden)] #[export_name = + "fermyon:spin/key-value@2.0.0#[dtor]store"] + #[allow(non_snake_case)] unsafe extern "C" fn dtor(rep : * mut + u8) { $($path_to_types)*:: Store::dtor::< <$ty as + $($path_to_types)*:: Guest >::Store > (rep) } }; }; + }; + } #[doc(hidden)] pub(crate) use __export_fermyon_spin_key_value_2_0_0_cabi; #[repr(align(4))] struct _RetArea([::core::mem::MaybeUninit; 16]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 16]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 16], + ); } - #[allow(dead_code, clippy::all)] pub mod variables { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; /// The set of errors which may be raised by functions in this interface. #[derive(Clone)] @@ -15465,7 +16145,10 @@ pub mod exports { Other(_rt::String), } impl ::core::fmt::Debug for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { Error::InvalidName(e) => { f.debug_tuple("Error::InvalidName").field(e).finish() @@ -15476,22 +16159,28 @@ pub mod exports { Error::Provider(e) => { f.debug_tuple("Error::Provider").field(e).finish() } - Error::Other(e) => f.debug_tuple("Error::Other").field(e).finish(), + Error::Other(e) => { + f.debug_tuple("Error::Other").field(e).finish() + } } } } impl ::core::fmt::Display for Error { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { write!(f, "{:?}", self) } } - impl std::error::Error for Error {} #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_get_cabi(arg0: *mut u8, arg1: usize) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + pub unsafe fn _export_get_cabi( + arg0: *mut u8, + arg1: usize, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let len0 = arg1; let bytes0 = _rt::Vec::from_raw_parts(arg0.cast(), len0, len0); let result1 = T::get(_rt::string_lift(bytes0)); @@ -15594,25 +16283,24 @@ pub mod exports { fn get(name: _rt::String) -> Result<_rt::String, Error>; } #[doc(hidden)] - - macro_rules! __export_fermyon_spin_variables_2_0_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "fermyon:spin/variables@2.0.0#get"] - unsafe extern "C" fn export_get(arg0: *mut u8,arg1: usize,) -> *mut u8 { - $($path_to_types)*::_export_get_cabi::<$ty>(arg0, arg1) - } - #[export_name = "cabi_post_fermyon:spin/variables@2.0.0#get"] - unsafe extern "C" fn _post_return_get(arg0: *mut u8,) { - $($path_to_types)*::__post_return_get::<$ty>(arg0) - } - };); -} + macro_rules! __export_fermyon_spin_variables_2_0_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "fermyon:spin/variables@2.0.0#get"] unsafe extern "C" fn + export_get(arg0 : * mut u8, arg1 : usize,) -> * mut u8 { + $($path_to_types)*:: _export_get_cabi::<$ty > (arg0, arg1) } + #[export_name = "cabi_post_fermyon:spin/variables@2.0.0#get"] + unsafe extern "C" fn _post_return_get(arg0 : * mut u8,) { + $($path_to_types)*:: __post_return_get::<$ty > (arg0) } }; + }; + } #[doc(hidden)] pub(crate) use __export_fermyon_spin_variables_2_0_0_cabi; #[repr(align(4))] struct _RetArea([::core::mem::MaybeUninit; 16]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 16]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 16], + ); } } } @@ -15624,20 +16312,20 @@ pub mod exports { pub mod environment { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + 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_get_environment_cabi() -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::get_environment(); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); let vec5 = result0; let len5 = vec5.len(); - let layout5 = _rt::alloc::Layout::from_size_align_unchecked(vec5.len() * 16, 4); + let layout5 = _rt::alloc::Layout::from_size_align_unchecked( + vec5.len() * 16, + 4, + ); let result5 = if layout5.size() != 0 { let ptr = _rt::alloc::alloc(layout5).cast::(); if ptr.is_null() { @@ -15645,9 +16333,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec5.into_iter().enumerate() { let base = result5.add(i * 16); @@ -15674,19 +16360,19 @@ pub mod exports { #[doc(hidden)] #[allow(non_snake_case)] pub unsafe fn __post_return_get_environment(arg0: *mut u8) { - let l4 = *arg0.add(0).cast::<*mut u8>(); - let l5 = *arg0.add(4).cast::(); - let base6 = l4; - let len6 = l5; + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base6 = l0; + let len6 = l1; for i in 0..len6 { let base = base6.add(i * 16); { - let l0 = *base.add(0).cast::<*mut u8>(); - let l1 = *base.add(4).cast::(); - _rt::cabi_dealloc(l0, l1, 1); - let l2 = *base.add(8).cast::<*mut u8>(); - let l3 = *base.add(12).cast::(); + let l2 = *base.add(0).cast::<*mut u8>(); + let l3 = *base.add(4).cast::(); _rt::cabi_dealloc(l2, l3, 1); + let l4 = *base.add(8).cast::<*mut u8>(); + let l5 = *base.add(12).cast::(); + _rt::cabi_dealloc(l4, l5, 1); } } _rt::cabi_dealloc(base6, len6 * 16, 4); @@ -15694,13 +16380,15 @@ pub mod exports { #[doc(hidden)] #[allow(non_snake_case)] pub unsafe fn _export_get_arguments_cabi() -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::get_arguments(); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); let vec3 = result0; let len3 = vec3.len(); - let layout3 = _rt::alloc::Layout::from_size_align_unchecked(vec3.len() * 8, 4); + 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() { @@ -15708,9 +16396,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec3.into_iter().enumerate() { let base = result3.add(i * 8); @@ -15730,16 +16416,16 @@ pub mod exports { #[doc(hidden)] #[allow(non_snake_case)] pub unsafe fn __post_return_get_arguments(arg0: *mut u8) { - let l2 = *arg0.add(0).cast::<*mut u8>(); - let l3 = *arg0.add(4).cast::(); - let base4 = l2; - let len4 = l3; + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base4 = l0; + let len4 = l1; for i in 0..len4 { let base = base4.add(i * 8); { - let l0 = *base.add(0).cast::<*mut u8>(); - let l1 = *base.add(4).cast::(); - _rt::cabi_dealloc(l0, l1, 1); + let l2 = *base.add(0).cast::<*mut u8>(); + let l3 = *base.add(4).cast::(); + _rt::cabi_dealloc(l2, l3, 1); } } _rt::cabi_dealloc(base4, len4 * 8, 4); @@ -15747,8 +16433,7 @@ pub mod exports { #[doc(hidden)] #[allow(non_snake_case)] pub unsafe fn _export_initial_cwd_cabi() -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::initial_cwd(); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { @@ -15772,7 +16457,7 @@ pub mod exports { pub unsafe fn __post_return_initial_cwd(arg0: *mut u8) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = *arg0.add(4).cast::<*mut u8>(); let l2 = *arg0.add(8).cast::(); @@ -15797,41 +16482,39 @@ pub mod exports { fn initial_cwd() -> Option<_rt::String>; } #[doc(hidden)] - - macro_rules! __export_wasi_cli_environment_0_2_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "wasi:cli/environment@0.2.0#get-environment"] - unsafe extern "C" fn export_get_environment() -> *mut u8 { - $($path_to_types)*::_export_get_environment_cabi::<$ty>() - } - #[export_name = "cabi_post_wasi:cli/environment@0.2.0#get-environment"] - unsafe extern "C" fn _post_return_get_environment(arg0: *mut u8,) { - $($path_to_types)*::__post_return_get_environment::<$ty>(arg0) - } - #[export_name = "wasi:cli/environment@0.2.0#get-arguments"] - unsafe extern "C" fn export_get_arguments() -> *mut u8 { - $($path_to_types)*::_export_get_arguments_cabi::<$ty>() - } - #[export_name = "cabi_post_wasi:cli/environment@0.2.0#get-arguments"] - unsafe extern "C" fn _post_return_get_arguments(arg0: *mut u8,) { - $($path_to_types)*::__post_return_get_arguments::<$ty>(arg0) - } - #[export_name = "wasi:cli/environment@0.2.0#initial-cwd"] - unsafe extern "C" fn export_initial_cwd() -> *mut u8 { - $($path_to_types)*::_export_initial_cwd_cabi::<$ty>() - } - #[export_name = "cabi_post_wasi:cli/environment@0.2.0#initial-cwd"] - unsafe extern "C" fn _post_return_initial_cwd(arg0: *mut u8,) { - $($path_to_types)*::__post_return_initial_cwd::<$ty>(arg0) - } - };); -} + macro_rules! __export_wasi_cli_environment_0_2_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "wasi:cli/environment@0.2.0#get-environment"] unsafe extern "C" + fn export_get_environment() -> * mut u8 { $($path_to_types)*:: + _export_get_environment_cabi::<$ty > () } #[export_name = + "cabi_post_wasi:cli/environment@0.2.0#get-environment"] unsafe + extern "C" fn _post_return_get_environment(arg0 : * mut u8,) { + $($path_to_types)*:: __post_return_get_environment::<$ty > (arg0) + } #[export_name = "wasi:cli/environment@0.2.0#get-arguments"] + unsafe extern "C" fn export_get_arguments() -> * mut u8 { + $($path_to_types)*:: _export_get_arguments_cabi::<$ty > () } + #[export_name = + "cabi_post_wasi:cli/environment@0.2.0#get-arguments"] unsafe + extern "C" fn _post_return_get_arguments(arg0 : * mut u8,) { + $($path_to_types)*:: __post_return_get_arguments::<$ty > (arg0) } + #[export_name = "wasi:cli/environment@0.2.0#initial-cwd"] unsafe + extern "C" fn export_initial_cwd() -> * mut u8 { + $($path_to_types)*:: _export_initial_cwd_cabi::<$ty > () } + #[export_name = + "cabi_post_wasi:cli/environment@0.2.0#initial-cwd"] unsafe extern + "C" fn _post_return_initial_cwd(arg0 : * mut u8,) { + $($path_to_types)*:: __post_return_initial_cwd::<$ty > (arg0) } + }; + }; + } #[doc(hidden)] pub(crate) use __export_wasi_cli_environment_0_2_0_cabi; #[repr(align(4))] struct _RetArea([::core::mem::MaybeUninit; 12]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 12]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 12], + ); } } #[allow(dead_code)] @@ -15840,22 +16523,21 @@ pub mod exports { pub mod preopens { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; - pub type Descriptor = - super::super::super::super::wasi::filesystem0_2_0::types::Descriptor; + pub type Descriptor = super::super::super::super::wasi::filesystem0_2_0::types::Descriptor; #[doc(hidden)] #[allow(non_snake_case)] pub unsafe fn _export_get_directories_cabi() -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::get_directories(); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); let vec4 = result0; let len4 = vec4.len(); - let layout4 = _rt::alloc::Layout::from_size_align_unchecked(vec4.len() * 12, 4); + let layout4 = _rt::alloc::Layout::from_size_align_unchecked( + vec4.len() * 12, + 4, + ); let result4 = if layout4.size() != 0 { let ptr = _rt::alloc::alloc(layout4).cast::(); if ptr.is_null() { @@ -15863,9 +16545,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec4.into_iter().enumerate() { let base = result4.add(i * 12); @@ -15887,43 +16567,45 @@ pub mod exports { #[doc(hidden)] #[allow(non_snake_case)] pub unsafe fn __post_return_get_directories(arg0: *mut u8) { - let l2 = *arg0.add(0).cast::<*mut u8>(); - let l3 = *arg0.add(4).cast::(); - let base4 = l2; - let len4 = l3; + let l0 = *arg0.add(0).cast::<*mut u8>(); + let l1 = *arg0.add(4).cast::(); + let base4 = l0; + let len4 = l1; for i in 0..len4 { let base = base4.add(i * 12); { - let l0 = *base.add(4).cast::<*mut u8>(); - let l1 = *base.add(8).cast::(); - _rt::cabi_dealloc(l0, l1, 1); + let l2 = *base.add(4).cast::<*mut u8>(); + let l3 = *base.add(8).cast::(); + _rt::cabi_dealloc(l2, l3, 1); } } _rt::cabi_dealloc(base4, len4 * 12, 4); } pub trait Guest { + /// Return the set of preopened directories, and their path. fn get_directories() -> _rt::Vec<(Descriptor, _rt::String)>; } #[doc(hidden)] - - macro_rules! __export_wasi_filesystem_preopens_0_2_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "wasi:filesystem/preopens@0.2.0#get-directories"] - unsafe extern "C" fn export_get_directories() -> *mut u8 { - $($path_to_types)*::_export_get_directories_cabi::<$ty>() - } - #[export_name = "cabi_post_wasi:filesystem/preopens@0.2.0#get-directories"] - unsafe extern "C" fn _post_return_get_directories(arg0: *mut u8,) { - $($path_to_types)*::__post_return_get_directories::<$ty>(arg0) - } - };); - } + macro_rules! __export_wasi_filesystem_preopens_0_2_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "wasi:filesystem/preopens@0.2.0#get-directories"] unsafe extern + "C" fn export_get_directories() -> * mut u8 { + $($path_to_types)*:: _export_get_directories_cabi::<$ty > () } + #[export_name = + "cabi_post_wasi:filesystem/preopens@0.2.0#get-directories"] + unsafe extern "C" fn _post_return_get_directories(arg0 : * mut + u8,) { $($path_to_types)*:: __post_return_get_directories::<$ty > + (arg0) } }; + }; + } #[doc(hidden)] pub(crate) use __export_wasi_filesystem_preopens_0_2_0_cabi; #[repr(align(4))] struct _RetArea([::core::mem::MaybeUninit; 8]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 8]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 8], + ); } } #[allow(dead_code)] @@ -15932,16 +16614,11 @@ pub mod exports { pub mod outgoing_handler { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; - pub type OutgoingRequest = - super::super::super::super::wasi::http0_2_0::types::OutgoingRequest; - pub type RequestOptions = - super::super::super::super::wasi::http0_2_0::types::RequestOptions; - pub type FutureIncomingResponse = - super::super::super::super::wasi::http0_2_0::types::FutureIncomingResponse; + pub type OutgoingRequest = super::super::super::super::wasi::http0_2_0::types::OutgoingRequest; + pub type RequestOptions = super::super::super::super::wasi::http0_2_0::types::RequestOptions; + pub type FutureIncomingResponse = super::super::super::super::wasi::http0_2_0::types::FutureIncomingResponse; pub type ErrorCode = super::super::super::super::wasi::http0_2_0::types::ErrorCode; #[doc(hidden)] #[allow(non_snake_case)] @@ -15950,16 +16627,22 @@ pub mod exports { arg1: i32, arg2: i32, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = T::handle(super::super::super::super::wasi::http0_2_0::types::OutgoingRequest::from_handle(arg0 as u32), match arg1 { - 0 => None, - 1 => { - let e = super::super::super::super::wasi::http0_2_0::types::RequestOptions::from_handle(arg2 as u32); - Some(e) - } - _ => _rt::invalid_enum_discriminant(), - }); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::handle( + super::super::super::super::wasi::http0_2_0::types::OutgoingRequest::from_handle( + arg0 as u32, + ), + match arg1 { + 0 => None, + 1 => { + let e = super::super::super::super::wasi::http0_2_0::types::RequestOptions::from_handle( + arg2 as u32, + ); + Some(e) + } + _ => _rt::invalid_enum_discriminant(), + }, + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -15975,7 +16658,10 @@ pub mod exports { } V17::DnsError(e) => { *ptr1.add(8).cast::() = (1i32) as u8; - let super::super::super::super::wasi::http0_2_0::types::DnsErrorPayload{ rcode:rcode2, info_code:info_code2, } = e; + let super::super::super::super::wasi::http0_2_0::types::DnsErrorPayload { + rcode: rcode2, + info_code: info_code2, + } = e; match rcode2 { Some(e) => { *ptr1.add(16).cast::() = (1i32) as u8; @@ -16038,7 +16724,10 @@ pub mod exports { } V17::TlsAlertReceived(e) => { *ptr1.add(8).cast::() = (14i32) as u8; - let super::super::super::super::wasi::http0_2_0::types::TlsAlertReceivedPayload{ alert_id:alert_id4, alert_message:alert_message4, } = e; + let super::super::super::super::wasi::http0_2_0::types::TlsAlertReceivedPayload { + alert_id: alert_id4, + alert_message: alert_message4, + } = e; match alert_id4 { Some(e) => { *ptr1.add(16).cast::() = (1i32) as u8; @@ -16107,7 +16796,10 @@ pub mod exports { match e { Some(e) => { *ptr1.add(16).cast::() = (1i32) as u8; - let super::super::super::super::wasi::http0_2_0::types::FieldSizePayload{ field_name:field_name6, field_size:field_size6, } = e; + let super::super::super::super::wasi::http0_2_0::types::FieldSizePayload { + field_name: field_name6, + field_size: field_size6, + } = e; match field_name6 { Some(e) => { *ptr1.add(20).cast::() = (1i32) as u8; @@ -16116,8 +16808,7 @@ pub mod exports { let len7 = vec7.len(); ::core::mem::forget(vec7); *ptr1.add(28).cast::() = len7; - *ptr1.add(24).cast::<*mut u8>() = - ptr7.cast_mut(); + *ptr1.add(24).cast::<*mut u8>() = ptr7.cast_mut(); } None => { *ptr1.add(20).cast::() = (0i32) as u8; @@ -16152,7 +16843,10 @@ pub mod exports { } V17::HttpRequestTrailerSize(e) => { *ptr1.add(8).cast::() = (24i32) as u8; - let super::super::super::super::wasi::http0_2_0::types::FieldSizePayload{ field_name:field_name8, field_size:field_size8, } = e; + let super::super::super::super::wasi::http0_2_0::types::FieldSizePayload { + field_name: field_name8, + field_size: field_size8, + } = e; match field_name8 { Some(e) => { *ptr1.add(16).cast::() = (1i32) as u8; @@ -16194,7 +16888,10 @@ pub mod exports { } V17::HttpResponseHeaderSize(e) => { *ptr1.add(8).cast::() = (27i32) as u8; - let super::super::super::super::wasi::http0_2_0::types::FieldSizePayload{ field_name:field_name10, field_size:field_size10, } = e; + let super::super::super::super::wasi::http0_2_0::types::FieldSizePayload { + field_name: field_name10, + field_size: field_size10, + } = e; match field_name10 { Some(e) => { *ptr1.add(16).cast::() = (1i32) as u8; @@ -16245,7 +16942,10 @@ pub mod exports { } V17::HttpResponseTrailerSize(e) => { *ptr1.add(8).cast::() = (30i32) as u8; - let super::super::super::super::wasi::http0_2_0::types::FieldSizePayload{ field_name:field_name12, field_size:field_size12, } = e; + let super::super::super::super::wasi::http0_2_0::types::FieldSizePayload { + field_name: field_name12, + field_size: field_size12, + } = e; match field_name12 { Some(e) => { *ptr1.add(16).cast::() = (1i32) as u8; @@ -16346,15 +17046,15 @@ pub mod exports { pub unsafe fn __post_return_handle(arg0: *mut u8) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { - 0 => (), + 0 => {} _ => { let l1 = i32::from(*arg0.add(8).cast::()); match l1 { - 0 => (), + 0 => {} 1 => { let l2 = i32::from(*arg0.add(16).cast::()); match l2 { - 0 => (), + 0 => {} _ => { let l3 = *arg0.add(20).cast::<*mut u8>(); let l4 = *arg0.add(24).cast::(); @@ -16362,22 +17062,22 @@ pub mod exports { } } } - 2 => (), - 3 => (), - 4 => (), - 5 => (), - 6 => (), - 7 => (), - 8 => (), - 9 => (), - 10 => (), - 11 => (), - 12 => (), - 13 => (), + 2 => {} + 3 => {} + 4 => {} + 5 => {} + 6 => {} + 7 => {} + 8 => {} + 9 => {} + 10 => {} + 11 => {} + 12 => {} + 13 => {} 14 => { let l5 = i32::from(*arg0.add(20).cast::()); match l5 { - 0 => (), + 0 => {} _ => { let l6 = *arg0.add(24).cast::<*mut u8>(); let l7 = *arg0.add(28).cast::(); @@ -16385,21 +17085,21 @@ pub mod exports { } } } - 15 => (), - 16 => (), - 17 => (), - 18 => (), - 19 => (), - 20 => (), - 21 => (), + 15 => {} + 16 => {} + 17 => {} + 18 => {} + 19 => {} + 20 => {} + 21 => {} 22 => { let l8 = i32::from(*arg0.add(16).cast::()); match l8 { - 0 => (), + 0 => {} _ => { let l9 = i32::from(*arg0.add(20).cast::()); match l9 { - 0 => (), + 0 => {} _ => { let l10 = *arg0.add(24).cast::<*mut u8>(); let l11 = *arg0.add(28).cast::(); @@ -16409,11 +17109,11 @@ pub mod exports { } } } - 23 => (), + 23 => {} 24 => { let l12 = i32::from(*arg0.add(16).cast::()); match l12 { - 0 => (), + 0 => {} _ => { let l13 = *arg0.add(20).cast::<*mut u8>(); let l14 = *arg0.add(24).cast::(); @@ -16421,12 +17121,12 @@ pub mod exports { } } } - 25 => (), - 26 => (), + 25 => {} + 26 => {} 27 => { let l15 = i32::from(*arg0.add(16).cast::()); match l15 { - 0 => (), + 0 => {} _ => { let l16 = *arg0.add(20).cast::<*mut u8>(); let l17 = *arg0.add(24).cast::(); @@ -16434,12 +17134,12 @@ pub mod exports { } } } - 28 => (), - 29 => (), + 28 => {} + 29 => {} 30 => { let l18 = i32::from(*arg0.add(16).cast::()); match l18 { - 0 => (), + 0 => {} _ => { let l19 = *arg0.add(20).cast::<*mut u8>(); let l20 = *arg0.add(24).cast::(); @@ -16450,7 +17150,7 @@ pub mod exports { 31 => { let l21 = i32::from(*arg0.add(16).cast::()); match l21 { - 0 => (), + 0 => {} _ => { let l22 = *arg0.add(20).cast::<*mut u8>(); let l23 = *arg0.add(24).cast::(); @@ -16461,7 +17161,7 @@ pub mod exports { 32 => { let l24 = i32::from(*arg0.add(16).cast::()); match l24 { - 0 => (), + 0 => {} _ => { let l25 = *arg0.add(20).cast::<*mut u8>(); let l26 = *arg0.add(24).cast::(); @@ -16469,15 +17169,15 @@ pub mod exports { } } } - 33 => (), - 34 => (), - 35 => (), - 36 => (), - 37 => (), + 33 => {} + 34 => {} + 35 => {} + 36 => {} + 37 => {} _ => { let l27 = i32::from(*arg0.add(16).cast::()); match l27 { - 0 => (), + 0 => {} _ => { let l28 = *arg0.add(20).cast::<*mut u8>(); let l29 = *arg0.add(24).cast::(); @@ -16490,31 +17190,41 @@ pub mod exports { } } pub trait Guest { + /// 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`. fn handle( request: OutgoingRequest, options: Option, ) -> Result; } #[doc(hidden)] - - macro_rules! __export_wasi_http_outgoing_handler_0_2_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "wasi:http/outgoing-handler@0.2.0#handle"] - unsafe extern "C" fn export_handle(arg0: i32,arg1: i32,arg2: i32,) -> *mut u8 { - $($path_to_types)*::_export_handle_cabi::<$ty>(arg0, arg1, arg2) - } - #[export_name = "cabi_post_wasi:http/outgoing-handler@0.2.0#handle"] - unsafe extern "C" fn _post_return_handle(arg0: *mut u8,) { - $($path_to_types)*::__post_return_handle::<$ty>(arg0) - } - };); - } + macro_rules! __export_wasi_http_outgoing_handler_0_2_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "wasi:http/outgoing-handler@0.2.0#handle"] unsafe extern "C" fn + export_handle(arg0 : i32, arg1 : i32, arg2 : i32,) -> * mut u8 { + $($path_to_types)*:: _export_handle_cabi::<$ty > (arg0, arg1, + arg2) } #[export_name = + "cabi_post_wasi:http/outgoing-handler@0.2.0#handle"] unsafe + extern "C" fn _post_return_handle(arg0 : * mut u8,) { + $($path_to_types)*:: __post_return_handle::<$ty > (arg0) } }; + }; + } #[doc(hidden)] pub(crate) use __export_wasi_http_outgoing_handler_0_2_0_cabi; #[repr(align(8))] struct _RetArea([::core::mem::MaybeUninit; 40]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 40]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 40], + ); } } #[allow(dead_code)] @@ -16523,25 +17233,18 @@ pub mod exports { pub mod ip_name_lookup { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; pub type Pollable = super::super::super::super::wasi::io0_2_0::poll::Pollable; pub type Network = super::super::super::super::wasi::sockets0_2_0::network::Network; - pub type ErrorCode = - super::super::super::super::wasi::sockets0_2_0::network::ErrorCode; - pub type IpAddress = - super::super::super::super::wasi::sockets0_2_0::network::IpAddress; - + pub type ErrorCode = super::super::super::super::wasi::sockets0_2_0::network::ErrorCode; + pub type IpAddress = super::super::super::super::wasi::sockets0_2_0::network::IpAddress; #[derive(Debug)] #[repr(transparent)] pub struct ResolveAddressStream { handle: _rt::Resource, } - type _ResolveAddressStreamRep = Option; - impl ResolveAddressStream { /// Creates a new resource from the specified representation. /// @@ -16551,72 +17254,65 @@ pub mod exports { pub fn new(val: T) -> Self { Self::type_guard::(); let val: _ResolveAddressStreamRep = Some(val); - let ptr: *mut _ResolveAddressStreamRep = - _rt::Box::into_raw(_rt::Box::new(val)); + let ptr: *mut _ResolveAddressStreamRep = _rt::Box::into_raw( + _rt::Box::new(val), + ); unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } } - /// Gets access to the underlying `T` which represents this resource. pub fn get(&self) -> &T { let ptr = unsafe { &*self.as_ptr::() }; ptr.as_ref().unwrap() } - /// Gets mutable access to the underlying `T` which represents this /// resource. pub fn get_mut(&mut self) -> &mut T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_mut().unwrap() } - /// Consumes this resource and returns the underlying `T`. pub fn into_inner(self) -> T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.take().unwrap() } - #[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) } - - // It's theoretically possible to implement the `GuestResolveAddressStream` trait twice - // so guard against using it with two different types here. #[doc(hidden)] fn type_guard() { use core::any::TypeId; static mut LAST_TYPE: Option = None; unsafe { - assert!(!cfg!(target_feature = "threads")); + assert!(! cfg!(target_feature = "atomics")); let id = TypeId::of::(); match LAST_TYPE { - Some(ty) => assert!( - ty == id, - "cannot use two types with this resource type" - ), + Some(ty) => { + assert!( + ty == id, "cannot use two types with this resource type" + ) + } None => LAST_TYPE = Some(id), } } } - #[doc(hidden)] pub unsafe fn dtor(handle: *mut u8) { Self::type_guard::(); - let _ = _rt::Box::from_raw(handle as *mut _ResolveAddressStreamRep); + let _ = _rt::Box::from_raw( + handle as *mut _ResolveAddressStreamRep, + ); } - fn as_ptr( &self, ) -> *mut _ResolveAddressStreamRep { @@ -16624,7 +17320,6 @@ pub mod exports { T::_resource_rep(self.handle()).cast() } } - /// A borrowed version of [`ResolveAddressStream`] which represents a borrowed value /// with the lifetime `'a`. #[derive(Debug)] @@ -16633,7 +17328,6 @@ pub mod exports { rep: *mut u8, _marker: core::marker::PhantomData<&'a ResolveAddressStream>, } - impl<'a> ResolveAddressStreamBorrow<'a> { #[doc(hidden)] pub unsafe fn lift(rep: usize) -> Self { @@ -16642,28 +17336,21 @@ pub mod exports { _marker: core::marker::PhantomData, } } - /// Gets access to the underlying `T` in this resource. pub fn get(&self) -> &T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_ref().unwrap() } - - // NB: mutable access is not allowed due to the component model allowing - // multiple borrows of the same resource. - fn as_ptr(&self) -> *mut _ResolveAddressStreamRep { ResolveAddressStream::type_guard::(); self.rep.cast() } } - unsafe impl _rt::WasmResource for ResolveAddressStream { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - #[cfg(target_arch = "wasm32")] { #[link( @@ -16673,21 +17360,16 @@ pub mod exports { #[link_name = "[resource-drop]resolve-address-stream"] fn drop(_: u32); } - drop(_handle); } } } - #[doc(hidden)] #[allow(non_snake_case)] pub unsafe fn _export_method_resolve_address_stream_resolve_next_address_cabi< T: GuestResolveAddressStream, - >( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::resolve_next_address( ResolveAddressStreamBorrow::lift(arg0 as u32 as usize).get(), ); @@ -16710,22 +17392,15 @@ pub mod exports { } V4::Ipv6(e) => { *ptr1.add(4).cast::() = (1i32) as u8; - let (t3_0, t3_1, t3_2, t3_3, t3_4, t3_5, t3_6, t3_7) = - e; + let (t3_0, t3_1, t3_2, t3_3, t3_4, t3_5, t3_6, t3_7) = e; *ptr1.add(6).cast::() = (_rt::as_i32(t3_0)) as u16; *ptr1.add(8).cast::() = (_rt::as_i32(t3_1)) as u16; - *ptr1.add(10).cast::() = - (_rt::as_i32(t3_2)) as u16; - *ptr1.add(12).cast::() = - (_rt::as_i32(t3_3)) as u16; - *ptr1.add(14).cast::() = - (_rt::as_i32(t3_4)) as u16; - *ptr1.add(16).cast::() = - (_rt::as_i32(t3_5)) as u16; - *ptr1.add(18).cast::() = - (_rt::as_i32(t3_6)) as u16; - *ptr1.add(20).cast::() = - (_rt::as_i32(t3_7)) as u16; + *ptr1.add(10).cast::() = (_rt::as_i32(t3_2)) as u16; + *ptr1.add(12).cast::() = (_rt::as_i32(t3_3)) as u16; + *ptr1.add(14).cast::() = (_rt::as_i32(t3_4)) as u16; + *ptr1.add(16).cast::() = (_rt::as_i32(t3_5)) as u16; + *ptr1.add(18).cast::() = (_rt::as_i32(t3_6)) as u16; + *ptr1.add(20).cast::() = (_rt::as_i32(t3_7)) as u16; } } } @@ -16745,13 +17420,11 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_resolve_address_stream_subscribe_cabi< T: GuestResolveAddressStream, - >( - arg0: *mut u8, - ) -> i32 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::subscribe(ResolveAddressStreamBorrow::lift(arg0 as u32 as usize).get()); + >(arg0: *mut u8) -> i32 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::subscribe( + ResolveAddressStreamBorrow::lift(arg0 as u32 as usize).get(), + ); (result0).take_handle() as i32 } #[doc(hidden)] @@ -16761,14 +17434,15 @@ pub mod exports { arg1: *mut u8, arg2: usize, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let handle0; let len1 = arg2; let bytes1 = _rt::Vec::from_raw_parts(arg1.cast(), len1, len1); let result2 = T::resolve_addresses( { - handle0 = super::super::super::super::wasi::sockets0_2_0::network::Network::from_handle(arg0 as u32); + handle0 = super::super::super::super::wasi::sockets0_2_0::network::Network::from_handle( + arg0 as u32, + ); &handle0 }, _rt::string_lift(bytes1), @@ -16788,6 +17462,26 @@ pub mod exports { } pub trait Guest { type ResolveAddressStream: GuestResolveAddressStream; + /// Resolve an internet host name to a list of IP addresses. + /// + /// Unicode domain names are automatically converted to ASCII using IDNA encoding. + /// If the input is an IP address string, the address is parsed and returned + /// as-is without making any external requests. + /// + /// See the wasi-socket proposal README.md for a comparison with getaddrinfo. + /// + /// This function never blocks. It either immediately fails or immediately + /// returns successfully with a `resolve-address-stream` that can be used + /// to (asynchronously) fetch the results. + /// + /// # Typical errors + /// - `invalid-argument`: `name` is a syntactically invalid domain name or IP address. + /// + /// # References: + /// - + /// - + /// - + /// - fn resolve_addresses( network: &Network, name: _rt::String, @@ -16804,7 +17498,6 @@ pub mod exports { let _ = val; unreachable!(); } - #[cfg(target_arch = "wasm32")] { #[link( @@ -16817,7 +17510,6 @@ pub mod exports { new(val) } } - #[doc(hidden)] fn _resource_rep(handle: u32) -> *mut u8 where @@ -16828,7 +17520,6 @@ pub mod exports { let _ = handle; unreachable!(); } - #[cfg(target_arch = "wasm32")] { #[link( @@ -16841,114 +17532,149 @@ pub mod exports { unsafe { rep(handle) } } } - - fn resolve_next_address(&self) -> Result, ErrorCode>; + /// Returns the next address from the resolver. + /// + /// This function should be called multiple times. On each call, it will + /// return the next address in connection order preference. If all + /// addresses have been exhausted, this function returns `none`. + /// + /// This function never returns IPv4-mapped IPv6 addresses. + /// + /// # Typical errors + /// - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY) + /// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN) + /// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL) + /// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN) + fn resolve_next_address( + &self, + ) -> Result, ErrorCode>; + /// Create a `pollable` which will resolve once the stream is ready for I/O. + /// + /// Note: this function is here for WASI Preview2 only. + /// It's planned to be removed when `future` is natively supported in Preview3. fn subscribe(&self) -> Pollable; } #[doc(hidden)] - - macro_rules! __export_wasi_sockets_ip_name_lookup_0_2_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "wasi:sockets/ip-name-lookup@0.2.0#[method]resolve-address-stream.resolve-next-address"] - unsafe extern "C" fn export_method_resolve_address_stream_resolve_next_address(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_resolve_address_stream_resolve_next_address_cabi::<<$ty as $($path_to_types)*::Guest>::ResolveAddressStream>(arg0) - } - #[export_name = "wasi:sockets/ip-name-lookup@0.2.0#[method]resolve-address-stream.subscribe"] - unsafe extern "C" fn export_method_resolve_address_stream_subscribe(arg0: *mut u8,) -> i32 { - $($path_to_types)*::_export_method_resolve_address_stream_subscribe_cabi::<<$ty as $($path_to_types)*::Guest>::ResolveAddressStream>(arg0) - } - #[export_name = "wasi:sockets/ip-name-lookup@0.2.0#resolve-addresses"] - unsafe extern "C" fn export_resolve_addresses(arg0: i32,arg1: *mut u8,arg2: usize,) -> *mut u8 { - $($path_to_types)*::_export_resolve_addresses_cabi::<$ty>(arg0, arg1, arg2) - } - - const _: () = { - #[doc(hidden)] - #[export_name = "wasi:sockets/ip-name-lookup@0.2.0#[dtor]resolve-address-stream"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: *mut u8) { - $($path_to_types)*::ResolveAddressStream::dtor::< - <$ty as $($path_to_types)*::Guest>::ResolveAddressStream - >(rep) - } - }; - - };); - } + macro_rules! __export_wasi_sockets_ip_name_lookup_0_2_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "wasi:sockets/ip-name-lookup@0.2.0#[method]resolve-address-stream.resolve-next-address"] + unsafe extern "C" fn + export_method_resolve_address_stream_resolve_next_address(arg0 : + * mut u8,) -> * mut u8 { $($path_to_types)*:: + _export_method_resolve_address_stream_resolve_next_address_cabi::<<$ty + as $($path_to_types)*:: Guest >::ResolveAddressStream > (arg0) } + #[export_name = + "wasi:sockets/ip-name-lookup@0.2.0#[method]resolve-address-stream.subscribe"] + unsafe extern "C" fn + export_method_resolve_address_stream_subscribe(arg0 : * mut u8,) + -> i32 { $($path_to_types)*:: + _export_method_resolve_address_stream_subscribe_cabi::<<$ty as + $($path_to_types)*:: Guest >::ResolveAddressStream > (arg0) } + #[export_name = + "wasi:sockets/ip-name-lookup@0.2.0#resolve-addresses"] unsafe + extern "C" fn export_resolve_addresses(arg0 : i32, arg1 : * mut + u8, arg2 : usize,) -> * mut u8 { $($path_to_types)*:: + _export_resolve_addresses_cabi::<$ty > (arg0, arg1, arg2) } const + _ : () = { #[doc(hidden)] #[export_name = + "wasi:sockets/ip-name-lookup@0.2.0#[dtor]resolve-address-stream"] + #[allow(non_snake_case)] unsafe extern "C" fn dtor(rep : * mut + u8) { $($path_to_types)*:: ResolveAddressStream::dtor::< <$ty as + $($path_to_types)*:: Guest >::ResolveAddressStream > (rep) } }; + }; + }; + } #[doc(hidden)] pub(crate) use __export_wasi_sockets_ip_name_lookup_0_2_0_cabi; #[repr(align(4))] struct _RetArea([::core::mem::MaybeUninit; 22]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 22]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 22], + ); } - #[allow(dead_code, clippy::all)] pub mod tcp { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; - pub type InputStream = - super::super::super::super::wasi::io0_2_0::streams::InputStream; - pub type OutputStream = - super::super::super::super::wasi::io0_2_0::streams::OutputStream; + pub type InputStream = super::super::super::super::wasi::io0_2_0::streams::InputStream; + pub type OutputStream = super::super::super::super::wasi::io0_2_0::streams::OutputStream; pub type Pollable = super::super::super::super::wasi::io0_2_0::poll::Pollable; - pub type Duration = - super::super::super::super::wasi::clocks0_2_0::monotonic_clock::Duration; + pub type Duration = super::super::super::super::wasi::clocks0_2_0::monotonic_clock::Duration; pub type Network = super::super::super::super::wasi::sockets0_2_0::network::Network; - pub type ErrorCode = - super::super::super::super::wasi::sockets0_2_0::network::ErrorCode; - pub type IpSocketAddress = - super::super::super::super::wasi::sockets0_2_0::network::IpSocketAddress; - pub type IpAddressFamily = - super::super::super::super::wasi::sockets0_2_0::network::IpAddressFamily; + pub type ErrorCode = super::super::super::super::wasi::sockets0_2_0::network::ErrorCode; + pub type IpSocketAddress = super::super::super::super::wasi::sockets0_2_0::network::IpSocketAddress; + pub type IpAddressFamily = super::super::super::super::wasi::sockets0_2_0::network::IpAddressFamily; #[repr(u8)] - #[derive(Clone, Copy, Eq, PartialEq)] + #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] pub enum ShutdownType { + /// Similar to `SHUT_RD` in POSIX. Receive, + /// Similar to `SHUT_WR` in POSIX. Send, + /// Similar to `SHUT_RDWR` in POSIX. Both, } impl ::core::fmt::Debug for ShutdownType { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { match self { ShutdownType::Receive => { f.debug_tuple("ShutdownType::Receive").finish() } - ShutdownType::Send => f.debug_tuple("ShutdownType::Send").finish(), - ShutdownType::Both => f.debug_tuple("ShutdownType::Both").finish(), + ShutdownType::Send => { + f.debug_tuple("ShutdownType::Send").finish() + } + ShutdownType::Both => { + f.debug_tuple("ShutdownType::Both").finish() + } } } } - impl ShutdownType { #[doc(hidden)] pub unsafe fn _lift(val: u8) -> ShutdownType { if !cfg!(debug_assertions) { return ::core::mem::transmute(val); } - match val { 0 => ShutdownType::Receive, 1 => ShutdownType::Send, 2 => ShutdownType::Both, - _ => panic!("invalid enum discriminant"), } } } - + /// A TCP socket resource. + /// + /// The socket can be in one of the following states: + /// - `unbound` + /// - `bind-in-progress` + /// - `bound` (See note below) + /// - `listen-in-progress` + /// - `listening` + /// - `connect-in-progress` + /// - `connected` + /// - `closed` + /// See + /// for a more information. + /// + /// Note: Except where explicitly mentioned, whenever this documentation uses + /// the term "bound" without backticks it actually means: in the `bound` state *or higher*. + /// (i.e. `bound`, `listen-in-progress`, `listening`, `connect-in-progress` or `connected`) + /// + /// In addition to the general error codes documented on the + /// `network::error-code` type, TCP socket methods may always return + /// `error(invalid-state)` when in the `closed` state. #[derive(Debug)] #[repr(transparent)] pub struct TcpSocket { handle: _rt::Resource, } - type _TcpSocketRep = Option; - impl TcpSocket { /// Creates a new resource from the specified representation. /// @@ -16958,77 +17684,68 @@ pub mod exports { pub fn new(val: T) -> Self { Self::type_guard::(); let val: _TcpSocketRep = Some(val); - let ptr: *mut _TcpSocketRep = _rt::Box::into_raw(_rt::Box::new(val)); + let ptr: *mut _TcpSocketRep = _rt::Box::into_raw( + _rt::Box::new(val), + ); unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } } - /// Gets access to the underlying `T` which represents this resource. pub fn get(&self) -> &T { let ptr = unsafe { &*self.as_ptr::() }; ptr.as_ref().unwrap() } - /// Gets mutable access to the underlying `T` which represents this /// resource. pub fn get_mut(&mut self) -> &mut T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_mut().unwrap() } - /// Consumes this resource and returns the underlying `T`. pub fn into_inner(self) -> T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.take().unwrap() } - #[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) } - - // It's theoretically possible to implement the `GuestTcpSocket` trait twice - // so guard against using it with two different types here. #[doc(hidden)] fn type_guard() { use core::any::TypeId; static mut LAST_TYPE: Option = None; unsafe { - assert!(!cfg!(target_feature = "threads")); + assert!(! cfg!(target_feature = "atomics")); let id = TypeId::of::(); match LAST_TYPE { - Some(ty) => assert!( - ty == id, - "cannot use two types with this resource type" - ), + Some(ty) => { + assert!( + ty == id, "cannot use two types with this resource type" + ) + } None => LAST_TYPE = Some(id), } } } - #[doc(hidden)] pub unsafe fn dtor(handle: *mut u8) { Self::type_guard::(); let _ = _rt::Box::from_raw(handle as *mut _TcpSocketRep); } - fn as_ptr(&self) -> *mut _TcpSocketRep { TcpSocket::type_guard::(); T::_resource_rep(self.handle()).cast() } } - /// A borrowed version of [`TcpSocket`] which represents a borrowed value /// with the lifetime `'a`. #[derive(Debug)] @@ -17037,7 +17754,6 @@ pub mod exports { rep: *mut u8, _marker: core::marker::PhantomData<&'a TcpSocket>, } - impl<'a> TcpSocketBorrow<'a> { #[doc(hidden)] pub unsafe fn lift(rep: usize) -> Self { @@ -17046,44 +17762,39 @@ pub mod exports { _marker: core::marker::PhantomData, } } - /// Gets access to the underlying `T` in this resource. pub fn get(&self) -> &T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_ref().unwrap() } - - // NB: mutable access is not allowed due to the component model allowing - // multiple borrows of the same resource. - fn as_ptr(&self) -> *mut _TcpSocketRep { TcpSocket::type_guard::(); self.rep.cast() } } - unsafe impl _rt::WasmResource for TcpSocket { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]wasi:sockets/tcp@0.2.0")] + #[link( + wasm_import_module = "[export]wasi:sockets/tcp@0.2.0" + )] extern "C" { #[link_name = "[resource-drop]tcp-socket"] fn drop(_: u32); } - drop(_handle); } } } - #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_start_bind_cabi( + pub unsafe fn _export_method_tcp_socket_start_bind_cabi< + T: GuestTcpSocket, + >( arg0: *mut u8, arg1: i32, arg2: i32, @@ -17099,33 +17810,43 @@ pub mod exports { arg12: i32, arg13: i32, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let handle0; use super::super::super::super::wasi::sockets0_2_0::network::IpSocketAddress as V1; let v1 = match arg2 { 0 => { - let e1 = super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress{ - port: arg3 as u16, - address: (arg4 as u8, arg5 as u8, arg6 as u8, arg7 as u8), - }; + let e1 = super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress { + port: arg3 as u16, + address: (arg4 as u8, arg5 as u8, arg6 as u8, arg7 as u8), + }; V1::Ipv4(e1) } n => { debug_assert_eq!(n, 1, "invalid enum discriminant"); - let e1 = super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress{ - port: arg3 as u16, - flow_info: arg4 as u32, - address: (arg5 as u16, arg6 as u16, arg7 as u16, arg8 as u16, arg9 as u16, arg10 as u16, arg11 as u16, arg12 as u16), - scope_id: arg13 as u32, - }; + let e1 = super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress { + port: arg3 as u16, + flow_info: arg4 as u32, + address: ( + arg5 as u16, + arg6 as u16, + arg7 as u16, + arg8 as u16, + arg9 as u16, + arg10 as u16, + arg11 as u16, + arg12 as u16, + ), + scope_id: arg13 as u32, + }; V1::Ipv6(e1) } }; let result2 = T::start_bind( TcpSocketBorrow::lift(arg0 as u32 as usize).get(), { - handle0 = super::super::super::super::wasi::sockets0_2_0::network::Network::from_handle(arg1 as u32); + handle0 = super::super::super::super::wasi::sockets0_2_0::network::Network::from_handle( + arg1 as u32, + ); &handle0 }, v1, @@ -17144,12 +17865,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_finish_bind_cabi( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = T::finish_bind(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_tcp_socket_finish_bind_cabi< + T: GuestTcpSocket, + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::finish_bind( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(_) => { @@ -17164,7 +17886,9 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_start_connect_cabi( + pub unsafe fn _export_method_tcp_socket_start_connect_cabi< + T: GuestTcpSocket, + >( arg0: *mut u8, arg1: i32, arg2: i32, @@ -17180,33 +17904,43 @@ pub mod exports { arg12: i32, arg13: i32, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let handle0; use super::super::super::super::wasi::sockets0_2_0::network::IpSocketAddress as V1; let v1 = match arg2 { 0 => { - let e1 = super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress{ + let e1 = super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress { port: arg3 as u16, address: (arg4 as u8, arg5 as u8, arg6 as u8, arg7 as u8), - }; + }; V1::Ipv4(e1) } n => { debug_assert_eq!(n, 1, "invalid enum discriminant"); - let e1 = super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress{ + let e1 = super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress { port: arg3 as u16, flow_info: arg4 as u32, - address: (arg5 as u16, arg6 as u16, arg7 as u16, arg8 as u16, arg9 as u16, arg10 as u16, arg11 as u16, arg12 as u16), + address: ( + arg5 as u16, + arg6 as u16, + arg7 as u16, + arg8 as u16, + arg9 as u16, + arg10 as u16, + arg11 as u16, + arg12 as u16, + ), scope_id: arg13 as u32, - }; + }; V1::Ipv6(e1) } }; let result2 = T::start_connect( TcpSocketBorrow::lift(arg0 as u32 as usize).get(), { - handle0 = super::super::super::super::wasi::sockets0_2_0::network::Network::from_handle(arg1 as u32); + handle0 = super::super::super::super::wasi::sockets0_2_0::network::Network::from_handle( + arg1 as u32, + ); &handle0 }, v1, @@ -17225,13 +17959,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_finish_connect_cabi( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::finish_connect(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_tcp_socket_finish_connect_cabi< + T: GuestTcpSocket, + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::finish_connect( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -17249,13 +17983,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_start_listen_cabi( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::start_listen(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_tcp_socket_start_listen_cabi< + T: GuestTcpSocket, + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::start_listen( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(_) => { @@ -17270,13 +18004,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_finish_listen_cabi( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::finish_listen(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_tcp_socket_finish_listen_cabi< + T: GuestTcpSocket, + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::finish_listen( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(_) => { @@ -17294,9 +18028,10 @@ pub mod exports { pub unsafe fn _export_method_tcp_socket_accept_cabi( arg0: *mut u8, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = T::accept(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::accept( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -17315,13 +18050,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_local_address_cabi( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::local_address(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_tcp_socket_local_address_cabi< + T: GuestTcpSocket, + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::local_address( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -17330,7 +18065,10 @@ pub mod exports { match e { V6::Ipv4(e) => { *ptr1.add(4).cast::() = (0i32) as u8; - let super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress{ port:port2, address:address2, } = e; + let super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress { + port: port2, + address: address2, + } = e; *ptr1.add(8).cast::() = (_rt::as_i32(port2)) as u16; let (t3_0, t3_1, t3_2, t3_3) = address2; *ptr1.add(10).cast::() = (_rt::as_i32(t3_0)) as u8; @@ -17340,7 +18078,12 @@ pub mod exports { } V6::Ipv6(e) => { *ptr1.add(4).cast::() = (1i32) as u8; - let super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress{ port:port4, flow_info:flow_info4, address:address4, scope_id:scope_id4, } = e; + let super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress { + port: port4, + flow_info: flow_info4, + address: address4, + scope_id: scope_id4, + } = e; *ptr1.add(8).cast::() = (_rt::as_i32(port4)) as u16; *ptr1.add(12).cast::() = _rt::as_i32(flow_info4); let (t5_0, t5_1, t5_2, t5_3, t5_4, t5_5, t5_6, t5_7) = address4; @@ -17365,13 +18108,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_remote_address_cabi( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::remote_address(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_tcp_socket_remote_address_cabi< + T: GuestTcpSocket, + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::remote_address( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -17380,7 +18123,10 @@ pub mod exports { match e { V6::Ipv4(e) => { *ptr1.add(4).cast::() = (0i32) as u8; - let super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress{ port:port2, address:address2, } = e; + let super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress { + port: port2, + address: address2, + } = e; *ptr1.add(8).cast::() = (_rt::as_i32(port2)) as u16; let (t3_0, t3_1, t3_2, t3_3) = address2; *ptr1.add(10).cast::() = (_rt::as_i32(t3_0)) as u8; @@ -17390,7 +18136,12 @@ pub mod exports { } V6::Ipv6(e) => { *ptr1.add(4).cast::() = (1i32) as u8; - let super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress{ port:port4, flow_info:flow_info4, address:address4, scope_id:scope_id4, } = e; + let super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress { + port: port4, + flow_info: flow_info4, + address: address4, + scope_id: scope_id4, + } = e; *ptr1.add(8).cast::() = (_rt::as_i32(port4)) as u16; *ptr1.add(12).cast::() = _rt::as_i32(flow_info4); let (t5_0, t5_1, t5_2, t5_3, t5_4, t5_5, t5_6, t5_7) = address4; @@ -17415,13 +18166,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_is_listening_cabi( - arg0: *mut u8, - ) -> i32 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::is_listening(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_tcp_socket_is_listening_cabi< + T: GuestTcpSocket, + >(arg0: *mut u8) -> i32 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::is_listening( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); match result0 { true => 1, false => 0, @@ -17429,25 +18180,21 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_address_family_cabi( - arg0: *mut u8, - ) -> i32 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::address_family(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_tcp_socket_address_family_cabi< + T: GuestTcpSocket, + >(arg0: *mut u8) -> i32 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::address_family( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); result0.clone() as i32 } #[doc(hidden)] #[allow(non_snake_case)] pub unsafe fn _export_method_tcp_socket_set_listen_backlog_size_cabi< T: GuestTcpSocket, - >( - arg0: *mut u8, - arg1: i64, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8, arg1: i64) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::set_listen_backlog_size( TcpSocketBorrow::lift(arg0 as u32 as usize).get(), arg1 as u64, @@ -17468,13 +18215,11 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_tcp_socket_keep_alive_enabled_cabi< T: GuestTcpSocket, - >( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::keep_alive_enabled(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::keep_alive_enabled( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -17495,12 +18240,8 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_tcp_socket_set_keep_alive_enabled_cabi< T: GuestTcpSocket, - >( - arg0: *mut u8, - arg1: i32, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8, arg1: i32) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::set_keep_alive_enabled( TcpSocketBorrow::lift(arg0 as u32 as usize).get(), _rt::bool_lift(arg1 as u8), @@ -17521,13 +18262,11 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_tcp_socket_keep_alive_idle_time_cabi< T: GuestTcpSocket, - >( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::keep_alive_idle_time(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::keep_alive_idle_time( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -17545,12 +18284,8 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_tcp_socket_set_keep_alive_idle_time_cabi< T: GuestTcpSocket, - >( - arg0: *mut u8, - arg1: i64, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8, arg1: i64) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::set_keep_alive_idle_time( TcpSocketBorrow::lift(arg0 as u32 as usize).get(), arg1 as u64, @@ -17571,13 +18306,11 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_tcp_socket_keep_alive_interval_cabi< T: GuestTcpSocket, - >( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::keep_alive_interval(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::keep_alive_interval( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -17595,12 +18328,8 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_tcp_socket_set_keep_alive_interval_cabi< T: GuestTcpSocket, - >( - arg0: *mut u8, - arg1: i64, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8, arg1: i64) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::set_keep_alive_interval( TcpSocketBorrow::lift(arg0 as u32 as usize).get(), arg1 as u64, @@ -17619,13 +18348,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_keep_alive_count_cabi( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::keep_alive_count(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_tcp_socket_keep_alive_count_cabi< + T: GuestTcpSocket, + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::keep_alive_count( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -17643,12 +18372,8 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_tcp_socket_set_keep_alive_count_cabi< T: GuestTcpSocket, - >( - arg0: *mut u8, - arg1: i32, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8, arg1: i32) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::set_keep_alive_count( TcpSocketBorrow::lift(arg0 as u32 as usize).get(), arg1 as u32, @@ -17667,12 +18392,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_hop_limit_cabi( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = T::hop_limit(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_tcp_socket_hop_limit_cabi< + T: GuestTcpSocket, + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::hop_limit( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -17688,12 +18414,10 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_set_hop_limit_cabi( - arg0: *mut u8, - arg1: i32, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + pub unsafe fn _export_method_tcp_socket_set_hop_limit_cabi< + T: GuestTcpSocket, + >(arg0: *mut u8, arg1: i32) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::set_hop_limit( TcpSocketBorrow::lift(arg0 as u32 as usize).get(), arg1 as u8, @@ -17714,13 +18438,11 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_tcp_socket_receive_buffer_size_cabi< T: GuestTcpSocket, - >( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::receive_buffer_size(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::receive_buffer_size( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -17738,12 +18460,8 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_tcp_socket_set_receive_buffer_size_cabi< T: GuestTcpSocket, - >( - arg0: *mut u8, - arg1: i64, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8, arg1: i64) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::set_receive_buffer_size( TcpSocketBorrow::lift(arg0 as u32 as usize).get(), arg1 as u64, @@ -17762,13 +18480,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_send_buffer_size_cabi( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::send_buffer_size(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_tcp_socket_send_buffer_size_cabi< + T: GuestTcpSocket, + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::send_buffer_size( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -17786,12 +18504,8 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_tcp_socket_set_send_buffer_size_cabi< T: GuestTcpSocket, - >( - arg0: *mut u8, - arg1: i64, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8, arg1: i64) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::set_send_buffer_size( TcpSocketBorrow::lift(arg0 as u32 as usize).get(), arg1 as u64, @@ -17810,12 +18524,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_tcp_socket_subscribe_cabi( - arg0: *mut u8, - ) -> i32 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = T::subscribe(TcpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_tcp_socket_subscribe_cabi< + T: GuestTcpSocket, + >(arg0: *mut u8) -> i32 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::subscribe( + TcpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); (result0).take_handle() as i32 } #[doc(hidden)] @@ -17824,8 +18539,7 @@ pub mod exports { arg0: *mut u8, arg1: i32, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::shutdown( TcpSocketBorrow::lift(arg0 as u32 as usize).get(), ShutdownType::_lift(arg1 as u8), @@ -17856,10 +18570,11 @@ pub mod exports { let _ = val; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]wasi:sockets/tcp@0.2.0")] + #[link( + wasm_import_module = "[export]wasi:sockets/tcp@0.2.0" + )] extern "C" { #[link_name = "[resource-new]tcp-socket"] fn new(_: *mut u8) -> u32; @@ -17867,7 +18582,6 @@ pub mod exports { new(val) } } - #[doc(hidden)] fn _resource_rep(handle: u32) -> *mut u8 where @@ -17878,10 +18592,11 @@ pub mod exports { let _ = handle; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]wasi:sockets/tcp@0.2.0")] + #[link( + wasm_import_module = "[export]wasi:sockets/tcp@0.2.0" + )] extern "C" { #[link_name = "[resource-rep]tcp-socket"] fn rep(_: u32) -> *mut u8; @@ -17889,233 +18604,676 @@ pub mod exports { unsafe { rep(handle) } } } - + /// Bind the socket to a specific network on the provided IP address and port. + /// + /// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is left to the implementation to decide which + /// network interface(s) to bind to. + /// If the TCP/UDP port is zero, the socket will be bound to a random free port. + /// + /// Bind can be attempted multiple times on the same socket, even with + /// different arguments on each iteration. But never concurrently and + /// only as long as the previous bind failed. Once a bind succeeds, the + /// binding can't be changed anymore. + /// + /// # Typical errors + /// - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows) + /// - `invalid-argument`: `local-address` is not a unicast address. (EINVAL) + /// - `invalid-argument`: `local-address` is an IPv4-mapped IPv6 address. (EINVAL) + /// - `invalid-state`: The socket is already bound. (EINVAL) + /// - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS on Windows) + /// - `address-in-use`: Address is already in use. (EADDRINUSE) + /// - `address-not-bindable`: `local-address` is not an address that the `network` can bind to. (EADDRNOTAVAIL) + /// - `not-in-progress`: A `bind` operation is not in progress. + /// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) + /// + /// # Implementors note + /// When binding to a non-zero port, this bind operation shouldn't be affected by the TIME_WAIT + /// state of a recently closed socket on the same local address. In practice this means that the SO_REUSEADDR + /// socket option should be set implicitly on all platforms, except on Windows where this is the default behavior + /// and SO_REUSEADDR performs something different entirely. + /// + /// Unlike in POSIX, in WASI the bind operation is async. This enables + /// interactive WASI hosts to inject permission prompts. Runtimes that + /// don't want to make use of this ability can simply call the native + /// `bind` as part of either `start-bind` or `finish-bind`. + /// + /// # References + /// - + /// - + /// - + /// - fn start_bind( &self, network: &Network, local_address: IpSocketAddress, ) -> Result<(), ErrorCode>; fn finish_bind(&self) -> Result<(), ErrorCode>; + /// Connect to a remote endpoint. + /// + /// On success: + /// - the socket is transitioned into the `connection` state. + /// - a pair of streams is returned that can be used to read & write to the connection + /// + /// After a failed connection attempt, the socket will be in the `closed` + /// state and the only valid action left is to `drop` the socket. A single + /// socket can not be used to connect more than once. + /// + /// # Typical errors + /// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) + /// - `invalid-argument`: `remote-address` is not a unicast address. (EINVAL, ENETUNREACH on Linux, EAFNOSUPPORT on MacOS) + /// - `invalid-argument`: `remote-address` is an IPv4-mapped IPv6 address. (EINVAL, EADDRNOTAVAIL on Illumos) + /// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EADDRNOTAVAIL on Windows) + /// - `invalid-argument`: The port in `remote-address` is set to 0. (EADDRNOTAVAIL on Windows) + /// - `invalid-argument`: The socket is already attached to a different network. The `network` passed to `connect` must be identical to the one passed to `bind`. + /// - `invalid-state`: The socket is already in the `connected` state. (EISCONN) + /// - `invalid-state`: The socket is already in the `listening` state. (EOPNOTSUPP, EINVAL on Windows) + /// - `timeout`: Connection timed out. (ETIMEDOUT) + /// - `connection-refused`: The connection was forcefully rejected. (ECONNREFUSED) + /// - `connection-reset`: The connection was reset. (ECONNRESET) + /// - `connection-aborted`: The connection was aborted. (ECONNABORTED) + /// - `remote-unreachable`: The remote address is not reachable. (EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD) + /// - `not-in-progress`: A connect operation is not in progress. + /// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) + /// + /// # Implementors note + /// The POSIX equivalent of `start-connect` is the regular `connect` syscall. + /// Because all WASI sockets are non-blocking this is expected to return + /// EINPROGRESS, which should be translated to `ok()` in WASI. + /// + /// The POSIX equivalent of `finish-connect` is a `poll` for event `POLLOUT` + /// with a timeout of 0 on the socket descriptor. Followed by a check for + /// the `SO_ERROR` socket option, in case the poll signaled readiness. + /// + /// # References + /// - + /// - + /// - + /// - fn start_connect( &self, network: &Network, remote_address: IpSocketAddress, ) -> Result<(), ErrorCode>; - fn finish_connect(&self) -> Result<(InputStream, OutputStream), ErrorCode>; + fn finish_connect( + &self, + ) -> Result<(InputStream, OutputStream), ErrorCode>; + /// Start listening for new connections. + /// + /// Transitions the socket into the `listening` state. + /// + /// Unlike POSIX, the socket must already be explicitly bound. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not bound to any local address. (EDESTADDRREQ) + /// - `invalid-state`: The socket is already in the `connected` state. (EISCONN, EINVAL on BSD) + /// - `invalid-state`: The socket is already in the `listening` state. + /// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE) + /// - `not-in-progress`: A listen operation is not in progress. + /// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) + /// + /// # Implementors note + /// Unlike in POSIX, in WASI the listen operation is async. This enables + /// interactive WASI hosts to inject permission prompts. Runtimes that + /// don't want to make use of this ability can simply call the native + /// `listen` as part of either `start-listen` or `finish-listen`. + /// + /// # References + /// - + /// - + /// - + /// - fn start_listen(&self) -> Result<(), ErrorCode>; fn finish_listen(&self) -> Result<(), ErrorCode>; - fn accept(&self) -> Result<(TcpSocket, InputStream, OutputStream), ErrorCode>; + /// Accept a new client socket. + /// + /// The returned socket is bound and in the `connected` state. The following properties are inherited from the listener socket: + /// - `address-family` + /// - `keep-alive-enabled` + /// - `keep-alive-idle-time` + /// - `keep-alive-interval` + /// - `keep-alive-count` + /// - `hop-limit` + /// - `receive-buffer-size` + /// - `send-buffer-size` + /// + /// On success, this function returns the newly accepted client socket along with + /// a pair of streams that can be used to read & write to the connection. + /// + /// # Typical errors + /// - `invalid-state`: Socket is not in the `listening` state. (EINVAL) + /// - `would-block`: No pending connections at the moment. (EWOULDBLOCK, EAGAIN) + /// - `connection-aborted`: An incoming connection was pending, but was terminated by the client before this listener could accept it. (ECONNABORTED) + /// - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE) + /// + /// # References + /// - + /// - + /// - + /// - + fn accept( + &self, + ) -> Result<(TcpSocket, InputStream, OutputStream), ErrorCode>; + /// Get the bound local address. + /// + /// POSIX mentions: + /// > If the socket has not been bound to a local name, the value + /// > stored in the object pointed to by `address` is unspecified. + /// + /// WASI is stricter and requires `local-address` to return `invalid-state` when the socket hasn't been bound yet. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not bound to any local address. + /// + /// # References + /// - + /// - + /// - + /// - fn local_address(&self) -> Result; + /// Get the remote address. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not connected to a remote address. (ENOTCONN) + /// + /// # References + /// - + /// - + /// - + /// - fn remote_address(&self) -> Result; + /// Whether the socket is in the `listening` state. + /// + /// Equivalent to the SO_ACCEPTCONN socket option. fn is_listening(&self) -> bool; + /// Whether this is a IPv4 or IPv6 socket. + /// + /// Equivalent to the SO_DOMAIN socket option. fn address_family(&self) -> IpAddressFamily; - fn set_listen_backlog_size(&self, value: u64) -> Result<(), ErrorCode>; + /// Hints the desired listen queue size. Implementations are free to ignore this. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently clamped and/or rounded. + /// + /// # Typical errors + /// - `not-supported`: (set) The platform does not support changing the backlog size after the initial listen. + /// - `invalid-argument`: (set) The provided value was 0. + /// - `invalid-state`: (set) The socket is in the `connect-in-progress` or `connected` state. + fn set_listen_backlog_size( + &self, + value: u64, + ) -> Result<(), ErrorCode>; + /// Enables or disables keepalive. + /// + /// The keepalive behavior can be adjusted using: + /// - `keep-alive-idle-time` + /// - `keep-alive-interval` + /// - `keep-alive-count` + /// These properties can be configured while `keep-alive-enabled` is false, but only come into effect when `keep-alive-enabled` is true. + /// + /// Equivalent to the SO_KEEPALIVE socket option. fn keep_alive_enabled(&self) -> Result; - fn set_keep_alive_enabled(&self, value: bool) -> Result<(), ErrorCode>; + fn set_keep_alive_enabled( + &self, + value: bool, + ) -> Result<(), ErrorCode>; + /// Amount of time the connection has to be idle before TCP starts sending keepalive packets. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently clamped and/or rounded. + /// I.e. after setting a value, reading the same setting back may return a different value. + /// + /// Equivalent to the TCP_KEEPIDLE socket option. (TCP_KEEPALIVE on MacOS) + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. fn keep_alive_idle_time(&self) -> Result; - fn set_keep_alive_idle_time(&self, value: Duration) -> Result<(), ErrorCode>; + fn set_keep_alive_idle_time( + &self, + value: Duration, + ) -> Result<(), ErrorCode>; + /// The time between keepalive packets. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently clamped and/or rounded. + /// I.e. after setting a value, reading the same setting back may return a different value. + /// + /// Equivalent to the TCP_KEEPINTVL socket option. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. fn keep_alive_interval(&self) -> Result; - fn set_keep_alive_interval(&self, value: Duration) -> Result<(), ErrorCode>; + fn set_keep_alive_interval( + &self, + value: Duration, + ) -> Result<(), ErrorCode>; + /// The maximum amount of keepalive packets TCP should send before aborting the connection. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently clamped and/or rounded. + /// I.e. after setting a value, reading the same setting back may return a different value. + /// + /// Equivalent to the TCP_KEEPCNT socket option. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. fn keep_alive_count(&self) -> Result; fn set_keep_alive_count(&self, value: u32) -> Result<(), ErrorCode>; + /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The TTL value must be 1 or higher. fn hop_limit(&self) -> Result; fn set_hop_limit(&self, value: u8) -> Result<(), ErrorCode>; + /// The kernel buffer space reserved for sends/receives on this socket. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently clamped and/or rounded. + /// I.e. after setting a value, reading the same setting back may return a different value. + /// + /// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. fn receive_buffer_size(&self) -> Result; - fn set_receive_buffer_size(&self, value: u64) -> Result<(), ErrorCode>; + fn set_receive_buffer_size( + &self, + value: u64, + ) -> Result<(), ErrorCode>; fn send_buffer_size(&self) -> Result; fn set_send_buffer_size(&self, value: u64) -> Result<(), ErrorCode>; + /// Create a `pollable` which can be used to poll for, or block on, + /// completion of any of the asynchronous operations of this socket. + /// + /// When `finish-bind`, `finish-listen`, `finish-connect` or `accept` + /// return `error(would-block)`, this pollable can be used to wait for + /// their success or failure, after which the method can be retried. + /// + /// The pollable is not limited to the async operation that happens to be + /// in progress at the time of calling `subscribe` (if any). Theoretically, + /// `subscribe` only has to be called once per socket and can then be + /// (re)used for the remainder of the socket's lifetime. + /// + /// See + /// for a more information. + /// + /// Note: this function is here for WASI Preview2 only. + /// It's planned to be removed when `future` is natively supported in Preview3. fn subscribe(&self) -> Pollable; - fn shutdown(&self, shutdown_type: ShutdownType) -> Result<(), ErrorCode>; + /// Initiate a graceful shutdown. + /// + /// - `receive`: The socket is not expecting to receive any data from + /// the peer. The `input-stream` associated with this socket will be + /// closed. Any data still in the receive queue at time of calling + /// this method will be discarded. + /// - `send`: The socket has no more data to send to the peer. The `output-stream` + /// associated with this socket will be closed and a FIN packet will be sent. + /// - `both`: Same effect as `receive` & `send` combined. + /// + /// This function is idempotent. Shutting a down a direction more than once + /// has no effect and returns `ok`. + /// + /// The shutdown function does not close (drop) the socket. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not in the `connected` state. (ENOTCONN) + /// + /// # References + /// - + /// - + /// - + /// - + fn shutdown( + &self, + shutdown_type: ShutdownType, + ) -> Result<(), ErrorCode>; } #[doc(hidden)] - - macro_rules! __export_wasi_sockets_tcp_0_2_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.start-bind"] - unsafe extern "C" fn export_method_tcp_socket_start_bind(arg0: *mut u8,arg1: i32,arg2: i32,arg3: i32,arg4: i32,arg5: i32,arg6: i32,arg7: i32,arg8: i32,arg9: i32,arg10: i32,arg11: i32,arg12: i32,arg13: i32,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_start_bind_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.finish-bind"] - unsafe extern "C" fn export_method_tcp_socket_finish_bind(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_finish_bind_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.start-connect"] - unsafe extern "C" fn export_method_tcp_socket_start_connect(arg0: *mut u8,arg1: i32,arg2: i32,arg3: i32,arg4: i32,arg5: i32,arg6: i32,arg7: i32,arg8: i32,arg9: i32,arg10: i32,arg11: i32,arg12: i32,arg13: i32,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_start_connect_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.finish-connect"] - unsafe extern "C" fn export_method_tcp_socket_finish_connect(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_finish_connect_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.start-listen"] - unsafe extern "C" fn export_method_tcp_socket_start_listen(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_start_listen_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.finish-listen"] - unsafe extern "C" fn export_method_tcp_socket_finish_listen(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_finish_listen_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.accept"] - unsafe extern "C" fn export_method_tcp_socket_accept(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_accept_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.local-address"] - unsafe extern "C" fn export_method_tcp_socket_local_address(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_local_address_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.remote-address"] - unsafe extern "C" fn export_method_tcp_socket_remote_address(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_remote_address_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.is-listening"] - unsafe extern "C" fn export_method_tcp_socket_is_listening(arg0: *mut u8,) -> i32 { - $($path_to_types)*::_export_method_tcp_socket_is_listening_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.address-family"] - unsafe extern "C" fn export_method_tcp_socket_address_family(arg0: *mut u8,) -> i32 { - $($path_to_types)*::_export_method_tcp_socket_address_family_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-listen-backlog-size"] - unsafe extern "C" fn export_method_tcp_socket_set_listen_backlog_size(arg0: *mut u8,arg1: i64,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_set_listen_backlog_size_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0, arg1) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.keep-alive-enabled"] - unsafe extern "C" fn export_method_tcp_socket_keep_alive_enabled(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_keep_alive_enabled_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-keep-alive-enabled"] - unsafe extern "C" fn export_method_tcp_socket_set_keep_alive_enabled(arg0: *mut u8,arg1: i32,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_set_keep_alive_enabled_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0, arg1) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.keep-alive-idle-time"] - unsafe extern "C" fn export_method_tcp_socket_keep_alive_idle_time(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_keep_alive_idle_time_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-keep-alive-idle-time"] - unsafe extern "C" fn export_method_tcp_socket_set_keep_alive_idle_time(arg0: *mut u8,arg1: i64,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_set_keep_alive_idle_time_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0, arg1) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.keep-alive-interval"] - unsafe extern "C" fn export_method_tcp_socket_keep_alive_interval(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_keep_alive_interval_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-keep-alive-interval"] - unsafe extern "C" fn export_method_tcp_socket_set_keep_alive_interval(arg0: *mut u8,arg1: i64,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_set_keep_alive_interval_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0, arg1) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.keep-alive-count"] - unsafe extern "C" fn export_method_tcp_socket_keep_alive_count(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_keep_alive_count_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-keep-alive-count"] - unsafe extern "C" fn export_method_tcp_socket_set_keep_alive_count(arg0: *mut u8,arg1: i32,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_set_keep_alive_count_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0, arg1) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.hop-limit"] - unsafe extern "C" fn export_method_tcp_socket_hop_limit(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_hop_limit_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-hop-limit"] - unsafe extern "C" fn export_method_tcp_socket_set_hop_limit(arg0: *mut u8,arg1: i32,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_set_hop_limit_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0, arg1) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.receive-buffer-size"] - unsafe extern "C" fn export_method_tcp_socket_receive_buffer_size(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_receive_buffer_size_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-receive-buffer-size"] - unsafe extern "C" fn export_method_tcp_socket_set_receive_buffer_size(arg0: *mut u8,arg1: i64,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_set_receive_buffer_size_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0, arg1) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.send-buffer-size"] - unsafe extern "C" fn export_method_tcp_socket_send_buffer_size(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_send_buffer_size_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-send-buffer-size"] - unsafe extern "C" fn export_method_tcp_socket_set_send_buffer_size(arg0: *mut u8,arg1: i64,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_set_send_buffer_size_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0, arg1) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.subscribe"] - unsafe extern "C" fn export_method_tcp_socket_subscribe(arg0: *mut u8,) -> i32 { - $($path_to_types)*::_export_method_tcp_socket_subscribe_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0) - } - #[export_name = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.shutdown"] - unsafe extern "C" fn export_method_tcp_socket_shutdown(arg0: *mut u8,arg1: i32,) -> *mut u8 { - $($path_to_types)*::_export_method_tcp_socket_shutdown_cabi::<<$ty as $($path_to_types)*::Guest>::TcpSocket>(arg0, arg1) - } - - const _: () = { - #[doc(hidden)] - #[export_name = "wasi:sockets/tcp@0.2.0#[dtor]tcp-socket"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: *mut u8) { - $($path_to_types)*::TcpSocket::dtor::< - <$ty as $($path_to_types)*::Guest>::TcpSocket - >(rep) - } - }; - - };); -} + macro_rules! __export_wasi_sockets_tcp_0_2_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.start-bind"] unsafe + extern "C" fn export_method_tcp_socket_start_bind(arg0 : * mut + u8, arg1 : i32, arg2 : i32, arg3 : i32, arg4 : i32, arg5 : i32, + arg6 : i32, arg7 : i32, arg8 : i32, arg9 : i32, arg10 : i32, + arg11 : i32, arg12 : i32, arg13 : i32,) -> * mut u8 { + $($path_to_types)*:: + _export_method_tcp_socket_start_bind_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0, arg1, arg2, + arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, + arg13) } #[export_name = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.finish-bind"] unsafe + extern "C" fn export_method_tcp_socket_finish_bind(arg0 : * mut + u8,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_finish_bind_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.start-connect"] + unsafe extern "C" fn export_method_tcp_socket_start_connect(arg0 + : * mut u8, arg1 : i32, arg2 : i32, arg3 : i32, arg4 : i32, arg5 + : i32, arg6 : i32, arg7 : i32, arg8 : i32, arg9 : i32, arg10 : + i32, arg11 : i32, arg12 : i32, arg13 : i32,) -> * mut u8 { + $($path_to_types)*:: + _export_method_tcp_socket_start_connect_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0, arg1, arg2, + arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, + arg13) } #[export_name = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.finish-connect"] + unsafe extern "C" fn export_method_tcp_socket_finish_connect(arg0 + : * mut u8,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_finish_connect_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.start-listen"] + unsafe extern "C" fn export_method_tcp_socket_start_listen(arg0 : + * mut u8,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_start_listen_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.finish-listen"] + unsafe extern "C" fn export_method_tcp_socket_finish_listen(arg0 + : * mut u8,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_finish_listen_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.accept"] unsafe + extern "C" fn export_method_tcp_socket_accept(arg0 : * mut u8,) + -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_accept_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.local-address"] + unsafe extern "C" fn export_method_tcp_socket_local_address(arg0 + : * mut u8,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_local_address_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.remote-address"] + unsafe extern "C" fn export_method_tcp_socket_remote_address(arg0 + : * mut u8,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_remote_address_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.is-listening"] + unsafe extern "C" fn export_method_tcp_socket_is_listening(arg0 : + * mut u8,) -> i32 { $($path_to_types)*:: + _export_method_tcp_socket_is_listening_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.address-family"] + unsafe extern "C" fn export_method_tcp_socket_address_family(arg0 + : * mut u8,) -> i32 { $($path_to_types)*:: + _export_method_tcp_socket_address_family_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-listen-backlog-size"] + unsafe extern "C" fn + export_method_tcp_socket_set_listen_backlog_size(arg0 : * mut u8, + arg1 : i64,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_set_listen_backlog_size_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0, arg1) } + #[export_name = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.keep-alive-enabled"] + unsafe extern "C" fn + export_method_tcp_socket_keep_alive_enabled(arg0 : * mut u8,) -> + * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_keep_alive_enabled_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-keep-alive-enabled"] + unsafe extern "C" fn + export_method_tcp_socket_set_keep_alive_enabled(arg0 : * mut u8, + arg1 : i32,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_set_keep_alive_enabled_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0, arg1) } + #[export_name = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.keep-alive-idle-time"] + unsafe extern "C" fn + export_method_tcp_socket_keep_alive_idle_time(arg0 : * mut u8,) + -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_keep_alive_idle_time_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-keep-alive-idle-time"] + unsafe extern "C" fn + export_method_tcp_socket_set_keep_alive_idle_time(arg0 : * mut + u8, arg1 : i64,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_set_keep_alive_idle_time_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0, arg1) } + #[export_name = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.keep-alive-interval"] + unsafe extern "C" fn + export_method_tcp_socket_keep_alive_interval(arg0 : * mut u8,) -> + * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_keep_alive_interval_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-keep-alive-interval"] + unsafe extern "C" fn + export_method_tcp_socket_set_keep_alive_interval(arg0 : * mut u8, + arg1 : i64,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_set_keep_alive_interval_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0, arg1) } + #[export_name = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.keep-alive-count"] + unsafe extern "C" fn + export_method_tcp_socket_keep_alive_count(arg0 : * mut u8,) -> * + mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_keep_alive_count_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-keep-alive-count"] + unsafe extern "C" fn + export_method_tcp_socket_set_keep_alive_count(arg0 : * mut u8, + arg1 : i32,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_set_keep_alive_count_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0, arg1) } + #[export_name = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.hop-limit"] unsafe + extern "C" fn export_method_tcp_socket_hop_limit(arg0 : * mut + u8,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_hop_limit_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-hop-limit"] + unsafe extern "C" fn export_method_tcp_socket_set_hop_limit(arg0 + : * mut u8, arg1 : i32,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_set_hop_limit_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0, arg1) } + #[export_name = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.receive-buffer-size"] + unsafe extern "C" fn + export_method_tcp_socket_receive_buffer_size(arg0 : * mut u8,) -> + * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_receive_buffer_size_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-receive-buffer-size"] + unsafe extern "C" fn + export_method_tcp_socket_set_receive_buffer_size(arg0 : * mut u8, + arg1 : i64,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_set_receive_buffer_size_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0, arg1) } + #[export_name = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.send-buffer-size"] + unsafe extern "C" fn + export_method_tcp_socket_send_buffer_size(arg0 : * mut u8,) -> * + mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_send_buffer_size_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.set-send-buffer-size"] + unsafe extern "C" fn + export_method_tcp_socket_set_send_buffer_size(arg0 : * mut u8, + arg1 : i64,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_set_send_buffer_size_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0, arg1) } + #[export_name = + "wasi:sockets/tcp@0.2.0#[method]tcp-socket.subscribe"] unsafe + extern "C" fn export_method_tcp_socket_subscribe(arg0 : * mut + u8,) -> i32 { $($path_to_types)*:: + _export_method_tcp_socket_subscribe_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0) } #[export_name + = "wasi:sockets/tcp@0.2.0#[method]tcp-socket.shutdown"] unsafe + extern "C" fn export_method_tcp_socket_shutdown(arg0 : * mut u8, + arg1 : i32,) -> * mut u8 { $($path_to_types)*:: + _export_method_tcp_socket_shutdown_cabi::<<$ty as + $($path_to_types)*:: Guest >::TcpSocket > (arg0, arg1) } const _ + : () = { #[doc(hidden)] #[export_name = + "wasi:sockets/tcp@0.2.0#[dtor]tcp-socket"] + #[allow(non_snake_case)] unsafe extern "C" fn dtor(rep : * mut + u8) { $($path_to_types)*:: TcpSocket::dtor::< <$ty as + $($path_to_types)*:: Guest >::TcpSocket > (rep) } }; }; + }; + } #[doc(hidden)] pub(crate) use __export_wasi_sockets_tcp_0_2_0_cabi; #[repr(align(8))] struct _RetArea([::core::mem::MaybeUninit; 36]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 36]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 36], + ); + } + #[allow(dead_code, clippy::all)] + pub mod tcp_create_socket { + #[used] + #[doc(hidden)] + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type ErrorCode = super::super::super::super::wasi::sockets0_2_0::network::ErrorCode; + pub type IpAddressFamily = super::super::super::super::wasi::sockets0_2_0::network::IpAddressFamily; + pub type TcpSocket = super::super::super::super::exports::wasi::sockets0_2_0::tcp::TcpSocket; + pub type TcpSocketBorrow<'a> = super::super::super::super::exports::wasi::sockets0_2_0::tcp::TcpSocketBorrow< + 'a, + >; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_create_tcp_socket_cabi( + arg0: i32, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::create_tcp_socket( + super::super::super::super::wasi::sockets0_2_0::network::IpAddressFamily::_lift( + arg0 as u8, + ), + ); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Ok(e) => { + *ptr1.add(0).cast::() = (0i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + Err(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + *ptr1.add(4).cast::() = (e.clone() as i32) as u8; + } + }; + ptr1 + } + pub trait Guest { + /// Create a new TCP socket. + /// + /// Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX. + /// On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise. + /// + /// This function does not require a network capability handle. This is considered to be safe because + /// at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind`/`connect` + /// is called, the socket is effectively an in-memory configuration object, unable to communicate with the outside world. + /// + /// All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous operations. + /// + /// # Typical errors + /// - `not-supported`: The specified `address-family` is not supported. (EAFNOSUPPORT) + /// - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE) + /// + /// # References + /// - + /// - + /// - + /// - + fn create_tcp_socket( + address_family: IpAddressFamily, + ) -> Result; + } + #[doc(hidden)] + macro_rules! __export_wasi_sockets_tcp_create_socket_0_2_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "wasi:sockets/tcp-create-socket@0.2.0#create-tcp-socket"] unsafe + extern "C" fn export_create_tcp_socket(arg0 : i32,) -> * mut u8 { + $($path_to_types)*:: _export_create_tcp_socket_cabi::<$ty > + (arg0) } }; + }; + } + #[doc(hidden)] + pub(crate) use __export_wasi_sockets_tcp_create_socket_0_2_0_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 8]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 8], + ); } - #[allow(dead_code, clippy::all)] pub mod udp { #[used] #[doc(hidden)] - #[cfg(target_arch = "wasm32")] - static __FORCE_SECTION_REF: fn() = - super::super::super::super::__link_custom_section_describing_imports; + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; use super::super::super::super::_rt; pub type Pollable = super::super::super::super::wasi::io0_2_0::poll::Pollable; pub type Network = super::super::super::super::wasi::sockets0_2_0::network::Network; - pub type ErrorCode = - super::super::super::super::wasi::sockets0_2_0::network::ErrorCode; - pub type IpSocketAddress = - super::super::super::super::wasi::sockets0_2_0::network::IpSocketAddress; - pub type IpAddressFamily = - super::super::super::super::wasi::sockets0_2_0::network::IpAddressFamily; + pub type ErrorCode = super::super::super::super::wasi::sockets0_2_0::network::ErrorCode; + pub type IpSocketAddress = super::super::super::super::wasi::sockets0_2_0::network::IpSocketAddress; + pub type IpAddressFamily = super::super::super::super::wasi::sockets0_2_0::network::IpAddressFamily; + /// A received datagram. #[derive(Clone)] pub struct IncomingDatagram { + /// The payload. + /// + /// Theoretical max size: ~64 KiB. In practice, typically less than 1500 bytes. pub data: _rt::Vec, + /// The source address. + /// + /// This field is guaranteed to match the remote address the stream was initialized with, if any. + /// + /// Equivalent to the `src_addr` out parameter of `recvfrom`. pub remote_address: IpSocketAddress, } impl ::core::fmt::Debug for IncomingDatagram { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("IncomingDatagram") .field("data", &self.data) .field("remote-address", &self.remote_address) .finish() } } + /// A datagram to be sent out. #[derive(Clone)] pub struct OutgoingDatagram { + /// The payload. pub data: _rt::Vec, + /// The destination address. + /// + /// The requirements on this field depend on how the stream was initialized: + /// - with a remote address: this field must be None or match the stream's remote address exactly. + /// - without a remote address: this field is required. + /// + /// If this value is None, the send operation is equivalent to `send` in POSIX. Otherwise it is equivalent to `sendto`. pub remote_address: Option, } impl ::core::fmt::Debug for OutgoingDatagram { - fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { + fn fmt( + &self, + f: &mut ::core::fmt::Formatter<'_>, + ) -> ::core::fmt::Result { f.debug_struct("OutgoingDatagram") .field("data", &self.data) .field("remote-address", &self.remote_address) .finish() } } - + /// A UDP socket handle. #[derive(Debug)] #[repr(transparent)] pub struct UdpSocket { handle: _rt::Resource, } - type _UdpSocketRep = Option; - impl UdpSocket { /// Creates a new resource from the specified representation. /// @@ -18125,77 +19283,68 @@ pub mod exports { pub fn new(val: T) -> Self { Self::type_guard::(); let val: _UdpSocketRep = Some(val); - let ptr: *mut _UdpSocketRep = _rt::Box::into_raw(_rt::Box::new(val)); + let ptr: *mut _UdpSocketRep = _rt::Box::into_raw( + _rt::Box::new(val), + ); unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } } - /// Gets access to the underlying `T` which represents this resource. pub fn get(&self) -> &T { let ptr = unsafe { &*self.as_ptr::() }; ptr.as_ref().unwrap() } - /// Gets mutable access to the underlying `T` which represents this /// resource. pub fn get_mut(&mut self) -> &mut T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_mut().unwrap() } - /// Consumes this resource and returns the underlying `T`. pub fn into_inner(self) -> T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.take().unwrap() } - #[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) } - - // It's theoretically possible to implement the `GuestUdpSocket` trait twice - // so guard against using it with two different types here. #[doc(hidden)] fn type_guard() { use core::any::TypeId; static mut LAST_TYPE: Option = None; unsafe { - assert!(!cfg!(target_feature = "threads")); + assert!(! cfg!(target_feature = "atomics")); let id = TypeId::of::(); match LAST_TYPE { - Some(ty) => assert!( - ty == id, - "cannot use two types with this resource type" - ), + Some(ty) => { + assert!( + ty == id, "cannot use two types with this resource type" + ) + } None => LAST_TYPE = Some(id), } } } - #[doc(hidden)] pub unsafe fn dtor(handle: *mut u8) { Self::type_guard::(); let _ = _rt::Box::from_raw(handle as *mut _UdpSocketRep); } - fn as_ptr(&self) -> *mut _UdpSocketRep { UdpSocket::type_guard::(); T::_resource_rep(self.handle()).cast() } } - /// A borrowed version of [`UdpSocket`] which represents a borrowed value /// with the lifetime `'a`. #[derive(Debug)] @@ -18204,7 +19353,6 @@ pub mod exports { rep: *mut u8, _marker: core::marker::PhantomData<&'a UdpSocket>, } - impl<'a> UdpSocketBorrow<'a> { #[doc(hidden)] pub unsafe fn lift(rep: usize) -> Self { @@ -18213,49 +19361,40 @@ pub mod exports { _marker: core::marker::PhantomData, } } - /// Gets access to the underlying `T` in this resource. pub fn get(&self) -> &T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_ref().unwrap() } - - // NB: mutable access is not allowed due to the component model allowing - // multiple borrows of the same resource. - fn as_ptr(&self) -> *mut _UdpSocketRep { UdpSocket::type_guard::(); self.rep.cast() } } - unsafe impl _rt::WasmResource for UdpSocket { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]wasi:sockets/udp@0.2.0")] + #[link( + wasm_import_module = "[export]wasi:sockets/udp@0.2.0" + )] extern "C" { #[link_name = "[resource-drop]udp-socket"] fn drop(_: u32); } - drop(_handle); } } } - #[derive(Debug)] #[repr(transparent)] pub struct IncomingDatagramStream { handle: _rt::Resource, } - type _IncomingDatagramStreamRep = Option; - impl IncomingDatagramStream { /// Creates a new resource from the specified representation. /// @@ -18265,72 +19404,65 @@ pub mod exports { pub fn new(val: T) -> Self { Self::type_guard::(); let val: _IncomingDatagramStreamRep = Some(val); - let ptr: *mut _IncomingDatagramStreamRep = - _rt::Box::into_raw(_rt::Box::new(val)); + let ptr: *mut _IncomingDatagramStreamRep = _rt::Box::into_raw( + _rt::Box::new(val), + ); unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } } - /// Gets access to the underlying `T` which represents this resource. pub fn get(&self) -> &T { let ptr = unsafe { &*self.as_ptr::() }; ptr.as_ref().unwrap() } - /// Gets mutable access to the underlying `T` which represents this /// resource. pub fn get_mut(&mut self) -> &mut T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_mut().unwrap() } - /// Consumes this resource and returns the underlying `T`. pub fn into_inner(self) -> T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.take().unwrap() } - #[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) } - - // It's theoretically possible to implement the `GuestIncomingDatagramStream` trait twice - // so guard against using it with two different types here. #[doc(hidden)] fn type_guard() { use core::any::TypeId; static mut LAST_TYPE: Option = None; unsafe { - assert!(!cfg!(target_feature = "threads")); + assert!(! cfg!(target_feature = "atomics")); let id = TypeId::of::(); match LAST_TYPE { - Some(ty) => assert!( - ty == id, - "cannot use two types with this resource type" - ), + Some(ty) => { + assert!( + ty == id, "cannot use two types with this resource type" + ) + } None => LAST_TYPE = Some(id), } } } - #[doc(hidden)] pub unsafe fn dtor(handle: *mut u8) { Self::type_guard::(); - let _ = _rt::Box::from_raw(handle as *mut _IncomingDatagramStreamRep); + let _ = _rt::Box::from_raw( + handle as *mut _IncomingDatagramStreamRep, + ); } - fn as_ptr( &self, ) -> *mut _IncomingDatagramStreamRep { @@ -18338,7 +19470,6 @@ pub mod exports { T::_resource_rep(self.handle()).cast() } } - /// A borrowed version of [`IncomingDatagramStream`] which represents a borrowed value /// with the lifetime `'a`. #[derive(Debug)] @@ -18347,7 +19478,6 @@ pub mod exports { rep: *mut u8, _marker: core::marker::PhantomData<&'a IncomingDatagramStream>, } - impl<'a> IncomingDatagramStreamBorrow<'a> { #[doc(hidden)] pub unsafe fn lift(rep: usize) -> Self { @@ -18356,49 +19486,40 @@ pub mod exports { _marker: core::marker::PhantomData, } } - /// Gets access to the underlying `T` in this resource. pub fn get(&self) -> &T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_ref().unwrap() } - - // NB: mutable access is not allowed due to the component model allowing - // multiple borrows of the same resource. - fn as_ptr(&self) -> *mut _IncomingDatagramStreamRep { IncomingDatagramStream::type_guard::(); self.rep.cast() } } - unsafe impl _rt::WasmResource for IncomingDatagramStream { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]wasi:sockets/udp@0.2.0")] + #[link( + wasm_import_module = "[export]wasi:sockets/udp@0.2.0" + )] extern "C" { #[link_name = "[resource-drop]incoming-datagram-stream"] fn drop(_: u32); } - drop(_handle); } } } - #[derive(Debug)] #[repr(transparent)] pub struct OutgoingDatagramStream { handle: _rt::Resource, } - type _OutgoingDatagramStreamRep = Option; - impl OutgoingDatagramStream { /// Creates a new resource from the specified representation. /// @@ -18408,72 +19529,65 @@ pub mod exports { pub fn new(val: T) -> Self { Self::type_guard::(); let val: _OutgoingDatagramStreamRep = Some(val); - let ptr: *mut _OutgoingDatagramStreamRep = - _rt::Box::into_raw(_rt::Box::new(val)); + let ptr: *mut _OutgoingDatagramStreamRep = _rt::Box::into_raw( + _rt::Box::new(val), + ); unsafe { Self::from_handle(T::_resource_new(ptr.cast())) } } - /// Gets access to the underlying `T` which represents this resource. pub fn get(&self) -> &T { let ptr = unsafe { &*self.as_ptr::() }; ptr.as_ref().unwrap() } - /// Gets mutable access to the underlying `T` which represents this /// resource. pub fn get_mut(&mut self) -> &mut T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_mut().unwrap() } - /// Consumes this resource and returns the underlying `T`. pub fn into_inner(self) -> T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.take().unwrap() } - #[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) } - - // It's theoretically possible to implement the `GuestOutgoingDatagramStream` trait twice - // so guard against using it with two different types here. #[doc(hidden)] fn type_guard() { use core::any::TypeId; static mut LAST_TYPE: Option = None; unsafe { - assert!(!cfg!(target_feature = "threads")); + assert!(! cfg!(target_feature = "atomics")); let id = TypeId::of::(); match LAST_TYPE { - Some(ty) => assert!( - ty == id, - "cannot use two types with this resource type" - ), + Some(ty) => { + assert!( + ty == id, "cannot use two types with this resource type" + ) + } None => LAST_TYPE = Some(id), } } } - #[doc(hidden)] pub unsafe fn dtor(handle: *mut u8) { Self::type_guard::(); - let _ = _rt::Box::from_raw(handle as *mut _OutgoingDatagramStreamRep); + let _ = _rt::Box::from_raw( + handle as *mut _OutgoingDatagramStreamRep, + ); } - fn as_ptr( &self, ) -> *mut _OutgoingDatagramStreamRep { @@ -18481,7 +19595,6 @@ pub mod exports { T::_resource_rep(self.handle()).cast() } } - /// A borrowed version of [`OutgoingDatagramStream`] which represents a borrowed value /// with the lifetime `'a`. #[derive(Debug)] @@ -18490,7 +19603,6 @@ pub mod exports { rep: *mut u8, _marker: core::marker::PhantomData<&'a OutgoingDatagramStream>, } - impl<'a> OutgoingDatagramStreamBorrow<'a> { #[doc(hidden)] pub unsafe fn lift(rep: usize) -> Self { @@ -18499,44 +19611,39 @@ pub mod exports { _marker: core::marker::PhantomData, } } - /// Gets access to the underlying `T` in this resource. pub fn get(&self) -> &T { let ptr = unsafe { &mut *self.as_ptr::() }; ptr.as_ref().unwrap() } - - // NB: mutable access is not allowed due to the component model allowing - // multiple borrows of the same resource. - fn as_ptr(&self) -> *mut _OutgoingDatagramStreamRep { OutgoingDatagramStream::type_guard::(); self.rep.cast() } } - unsafe impl _rt::WasmResource for OutgoingDatagramStream { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))] unreachable!(); - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]wasi:sockets/udp@0.2.0")] + #[link( + wasm_import_module = "[export]wasi:sockets/udp@0.2.0" + )] extern "C" { #[link_name = "[resource-drop]outgoing-datagram-stream"] fn drop(_: u32); } - drop(_handle); } } } - #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_udp_socket_start_bind_cabi( + pub unsafe fn _export_method_udp_socket_start_bind_cabi< + T: GuestUdpSocket, + >( arg0: *mut u8, arg1: i32, arg2: i32, @@ -18552,33 +19659,43 @@ pub mod exports { arg12: i32, arg13: i32, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let handle0; use super::super::super::super::wasi::sockets0_2_0::network::IpSocketAddress as V1; let v1 = match arg2 { 0 => { - let e1 = super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress{ - port: arg3 as u16, - address: (arg4 as u8, arg5 as u8, arg6 as u8, arg7 as u8), - }; + let e1 = super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress { + port: arg3 as u16, + address: (arg4 as u8, arg5 as u8, arg6 as u8, arg7 as u8), + }; V1::Ipv4(e1) } n => { debug_assert_eq!(n, 1, "invalid enum discriminant"); - let e1 = super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress{ - port: arg3 as u16, - flow_info: arg4 as u32, - address: (arg5 as u16, arg6 as u16, arg7 as u16, arg8 as u16, arg9 as u16, arg10 as u16, arg11 as u16, arg12 as u16), - scope_id: arg13 as u32, - }; + let e1 = super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress { + port: arg3 as u16, + flow_info: arg4 as u32, + address: ( + arg5 as u16, + arg6 as u16, + arg7 as u16, + arg8 as u16, + arg9 as u16, + arg10 as u16, + arg11 as u16, + arg12 as u16, + ), + scope_id: arg13 as u32, + }; V1::Ipv6(e1) } }; let result2 = T::start_bind( UdpSocketBorrow::lift(arg0 as u32 as usize).get(), { - handle0 = super::super::super::super::wasi::sockets0_2_0::network::Network::from_handle(arg1 as u32); + handle0 = super::super::super::super::wasi::sockets0_2_0::network::Network::from_handle( + arg1 as u32, + ); &handle0 }, v1, @@ -18597,12 +19714,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_udp_socket_finish_bind_cabi( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = T::finish_bind(UdpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_udp_socket_finish_bind_cabi< + T: GuestUdpSocket, + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::finish_bind( + UdpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(_) => { @@ -18633,8 +19751,7 @@ pub mod exports { arg12: i32, arg13: i32, ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result1 = T::stream( UdpSocketBorrow::lift(arg0 as u32 as usize).get(), match arg1 { @@ -18644,24 +19761,32 @@ pub mod exports { use super::super::super::super::wasi::sockets0_2_0::network::IpSocketAddress as V0; let v0 = match arg2 { 0 => { - let e0 = super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress{ - port: arg3 as u16, - address: (arg4 as u8, arg5 as u8, arg6 as u8, arg7 as u8), - }; + let e0 = super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress { + port: arg3 as u16, + address: (arg4 as u8, arg5 as u8, arg6 as u8, arg7 as u8), + }; V0::Ipv4(e0) } n => { debug_assert_eq!(n, 1, "invalid enum discriminant"); - let e0 = super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress{ - port: arg3 as u16, - flow_info: arg4 as u32, - address: (arg5 as u16, arg6 as u16, arg7 as u16, arg8 as u16, arg9 as u16, arg10 as u16, arg11 as u16, arg12 as u16), - scope_id: arg13 as u32, - }; + let e0 = super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress { + port: arg3 as u16, + flow_info: arg4 as u32, + address: ( + arg5 as u16, + arg6 as u16, + arg7 as u16, + arg8 as u16, + arg9 as u16, + arg10 as u16, + arg11 as u16, + arg12 as u16, + ), + scope_id: arg13 as u32, + }; V0::Ipv6(e0) } }; - v0 }; Some(e) @@ -18686,13 +19811,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_udp_socket_local_address_cabi( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::local_address(UdpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_udp_socket_local_address_cabi< + T: GuestUdpSocket, + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::local_address( + UdpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -18701,7 +19826,10 @@ pub mod exports { match e { V6::Ipv4(e) => { *ptr1.add(4).cast::() = (0i32) as u8; - let super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress{ port:port2, address:address2, } = e; + let super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress { + port: port2, + address: address2, + } = e; *ptr1.add(8).cast::() = (_rt::as_i32(port2)) as u16; let (t3_0, t3_1, t3_2, t3_3) = address2; *ptr1.add(10).cast::() = (_rt::as_i32(t3_0)) as u8; @@ -18711,7 +19839,12 @@ pub mod exports { } V6::Ipv6(e) => { *ptr1.add(4).cast::() = (1i32) as u8; - let super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress{ port:port4, flow_info:flow_info4, address:address4, scope_id:scope_id4, } = e; + let super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress { + port: port4, + flow_info: flow_info4, + address: address4, + scope_id: scope_id4, + } = e; *ptr1.add(8).cast::() = (_rt::as_i32(port4)) as u16; *ptr1.add(12).cast::() = _rt::as_i32(flow_info4); let (t5_0, t5_1, t5_2, t5_3, t5_4, t5_5, t5_6, t5_7) = address4; @@ -18736,13 +19869,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_udp_socket_remote_address_cabi( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::remote_address(UdpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_udp_socket_remote_address_cabi< + T: GuestUdpSocket, + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::remote_address( + UdpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -18751,7 +19884,10 @@ pub mod exports { match e { V6::Ipv4(e) => { *ptr1.add(4).cast::() = (0i32) as u8; - let super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress{ port:port2, address:address2, } = e; + let super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress { + port: port2, + address: address2, + } = e; *ptr1.add(8).cast::() = (_rt::as_i32(port2)) as u16; let (t3_0, t3_1, t3_2, t3_3) = address2; *ptr1.add(10).cast::() = (_rt::as_i32(t3_0)) as u8; @@ -18761,7 +19897,12 @@ pub mod exports { } V6::Ipv6(e) => { *ptr1.add(4).cast::() = (1i32) as u8; - let super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress{ port:port4, flow_info:flow_info4, address:address4, scope_id:scope_id4, } = e; + let super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress { + port: port4, + flow_info: flow_info4, + address: address4, + scope_id: scope_id4, + } = e; *ptr1.add(8).cast::() = (_rt::as_i32(port4)) as u16; *ptr1.add(12).cast::() = _rt::as_i32(flow_info4); let (t5_0, t5_1, t5_2, t5_3, t5_4, t5_5, t5_6, t5_7) = address4; @@ -18786,26 +19927,24 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_udp_socket_address_family_cabi( - arg0: *mut u8, - ) -> i32 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::address_family(UdpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_udp_socket_address_family_cabi< + T: GuestUdpSocket, + >(arg0: *mut u8) -> i32 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::address_family( + UdpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); result0.clone() as i32 } #[doc(hidden)] #[allow(non_snake_case)] pub unsafe fn _export_method_udp_socket_unicast_hop_limit_cabi< T: GuestUdpSocket, - >( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::unicast_hop_limit(UdpSocketBorrow::lift(arg0 as u32 as usize).get()); + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::unicast_hop_limit( + UdpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -18823,12 +19962,8 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_udp_socket_set_unicast_hop_limit_cabi< T: GuestUdpSocket, - >( - arg0: *mut u8, - arg1: i32, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8, arg1: i32) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::set_unicast_hop_limit( UdpSocketBorrow::lift(arg0 as u32 as usize).get(), arg1 as u8, @@ -18849,13 +19984,11 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_udp_socket_receive_buffer_size_cabi< T: GuestUdpSocket, - >( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::receive_buffer_size(UdpSocketBorrow::lift(arg0 as u32 as usize).get()); + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::receive_buffer_size( + UdpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -18873,12 +20006,8 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_udp_socket_set_receive_buffer_size_cabi< T: GuestUdpSocket, - >( - arg0: *mut u8, - arg1: i64, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8, arg1: i64) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::set_receive_buffer_size( UdpSocketBorrow::lift(arg0 as u32 as usize).get(), arg1 as u64, @@ -18897,13 +20026,13 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_udp_socket_send_buffer_size_cabi( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = - T::send_buffer_size(UdpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_udp_socket_send_buffer_size_cabi< + T: GuestUdpSocket, + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::send_buffer_size( + UdpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); match result0 { Ok(e) => { @@ -18921,12 +20050,8 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_udp_socket_set_send_buffer_size_cabi< T: GuestUdpSocket, - >( - arg0: *mut u8, - arg1: i64, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8, arg1: i64) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::set_send_buffer_size( UdpSocketBorrow::lift(arg0 as u32 as usize).get(), arg1 as u64, @@ -18945,24 +20070,21 @@ pub mod exports { } #[doc(hidden)] #[allow(non_snake_case)] - pub unsafe fn _export_method_udp_socket_subscribe_cabi( - arg0: *mut u8, - ) -> i32 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); - let result0 = T::subscribe(UdpSocketBorrow::lift(arg0 as u32 as usize).get()); + pub unsafe fn _export_method_udp_socket_subscribe_cabi< + T: GuestUdpSocket, + >(arg0: *mut u8) -> i32 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::subscribe( + UdpSocketBorrow::lift(arg0 as u32 as usize).get(), + ); (result0).take_handle() as i32 } #[doc(hidden)] #[allow(non_snake_case)] pub unsafe fn _export_method_incoming_datagram_stream_receive_cabi< T: GuestIncomingDatagramStream, - >( - arg0: *mut u8, - arg1: i64, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8, arg1: i64) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::receive( IncomingDatagramStreamBorrow::lift(arg0 as u32 as usize).get(), arg1 as u64, @@ -18973,8 +20095,10 @@ pub mod exports { *ptr1.add(0).cast::() = (0i32) as u8; let vec9 = e; let len9 = vec9.len(); - let layout9 = - _rt::alloc::Layout::from_size_align_unchecked(vec9.len() * 40, 4); + let layout9 = _rt::alloc::Layout::from_size_align_unchecked( + vec9.len() * 40, + 4, + ); let result9 = if layout9.size() != 0 { let ptr = _rt::alloc::alloc(layout9).cast::(); if ptr.is_null() { @@ -18982,9 +20106,7 @@ pub mod exports { } ptr } else { - { - ::core::ptr::null_mut() - } + ::core::ptr::null_mut() }; for (i, e) in vec9.into_iter().enumerate() { let base = result9.add(i * 40); @@ -19003,9 +20125,11 @@ pub mod exports { match remote_address2 { V8::Ipv4(e) => { *base.add(8).cast::() = (0i32) as u8; - let super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress{ port:port4, address:address4, } = e; - *base.add(12).cast::() = - (_rt::as_i32(port4)) as u16; + let super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress { + port: port4, + address: address4, + } = e; + *base.add(12).cast::() = (_rt::as_i32(port4)) as u16; let (t5_0, t5_1, t5_2, t5_3) = address4; *base.add(14).cast::() = (_rt::as_i32(t5_0)) as u8; *base.add(15).cast::() = (_rt::as_i32(t5_1)) as u8; @@ -19014,28 +20138,23 @@ pub mod exports { } V8::Ipv6(e) => { *base.add(8).cast::() = (1i32) as u8; - let super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress{ port:port6, flow_info:flow_info6, address:address6, scope_id:scope_id6, } = e; - *base.add(12).cast::() = - (_rt::as_i32(port6)) as u16; + let super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress { + port: port6, + flow_info: flow_info6, + address: address6, + scope_id: scope_id6, + } = e; + *base.add(12).cast::() = (_rt::as_i32(port6)) as u16; *base.add(16).cast::() = _rt::as_i32(flow_info6); - let (t7_0, t7_1, t7_2, t7_3, t7_4, t7_5, t7_6, t7_7) = - address6; - *base.add(20).cast::() = - (_rt::as_i32(t7_0)) as u16; - *base.add(22).cast::() = - (_rt::as_i32(t7_1)) as u16; - *base.add(24).cast::() = - (_rt::as_i32(t7_2)) as u16; - *base.add(26).cast::() = - (_rt::as_i32(t7_3)) as u16; - *base.add(28).cast::() = - (_rt::as_i32(t7_4)) as u16; - *base.add(30).cast::() = - (_rt::as_i32(t7_5)) as u16; - *base.add(32).cast::() = - (_rt::as_i32(t7_6)) as u16; - *base.add(34).cast::() = - (_rt::as_i32(t7_7)) as u16; + let (t7_0, t7_1, t7_2, t7_3, t7_4, t7_5, t7_6, t7_7) = address6; + *base.add(20).cast::() = (_rt::as_i32(t7_0)) as u16; + *base.add(22).cast::() = (_rt::as_i32(t7_1)) as u16; + *base.add(24).cast::() = (_rt::as_i32(t7_2)) as u16; + *base.add(26).cast::() = (_rt::as_i32(t7_3)) as u16; + *base.add(28).cast::() = (_rt::as_i32(t7_4)) as u16; + *base.add(30).cast::() = (_rt::as_i32(t7_5)) as u16; + *base.add(32).cast::() = (_rt::as_i32(t7_6)) as u16; + *base.add(34).cast::() = (_rt::as_i32(t7_7)) as u16; *base.add(36).cast::() = _rt::as_i32(scope_id6); } } @@ -19055,40 +20174,35 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn __post_return_method_incoming_datagram_stream_receive< T: GuestIncomingDatagramStream, - >( - arg0: *mut u8, - ) { + >(arg0: *mut u8) { let l0 = i32::from(*arg0.add(0).cast::()); match l0 { 0 => { - let l4 = *arg0.add(4).cast::<*mut u8>(); - let l5 = *arg0.add(8).cast::(); - let base6 = l4; - let len6 = l5; + let l1 = *arg0.add(4).cast::<*mut u8>(); + let l2 = *arg0.add(8).cast::(); + let base6 = l1; + let len6 = l2; for i in 0..len6 { let base = base6.add(i * 40); { - let l1 = *base.add(0).cast::<*mut u8>(); - let l2 = *base.add(4).cast::(); - let base3 = l1; - let len3 = l2; - _rt::cabi_dealloc(base3, len3 * 1, 1); + let l3 = *base.add(0).cast::<*mut u8>(); + let l4 = *base.add(4).cast::(); + let base5 = l3; + let len5 = l4; + _rt::cabi_dealloc(base5, len5 * 1, 1); } } _rt::cabi_dealloc(base6, len6 * 40, 4); } - _ => (), + _ => {} } } #[doc(hidden)] #[allow(non_snake_case)] pub unsafe fn _export_method_incoming_datagram_stream_subscribe_cabi< T: GuestIncomingDatagramStream, - >( - arg0: *mut u8, - ) -> i32 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8) -> i32 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::subscribe( IncomingDatagramStreamBorrow::lift(arg0 as u32 as usize).get(), ); @@ -19098,11 +20212,8 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_outgoing_datagram_stream_check_send_cabi< T: GuestOutgoingDatagramStream, - >( - arg0: *mut u8, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::check_send( OutgoingDatagramStreamBorrow::lift(arg0 as u32 as usize).get(), ); @@ -19123,13 +20234,8 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_outgoing_datagram_stream_send_cabi< T: GuestOutgoingDatagramStream, - >( - arg0: *mut u8, - arg1: *mut u8, - arg2: usize, - ) -> *mut u8 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8, arg1: *mut u8, arg2: usize) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let base22 = arg1; let len22 = arg2; let mut result22 = _rt::Vec::with_capacity(len22); @@ -19140,7 +20246,6 @@ pub mod exports { let l1 = *base.add(4).cast::(); let len2 = l1; let l3 = i32::from(*base.add(8).cast::()); - OutgoingDatagram { data: _rt::Vec::from_raw_parts(l0.cast(), len2, len2), remote_address: match l3 { @@ -19152,62 +20257,51 @@ pub mod exports { let v21 = match l4 { 0 => { let e21 = { - let l5 = - i32::from(*base.add(16).cast::()); - let l6 = - i32::from(*base.add(18).cast::()); - let l7 = - i32::from(*base.add(19).cast::()); - let l8 = - i32::from(*base.add(20).cast::()); - let l9 = - i32::from(*base.add(21).cast::()); - - super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress{ - port: l5 as u16, - address: (l6 as u8, l7 as u8, l8 as u8, l9 as u8), - } + let l5 = i32::from(*base.add(16).cast::()); + let l6 = i32::from(*base.add(18).cast::()); + let l7 = i32::from(*base.add(19).cast::()); + let l8 = i32::from(*base.add(20).cast::()); + let l9 = i32::from(*base.add(21).cast::()); + super::super::super::super::wasi::sockets0_2_0::network::Ipv4SocketAddress { + port: l5 as u16, + address: (l6 as u8, l7 as u8, l8 as u8, l9 as u8), + } }; V21::Ipv4(e21) } n => { - debug_assert_eq!( - n, 1, - "invalid enum discriminant" - ); + debug_assert_eq!(n, 1, "invalid enum discriminant"); let e21 = { - let l10 = - i32::from(*base.add(16).cast::()); + let l10 = i32::from(*base.add(16).cast::()); let l11 = *base.add(20).cast::(); - let l12 = - i32::from(*base.add(24).cast::()); - let l13 = - i32::from(*base.add(26).cast::()); - let l14 = - i32::from(*base.add(28).cast::()); - let l15 = - i32::from(*base.add(30).cast::()); - let l16 = - i32::from(*base.add(32).cast::()); - let l17 = - i32::from(*base.add(34).cast::()); - let l18 = - i32::from(*base.add(36).cast::()); - let l19 = - i32::from(*base.add(38).cast::()); + let l12 = i32::from(*base.add(24).cast::()); + let l13 = i32::from(*base.add(26).cast::()); + let l14 = i32::from(*base.add(28).cast::()); + let l15 = i32::from(*base.add(30).cast::()); + let l16 = i32::from(*base.add(32).cast::()); + let l17 = i32::from(*base.add(34).cast::()); + let l18 = i32::from(*base.add(36).cast::()); + let l19 = i32::from(*base.add(38).cast::()); let l20 = *base.add(40).cast::(); - - super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress{ - port: l10 as u16, - flow_info: l11 as u32, - address: (l12 as u16, l13 as u16, l14 as u16, l15 as u16, l16 as u16, l17 as u16, l18 as u16, l19 as u16), - scope_id: l20 as u32, - } + super::super::super::super::wasi::sockets0_2_0::network::Ipv6SocketAddress { + port: l10 as u16, + flow_info: l11 as u32, + address: ( + l12 as u16, + l13 as u16, + l14 as u16, + l15 as u16, + l16 as u16, + l17 as u16, + l18 as u16, + l19 as u16, + ), + scope_id: l20 as u32, + } }; V21::Ipv6(e21) } }; - v21 }; Some(e) @@ -19240,11 +20334,8 @@ pub mod exports { #[allow(non_snake_case)] pub unsafe fn _export_method_outgoing_datagram_stream_subscribe_cabi< T: GuestOutgoingDatagramStream, - >( - arg0: *mut u8, - ) -> i32 { - #[cfg(target_arch = "wasm32")] - _rt::run_ctors_once(); + >(arg0: *mut u8) -> i32 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); let result0 = T::subscribe( OutgoingDatagramStreamBorrow::lift(arg0 as u32 as usize).get(), ); @@ -19266,10 +20357,11 @@ pub mod exports { let _ = val; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]wasi:sockets/udp@0.2.0")] + #[link( + wasm_import_module = "[export]wasi:sockets/udp@0.2.0" + )] extern "C" { #[link_name = "[resource-new]udp-socket"] fn new(_: *mut u8) -> u32; @@ -19277,7 +20369,6 @@ pub mod exports { new(val) } } - #[doc(hidden)] fn _resource_rep(handle: u32) -> *mut u8 where @@ -19288,10 +20379,11 @@ pub mod exports { let _ = handle; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]wasi:sockets/udp@0.2.0")] + #[link( + wasm_import_module = "[export]wasi:sockets/udp@0.2.0" + )] extern "C" { #[link_name = "[resource-rep]udp-socket"] fn rep(_: u32) -> *mut u8; @@ -19299,26 +20391,146 @@ pub mod exports { unsafe { rep(handle) } } } - + /// Bind the socket to a specific network on the provided IP address and port. + /// + /// If the IP address is zero (`0.0.0.0` in IPv4, `::` in IPv6), it is left to the implementation to decide which + /// network interface(s) to bind to. + /// If the port is zero, the socket will be bound to a random free port. + /// + /// # Typical errors + /// - `invalid-argument`: The `local-address` has the wrong address family. (EAFNOSUPPORT, EFAULT on Windows) + /// - `invalid-state`: The socket is already bound. (EINVAL) + /// - `address-in-use`: No ephemeral ports available. (EADDRINUSE, ENOBUFS on Windows) + /// - `address-in-use`: Address is already in use. (EADDRINUSE) + /// - `address-not-bindable`: `local-address` is not an address that the `network` can bind to. (EADDRNOTAVAIL) + /// - `not-in-progress`: A `bind` operation is not in progress. + /// - `would-block`: Can't finish the operation, it is still in progress. (EWOULDBLOCK, EAGAIN) + /// + /// # Implementors note + /// Unlike in POSIX, in WASI the bind operation is async. This enables + /// interactive WASI hosts to inject permission prompts. Runtimes that + /// don't want to make use of this ability can simply call the native + /// `bind` as part of either `start-bind` or `finish-bind`. + /// + /// # References + /// - + /// - + /// - + /// - fn start_bind( &self, network: &Network, local_address: IpSocketAddress, ) -> Result<(), ErrorCode>; fn finish_bind(&self) -> Result<(), ErrorCode>; + /// Set up inbound & outbound communication channels, optionally to a specific peer. + /// + /// This function only changes the local socket configuration and does not generate any network traffic. + /// On success, the `remote-address` of the socket is updated. The `local-address` may be updated as well, + /// based on the best network path to `remote-address`. + /// + /// When a `remote-address` is provided, the returned streams are limited to communicating with that specific peer: + /// - `send` can only be used to send to this destination. + /// - `receive` will only return datagrams sent from the provided `remote-address`. + /// + /// This method may be called multiple times on the same socket to change its association, but + /// only the most recently returned pair of streams will be operational. Implementations may trap if + /// the streams returned by a previous invocation haven't been dropped yet before calling `stream` again. + /// + /// The POSIX equivalent in pseudo-code is: + /// ```text + /// if (was previously connected) { + /// connect(s, AF_UNSPEC) + /// } + /// if (remote_address is Some) { + /// connect(s, remote_address) + /// } + /// ``` + /// + /// Unlike in POSIX, the socket must already be explicitly bound. + /// + /// # Typical errors + /// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) + /// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EDESTADDRREQ, EADDRNOTAVAIL) + /// - `invalid-argument`: The port in `remote-address` is set to 0. (EDESTADDRREQ, EADDRNOTAVAIL) + /// - `invalid-state`: The socket is not bound. + /// - `address-in-use`: Tried to perform an implicit bind, but there were no ephemeral ports available. (EADDRINUSE, EADDRNOTAVAIL on Linux, EAGAIN on BSD) + /// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// - `connection-refused`: The connection was refused. (ECONNREFUSED) + /// + /// # References + /// - + /// - + /// - + /// - fn stream( &self, remote_address: Option, - ) -> Result<(IncomingDatagramStream, OutgoingDatagramStream), ErrorCode>; + ) -> Result< + (IncomingDatagramStream, OutgoingDatagramStream), + ErrorCode, + >; + /// Get the current bound address. + /// + /// POSIX mentions: + /// > If the socket has not been bound to a local name, the value + /// > stored in the object pointed to by `address` is unspecified. + /// + /// WASI is stricter and requires `local-address` to return `invalid-state` when the socket hasn't been bound yet. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not bound to any local address. + /// + /// # References + /// - + /// - + /// - + /// - fn local_address(&self) -> Result; + /// Get the address the socket is currently streaming to. + /// + /// # Typical errors + /// - `invalid-state`: The socket is not streaming to a specific remote address. (ENOTCONN) + /// + /// # References + /// - + /// - + /// - + /// - fn remote_address(&self) -> Result; + /// Whether this is a IPv4 or IPv6 socket. + /// + /// Equivalent to the SO_DOMAIN socket option. fn address_family(&self) -> IpAddressFamily; + /// Equivalent to the IP_TTL & IPV6_UNICAST_HOPS socket options. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The TTL value must be 1 or higher. fn unicast_hop_limit(&self) -> Result; fn set_unicast_hop_limit(&self, value: u8) -> Result<(), ErrorCode>; + /// The kernel buffer space reserved for sends/receives on this socket. + /// + /// If the provided value is 0, an `invalid-argument` error is returned. + /// Any other value will never cause an error, but it might be silently clamped and/or rounded. + /// I.e. after setting a value, reading the same setting back may return a different value. + /// + /// Equivalent to the SO_RCVBUF and SO_SNDBUF socket options. + /// + /// # Typical errors + /// - `invalid-argument`: (set) The provided value was 0. fn receive_buffer_size(&self) -> Result; - fn set_receive_buffer_size(&self, value: u64) -> Result<(), ErrorCode>; + fn set_receive_buffer_size( + &self, + value: u64, + ) -> Result<(), ErrorCode>; fn send_buffer_size(&self) -> Result; fn set_send_buffer_size(&self, value: u64) -> Result<(), ErrorCode>; + /// Create a `pollable` which will resolve once the socket is ready for I/O. + /// + /// Note: this function is here for WASI Preview2 only. + /// It's planned to be removed when `future` is natively supported in Preview3. fn subscribe(&self) -> Pollable; } pub trait GuestIncomingDatagramStream: 'static { @@ -19332,10 +20544,11 @@ pub mod exports { let _ = val; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]wasi:sockets/udp@0.2.0")] + #[link( + wasm_import_module = "[export]wasi:sockets/udp@0.2.0" + )] extern "C" { #[link_name = "[resource-new]incoming-datagram-stream"] fn new(_: *mut u8) -> u32; @@ -19343,7 +20556,6 @@ pub mod exports { new(val) } } - #[doc(hidden)] fn _resource_rep(handle: u32) -> *mut u8 where @@ -19354,10 +20566,11 @@ pub mod exports { let _ = handle; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]wasi:sockets/udp@0.2.0")] + #[link( + wasm_import_module = "[export]wasi:sockets/udp@0.2.0" + )] extern "C" { #[link_name = "[resource-rep]incoming-datagram-stream"] fn rep(_: u32) -> *mut u8; @@ -19365,11 +20578,37 @@ pub mod exports { unsafe { rep(handle) } } } - + /// Receive messages on the socket. + /// + /// This function attempts to receive up to `max-results` datagrams on the socket without blocking. + /// The returned list may contain fewer elements than requested, but never more. + /// + /// This function returns successfully with an empty list when either: + /// - `max-results` is 0, or: + /// - `max-results` is greater than 0, but no results are immediately available. + /// This function never returns `error(would-block)`. + /// + /// # Typical errors + /// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// - `connection-refused`: The connection was refused. (ECONNREFUSED) + /// + /// # References + /// - + /// - + /// - + /// - + /// - + /// - + /// - + /// - fn receive( &self, max_results: u64, ) -> Result<_rt::Vec, ErrorCode>; + /// Create a `pollable` which will resolve once the stream is ready to receive again. + /// + /// Note: this function is here for WASI Preview2 only. + /// It's planned to be removed when `future` is natively supported in Preview3. fn subscribe(&self) -> Pollable; } pub trait GuestOutgoingDatagramStream: 'static { @@ -19383,10 +20622,11 @@ pub mod exports { let _ = val; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]wasi:sockets/udp@0.2.0")] + #[link( + wasm_import_module = "[export]wasi:sockets/udp@0.2.0" + )] extern "C" { #[link_name = "[resource-new]outgoing-datagram-stream"] fn new(_: *mut u8) -> u32; @@ -19394,7 +20634,6 @@ pub mod exports { new(val) } } - #[doc(hidden)] fn _resource_rep(handle: u32) -> *mut u8 where @@ -19405,10 +20644,11 @@ pub mod exports { let _ = handle; unreachable!(); } - #[cfg(target_arch = "wasm32")] { - #[link(wasm_import_module = "[export]wasi:sockets/udp@0.2.0")] + #[link( + wasm_import_module = "[export]wasi:sockets/udp@0.2.0" + )] extern "C" { #[link_name = "[resource-rep]outgoing-datagram-stream"] fn rep(_: u32) -> *mut u8; @@ -19416,146 +20656,306 @@ pub mod exports { unsafe { rep(handle) } } } - + /// Check readiness for sending. This function never blocks. + /// + /// Returns the number of datagrams permitted for the next call to `send`, + /// or an error. Calling `send` with more datagrams than this function has + /// permitted will trap. + /// + /// When this function returns ok(0), the `subscribe` pollable will + /// become ready when this function will report at least ok(1), or an + /// error. + /// + /// Never returns `would-block`. fn check_send(&self) -> Result; - fn send(&self, datagrams: _rt::Vec) - -> Result; + /// Send messages on the socket. + /// + /// This function attempts to send all provided `datagrams` on the socket without blocking and + /// returns how many messages were actually sent (or queued for sending). This function never + /// returns `error(would-block)`. If none of the datagrams were able to be sent, `ok(0)` is returned. + /// + /// This function semantically behaves the same as iterating the `datagrams` list and sequentially + /// sending each individual datagram until either the end of the list has been reached or the first error occurred. + /// If at least one datagram has been sent successfully, this function never returns an error. + /// + /// If the input list is empty, the function returns `ok(0)`. + /// + /// Each call to `send` must be permitted by a preceding `check-send`. Implementations must trap if + /// either `check-send` was not called or `datagrams` contains more items than `check-send` permitted. + /// + /// # Typical errors + /// - `invalid-argument`: The `remote-address` has the wrong address family. (EAFNOSUPPORT) + /// - `invalid-argument`: The IP address in `remote-address` is set to INADDR_ANY (`0.0.0.0` / `::`). (EDESTADDRREQ, EADDRNOTAVAIL) + /// - `invalid-argument`: The port in `remote-address` is set to 0. (EDESTADDRREQ, EADDRNOTAVAIL) + /// - `invalid-argument`: The socket is in "connected" mode and `remote-address` is `some` value that does not match the address passed to `stream`. (EISCONN) + /// - `invalid-argument`: The socket is not "connected" and no value for `remote-address` was provided. (EDESTADDRREQ) + /// - `remote-unreachable`: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET) + /// - `connection-refused`: The connection was refused. (ECONNREFUSED) + /// - `datagram-too-large`: The datagram is too large. (EMSGSIZE) + /// + /// # References + /// - + /// - + /// - + /// - + /// - + /// - + /// - + /// - + fn send( + &self, + datagrams: _rt::Vec, + ) -> Result; + /// Create a `pollable` which will resolve once the stream is ready to send again. + /// + /// Note: this function is here for WASI Preview2 only. + /// It's planned to be removed when `future` is natively supported in Preview3. fn subscribe(&self) -> Pollable; } #[doc(hidden)] - - macro_rules! __export_wasi_sockets_udp_0_2_0_cabi{ - ($ty:ident with_types_in $($path_to_types:tt)*) => (const _: () = { - - #[export_name = "wasi:sockets/udp@0.2.0#[method]udp-socket.start-bind"] - unsafe extern "C" fn export_method_udp_socket_start_bind(arg0: *mut u8,arg1: i32,arg2: i32,arg3: i32,arg4: i32,arg5: i32,arg6: i32,arg7: i32,arg8: i32,arg9: i32,arg10: i32,arg11: i32,arg12: i32,arg13: i32,) -> *mut u8 { - $($path_to_types)*::_export_method_udp_socket_start_bind_cabi::<<$ty as $($path_to_types)*::Guest>::UdpSocket>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]udp-socket.finish-bind"] - unsafe extern "C" fn export_method_udp_socket_finish_bind(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_udp_socket_finish_bind_cabi::<<$ty as $($path_to_types)*::Guest>::UdpSocket>(arg0) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]udp-socket.stream"] - unsafe extern "C" fn export_method_udp_socket_stream(arg0: *mut u8,arg1: i32,arg2: i32,arg3: i32,arg4: i32,arg5: i32,arg6: i32,arg7: i32,arg8: i32,arg9: i32,arg10: i32,arg11: i32,arg12: i32,arg13: i32,) -> *mut u8 { - $($path_to_types)*::_export_method_udp_socket_stream_cabi::<<$ty as $($path_to_types)*::Guest>::UdpSocket>(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]udp-socket.local-address"] - unsafe extern "C" fn export_method_udp_socket_local_address(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_udp_socket_local_address_cabi::<<$ty as $($path_to_types)*::Guest>::UdpSocket>(arg0) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]udp-socket.remote-address"] - unsafe extern "C" fn export_method_udp_socket_remote_address(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_udp_socket_remote_address_cabi::<<$ty as $($path_to_types)*::Guest>::UdpSocket>(arg0) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]udp-socket.address-family"] - unsafe extern "C" fn export_method_udp_socket_address_family(arg0: *mut u8,) -> i32 { - $($path_to_types)*::_export_method_udp_socket_address_family_cabi::<<$ty as $($path_to_types)*::Guest>::UdpSocket>(arg0) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]udp-socket.unicast-hop-limit"] - unsafe extern "C" fn export_method_udp_socket_unicast_hop_limit(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_udp_socket_unicast_hop_limit_cabi::<<$ty as $($path_to_types)*::Guest>::UdpSocket>(arg0) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]udp-socket.set-unicast-hop-limit"] - unsafe extern "C" fn export_method_udp_socket_set_unicast_hop_limit(arg0: *mut u8,arg1: i32,) -> *mut u8 { - $($path_to_types)*::_export_method_udp_socket_set_unicast_hop_limit_cabi::<<$ty as $($path_to_types)*::Guest>::UdpSocket>(arg0, arg1) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]udp-socket.receive-buffer-size"] - unsafe extern "C" fn export_method_udp_socket_receive_buffer_size(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_udp_socket_receive_buffer_size_cabi::<<$ty as $($path_to_types)*::Guest>::UdpSocket>(arg0) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]udp-socket.set-receive-buffer-size"] - unsafe extern "C" fn export_method_udp_socket_set_receive_buffer_size(arg0: *mut u8,arg1: i64,) -> *mut u8 { - $($path_to_types)*::_export_method_udp_socket_set_receive_buffer_size_cabi::<<$ty as $($path_to_types)*::Guest>::UdpSocket>(arg0, arg1) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]udp-socket.send-buffer-size"] - unsafe extern "C" fn export_method_udp_socket_send_buffer_size(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_udp_socket_send_buffer_size_cabi::<<$ty as $($path_to_types)*::Guest>::UdpSocket>(arg0) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]udp-socket.set-send-buffer-size"] - unsafe extern "C" fn export_method_udp_socket_set_send_buffer_size(arg0: *mut u8,arg1: i64,) -> *mut u8 { - $($path_to_types)*::_export_method_udp_socket_set_send_buffer_size_cabi::<<$ty as $($path_to_types)*::Guest>::UdpSocket>(arg0, arg1) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]udp-socket.subscribe"] - unsafe extern "C" fn export_method_udp_socket_subscribe(arg0: *mut u8,) -> i32 { - $($path_to_types)*::_export_method_udp_socket_subscribe_cabi::<<$ty as $($path_to_types)*::Guest>::UdpSocket>(arg0) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]incoming-datagram-stream.receive"] - unsafe extern "C" fn export_method_incoming_datagram_stream_receive(arg0: *mut u8,arg1: i64,) -> *mut u8 { - $($path_to_types)*::_export_method_incoming_datagram_stream_receive_cabi::<<$ty as $($path_to_types)*::Guest>::IncomingDatagramStream>(arg0, arg1) - } - #[export_name = "cabi_post_wasi:sockets/udp@0.2.0#[method]incoming-datagram-stream.receive"] - unsafe extern "C" fn _post_return_method_incoming_datagram_stream_receive(arg0: *mut u8,) { - $($path_to_types)*::__post_return_method_incoming_datagram_stream_receive::<<$ty as $($path_to_types)*::Guest>::IncomingDatagramStream>(arg0) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]incoming-datagram-stream.subscribe"] - unsafe extern "C" fn export_method_incoming_datagram_stream_subscribe(arg0: *mut u8,) -> i32 { - $($path_to_types)*::_export_method_incoming_datagram_stream_subscribe_cabi::<<$ty as $($path_to_types)*::Guest>::IncomingDatagramStream>(arg0) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]outgoing-datagram-stream.check-send"] - unsafe extern "C" fn export_method_outgoing_datagram_stream_check_send(arg0: *mut u8,) -> *mut u8 { - $($path_to_types)*::_export_method_outgoing_datagram_stream_check_send_cabi::<<$ty as $($path_to_types)*::Guest>::OutgoingDatagramStream>(arg0) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]outgoing-datagram-stream.send"] - unsafe extern "C" fn export_method_outgoing_datagram_stream_send(arg0: *mut u8,arg1: *mut u8,arg2: usize,) -> *mut u8 { - $($path_to_types)*::_export_method_outgoing_datagram_stream_send_cabi::<<$ty as $($path_to_types)*::Guest>::OutgoingDatagramStream>(arg0, arg1, arg2) - } - #[export_name = "wasi:sockets/udp@0.2.0#[method]outgoing-datagram-stream.subscribe"] - unsafe extern "C" fn export_method_outgoing_datagram_stream_subscribe(arg0: *mut u8,) -> i32 { - $($path_to_types)*::_export_method_outgoing_datagram_stream_subscribe_cabi::<<$ty as $($path_to_types)*::Guest>::OutgoingDatagramStream>(arg0) - } - - const _: () = { - #[doc(hidden)] - #[export_name = "wasi:sockets/udp@0.2.0#[dtor]udp-socket"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: *mut u8) { - $($path_to_types)*::UdpSocket::dtor::< - <$ty as $($path_to_types)*::Guest>::UdpSocket - >(rep) - } - }; - - - const _: () = { - #[doc(hidden)] - #[export_name = "wasi:sockets/udp@0.2.0#[dtor]incoming-datagram-stream"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: *mut u8) { - $($path_to_types)*::IncomingDatagramStream::dtor::< - <$ty as $($path_to_types)*::Guest>::IncomingDatagramStream - >(rep) - } - }; - - - const _: () = { - #[doc(hidden)] - #[export_name = "wasi:sockets/udp@0.2.0#[dtor]outgoing-datagram-stream"] - #[allow(non_snake_case)] - unsafe extern "C" fn dtor(rep: *mut u8) { - $($path_to_types)*::OutgoingDatagramStream::dtor::< - <$ty as $($path_to_types)*::Guest>::OutgoingDatagramStream - >(rep) - } - }; - - };); -} + macro_rules! __export_wasi_sockets_udp_0_2_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "wasi:sockets/udp@0.2.0#[method]udp-socket.start-bind"] unsafe + extern "C" fn export_method_udp_socket_start_bind(arg0 : * mut + u8, arg1 : i32, arg2 : i32, arg3 : i32, arg4 : i32, arg5 : i32, + arg6 : i32, arg7 : i32, arg8 : i32, arg9 : i32, arg10 : i32, + arg11 : i32, arg12 : i32, arg13 : i32,) -> * mut u8 { + $($path_to_types)*:: + _export_method_udp_socket_start_bind_cabi::<<$ty as + $($path_to_types)*:: Guest >::UdpSocket > (arg0, arg1, arg2, + arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, + arg13) } #[export_name = + "wasi:sockets/udp@0.2.0#[method]udp-socket.finish-bind"] unsafe + extern "C" fn export_method_udp_socket_finish_bind(arg0 : * mut + u8,) -> * mut u8 { $($path_to_types)*:: + _export_method_udp_socket_finish_bind_cabi::<<$ty as + $($path_to_types)*:: Guest >::UdpSocket > (arg0) } #[export_name + = "wasi:sockets/udp@0.2.0#[method]udp-socket.stream"] unsafe + extern "C" fn export_method_udp_socket_stream(arg0 : * mut u8, + arg1 : i32, arg2 : i32, arg3 : i32, arg4 : i32, arg5 : i32, arg6 + : i32, arg7 : i32, arg8 : i32, arg9 : i32, arg10 : i32, arg11 : + i32, arg12 : i32, arg13 : i32,) -> * mut u8 { + $($path_to_types)*:: _export_method_udp_socket_stream_cabi::<<$ty + as $($path_to_types)*:: Guest >::UdpSocket > (arg0, arg1, arg2, + arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, + arg13) } #[export_name = + "wasi:sockets/udp@0.2.0#[method]udp-socket.local-address"] unsafe + extern "C" fn export_method_udp_socket_local_address(arg0 : * mut + u8,) -> * mut u8 { $($path_to_types)*:: + _export_method_udp_socket_local_address_cabi::<<$ty as + $($path_to_types)*:: Guest >::UdpSocket > (arg0) } #[export_name + = "wasi:sockets/udp@0.2.0#[method]udp-socket.remote-address"] + unsafe extern "C" fn export_method_udp_socket_remote_address(arg0 + : * mut u8,) -> * mut u8 { $($path_to_types)*:: + _export_method_udp_socket_remote_address_cabi::<<$ty as + $($path_to_types)*:: Guest >::UdpSocket > (arg0) } #[export_name + = "wasi:sockets/udp@0.2.0#[method]udp-socket.address-family"] + unsafe extern "C" fn export_method_udp_socket_address_family(arg0 + : * mut u8,) -> i32 { $($path_to_types)*:: + _export_method_udp_socket_address_family_cabi::<<$ty as + $($path_to_types)*:: Guest >::UdpSocket > (arg0) } #[export_name + = "wasi:sockets/udp@0.2.0#[method]udp-socket.unicast-hop-limit"] + unsafe extern "C" fn + export_method_udp_socket_unicast_hop_limit(arg0 : * mut u8,) -> * + mut u8 { $($path_to_types)*:: + _export_method_udp_socket_unicast_hop_limit_cabi::<<$ty as + $($path_to_types)*:: Guest >::UdpSocket > (arg0) } #[export_name + = + "wasi:sockets/udp@0.2.0#[method]udp-socket.set-unicast-hop-limit"] + unsafe extern "C" fn + export_method_udp_socket_set_unicast_hop_limit(arg0 : * mut u8, + arg1 : i32,) -> * mut u8 { $($path_to_types)*:: + _export_method_udp_socket_set_unicast_hop_limit_cabi::<<$ty as + $($path_to_types)*:: Guest >::UdpSocket > (arg0, arg1) } + #[export_name = + "wasi:sockets/udp@0.2.0#[method]udp-socket.receive-buffer-size"] + unsafe extern "C" fn + export_method_udp_socket_receive_buffer_size(arg0 : * mut u8,) -> + * mut u8 { $($path_to_types)*:: + _export_method_udp_socket_receive_buffer_size_cabi::<<$ty as + $($path_to_types)*:: Guest >::UdpSocket > (arg0) } #[export_name + = + "wasi:sockets/udp@0.2.0#[method]udp-socket.set-receive-buffer-size"] + unsafe extern "C" fn + export_method_udp_socket_set_receive_buffer_size(arg0 : * mut u8, + arg1 : i64,) -> * mut u8 { $($path_to_types)*:: + _export_method_udp_socket_set_receive_buffer_size_cabi::<<$ty as + $($path_to_types)*:: Guest >::UdpSocket > (arg0, arg1) } + #[export_name = + "wasi:sockets/udp@0.2.0#[method]udp-socket.send-buffer-size"] + unsafe extern "C" fn + export_method_udp_socket_send_buffer_size(arg0 : * mut u8,) -> * + mut u8 { $($path_to_types)*:: + _export_method_udp_socket_send_buffer_size_cabi::<<$ty as + $($path_to_types)*:: Guest >::UdpSocket > (arg0) } #[export_name + = + "wasi:sockets/udp@0.2.0#[method]udp-socket.set-send-buffer-size"] + unsafe extern "C" fn + export_method_udp_socket_set_send_buffer_size(arg0 : * mut u8, + arg1 : i64,) -> * mut u8 { $($path_to_types)*:: + _export_method_udp_socket_set_send_buffer_size_cabi::<<$ty as + $($path_to_types)*:: Guest >::UdpSocket > (arg0, arg1) } + #[export_name = + "wasi:sockets/udp@0.2.0#[method]udp-socket.subscribe"] unsafe + extern "C" fn export_method_udp_socket_subscribe(arg0 : * mut + u8,) -> i32 { $($path_to_types)*:: + _export_method_udp_socket_subscribe_cabi::<<$ty as + $($path_to_types)*:: Guest >::UdpSocket > (arg0) } #[export_name + = + "wasi:sockets/udp@0.2.0#[method]incoming-datagram-stream.receive"] + unsafe extern "C" fn + export_method_incoming_datagram_stream_receive(arg0 : * mut u8, + arg1 : i64,) -> * mut u8 { $($path_to_types)*:: + _export_method_incoming_datagram_stream_receive_cabi::<<$ty as + $($path_to_types)*:: Guest >::IncomingDatagramStream > (arg0, + arg1) } #[export_name = + "cabi_post_wasi:sockets/udp@0.2.0#[method]incoming-datagram-stream.receive"] + unsafe extern "C" fn + _post_return_method_incoming_datagram_stream_receive(arg0 : * mut + u8,) { $($path_to_types)*:: + __post_return_method_incoming_datagram_stream_receive::<<$ty as + $($path_to_types)*:: Guest >::IncomingDatagramStream > (arg0) } + #[export_name = + "wasi:sockets/udp@0.2.0#[method]incoming-datagram-stream.subscribe"] + unsafe extern "C" fn + export_method_incoming_datagram_stream_subscribe(arg0 : * mut + u8,) -> i32 { $($path_to_types)*:: + _export_method_incoming_datagram_stream_subscribe_cabi::<<$ty as + $($path_to_types)*:: Guest >::IncomingDatagramStream > (arg0) } + #[export_name = + "wasi:sockets/udp@0.2.0#[method]outgoing-datagram-stream.check-send"] + unsafe extern "C" fn + export_method_outgoing_datagram_stream_check_send(arg0 : * mut + u8,) -> * mut u8 { $($path_to_types)*:: + _export_method_outgoing_datagram_stream_check_send_cabi::<<$ty as + $($path_to_types)*:: Guest >::OutgoingDatagramStream > (arg0) } + #[export_name = + "wasi:sockets/udp@0.2.0#[method]outgoing-datagram-stream.send"] + unsafe extern "C" fn + export_method_outgoing_datagram_stream_send(arg0 : * mut u8, arg1 + : * mut u8, arg2 : usize,) -> * mut u8 { $($path_to_types)*:: + _export_method_outgoing_datagram_stream_send_cabi::<<$ty as + $($path_to_types)*:: Guest >::OutgoingDatagramStream > (arg0, + arg1, arg2) } #[export_name = + "wasi:sockets/udp@0.2.0#[method]outgoing-datagram-stream.subscribe"] + unsafe extern "C" fn + export_method_outgoing_datagram_stream_subscribe(arg0 : * mut + u8,) -> i32 { $($path_to_types)*:: + _export_method_outgoing_datagram_stream_subscribe_cabi::<<$ty as + $($path_to_types)*:: Guest >::OutgoingDatagramStream > (arg0) } + const _ : () = { #[doc(hidden)] #[export_name = + "wasi:sockets/udp@0.2.0#[dtor]udp-socket"] + #[allow(non_snake_case)] unsafe extern "C" fn dtor(rep : * mut + u8) { $($path_to_types)*:: UdpSocket::dtor::< <$ty as + $($path_to_types)*:: Guest >::UdpSocket > (rep) } }; const _ : () + = { #[doc(hidden)] #[export_name = + "wasi:sockets/udp@0.2.0#[dtor]incoming-datagram-stream"] + #[allow(non_snake_case)] unsafe extern "C" fn dtor(rep : * mut + u8) { $($path_to_types)*:: IncomingDatagramStream::dtor::< <$ty + as $($path_to_types)*:: Guest >::IncomingDatagramStream > (rep) } + }; const _ : () = { #[doc(hidden)] #[export_name = + "wasi:sockets/udp@0.2.0#[dtor]outgoing-datagram-stream"] + #[allow(non_snake_case)] unsafe extern "C" fn dtor(rep : * mut + u8) { $($path_to_types)*:: OutgoingDatagramStream::dtor::< <$ty + as $($path_to_types)*:: Guest >::OutgoingDatagramStream > (rep) } + }; }; + }; + } #[doc(hidden)] pub(crate) use __export_wasi_sockets_udp_0_2_0_cabi; #[repr(align(8))] struct _RetArea([::core::mem::MaybeUninit; 36]); - static mut _RET_AREA: _RetArea = _RetArea([::core::mem::MaybeUninit::uninit(); 36]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 36], + ); + } + #[allow(dead_code, clippy::all)] + pub mod udp_create_socket { + #[used] + #[doc(hidden)] + static __FORCE_SECTION_REF: fn() = super::super::super::super::__link_custom_section_describing_imports; + use super::super::super::super::_rt; + pub type ErrorCode = super::super::super::super::wasi::sockets0_2_0::network::ErrorCode; + pub type IpAddressFamily = super::super::super::super::wasi::sockets0_2_0::network::IpAddressFamily; + pub type UdpSocket = super::super::super::super::exports::wasi::sockets0_2_0::udp::UdpSocket; + pub type UdpSocketBorrow<'a> = super::super::super::super::exports::wasi::sockets0_2_0::udp::UdpSocketBorrow< + 'a, + >; + #[doc(hidden)] + #[allow(non_snake_case)] + pub unsafe fn _export_create_udp_socket_cabi( + arg0: i32, + ) -> *mut u8 { + #[cfg(target_arch = "wasm32")] _rt::run_ctors_once(); + let result0 = T::create_udp_socket( + super::super::super::super::wasi::sockets0_2_0::network::IpAddressFamily::_lift( + arg0 as u8, + ), + ); + let ptr1 = _RET_AREA.0.as_mut_ptr().cast::(); + match result0 { + Ok(e) => { + *ptr1.add(0).cast::() = (0i32) as u8; + *ptr1.add(4).cast::() = (e).take_handle() as i32; + } + Err(e) => { + *ptr1.add(0).cast::() = (1i32) as u8; + *ptr1.add(4).cast::() = (e.clone() as i32) as u8; + } + }; + ptr1 + } + pub trait Guest { + /// Create a new UDP socket. + /// + /// Similar to `socket(AF_INET or AF_INET6, SOCK_DGRAM, IPPROTO_UDP)` in POSIX. + /// On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise. + /// + /// This function does not require a network capability handle. This is considered to be safe because + /// at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind` is called, + /// the socket is effectively an in-memory configuration object, unable to communicate with the outside world. + /// + /// All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous operations. + /// + /// # Typical errors + /// - `not-supported`: The specified `address-family` is not supported. (EAFNOSUPPORT) + /// - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE) + /// + /// # References: + /// - + /// - + /// - + /// - + fn create_udp_socket( + address_family: IpAddressFamily, + ) -> Result; + } + #[doc(hidden)] + macro_rules! __export_wasi_sockets_udp_create_socket_0_2_0_cabi { + ($ty:ident with_types_in $($path_to_types:tt)*) => { + const _ : () = { #[export_name = + "wasi:sockets/udp-create-socket@0.2.0#create-udp-socket"] unsafe + extern "C" fn export_create_udp_socket(arg0 : i32,) -> * mut u8 { + $($path_to_types)*:: _export_create_udp_socket_cabi::<$ty > + (arg0) } }; + }; + } + #[doc(hidden)] + pub(crate) use __export_wasi_sockets_udp_create_socket_0_2_0_cabi; + #[repr(align(4))] + struct _RetArea([::core::mem::MaybeUninit; 8]); + static mut _RET_AREA: _RetArea = _RetArea( + [::core::mem::MaybeUninit::uninit(); 8], + ); } } } } mod _rt { - 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. /// @@ -19570,16 +20970,9 @@ mod _rt { /// 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. /// @@ -19589,7 +20982,6 @@ mod _rt { /// Invokes the `[resource-drop]...` intrinsic. unsafe fn drop(handle: u32); } - impl Resource { #[doc(hidden)] pub unsafe fn from_handle(handle: u32) -> Self { @@ -19599,7 +20991,6 @@ mod _rt { _marker: marker::PhantomData, } } - /// Takes ownership of the handle owned by `resource`. /// /// Note that this ideally would be `into_handle` taking `Resource` by @@ -19616,31 +21007,21 @@ mod _rt { 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() + 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), } } @@ -19667,28 +21048,23 @@ mod _rt { } } pub use alloc_crate::alloc; - 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 { @@ -19702,70 +21078,59 @@ mod _rt { core::hint::unreachable_unchecked() } } - 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 { @@ -19777,50 +21142,41 @@ mod _rt { return; } let layout = alloc::Layout::from_size_align_unchecked(size, align); - alloc::dealloc(ptr as *mut u8, layout); + alloc::dealloc(ptr, layout); } - #[cfg(target_arch = "wasm32")] pub fn run_ctors_once() { wit_bindgen_rt::run_ctors_once(); } pub use alloc_crate::boxed::Box; - pub fn as_f32(t: T) -> f32 { t.as_f32() } - pub trait AsF32 { fn as_f32(self) -> f32; } - impl<'a, T: Copy + AsF32> AsF32 for &'a T { fn as_f32(self) -> f32 { (*self).as_f32() } } - impl AsF32 for f32 { #[inline] fn as_f32(self) -> f32 { self as f32 } } - 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 { @@ -19829,7 +21185,6 @@ mod _rt { } extern crate alloc as alloc_crate; } - /// Generates `#[no_mangle]` functions to export the specified type as the /// root implementation of all generated traits. /// @@ -19848,44 +21203,80 @@ mod _rt { /// ``` #[allow(unused_macros)] #[doc(hidden)] - macro_rules! __export_deny_all_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::cli0_2_0::environment::__export_wasi_cli_environment_0_2_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::wasi::cli0_2_0::environment); - $($path_to_types_root)*::exports::wasi::filesystem0_2_0::preopens::__export_wasi_filesystem_preopens_0_2_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::wasi::filesystem0_2_0::preopens); - $($path_to_types_root)*::exports::wasi::http0_2_0::outgoing_handler::__export_wasi_http_outgoing_handler_0_2_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::wasi::http0_2_0::outgoing_handler); - $($path_to_types_root)*::exports::wasi::sockets0_2_0::ip_name_lookup::__export_wasi_sockets_ip_name_lookup_0_2_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::wasi::sockets0_2_0::ip_name_lookup); - $($path_to_types_root)*::exports::wasi::sockets0_2_0::tcp::__export_wasi_sockets_tcp_0_2_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::wasi::sockets0_2_0::tcp); - $($path_to_types_root)*::exports::wasi::sockets0_2_0::udp::__export_wasi_sockets_udp_0_2_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::wasi::sockets0_2_0::udp); - $($path_to_types_root)*::exports::fermyon::spin::llm::__export_fermyon_spin_llm_2_0_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::fermyon::spin::llm); - $($path_to_types_root)*::exports::fermyon::spin::redis::__export_fermyon_spin_redis_2_0_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::fermyon::spin::redis); - $($path_to_types_root)*::exports::fermyon::spin::mqtt::__export_fermyon_spin_mqtt_2_0_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::fermyon::spin::mqtt); - $($path_to_types_root)*::exports::fermyon::spin::rdbms_types::__export_fermyon_spin_rdbms_types_2_0_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::fermyon::spin::rdbms_types); - $($path_to_types_root)*::exports::fermyon::spin::postgres::__export_fermyon_spin_postgres_2_0_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::fermyon::spin::postgres); - $($path_to_types_root)*::exports::fermyon::spin::mysql::__export_fermyon_spin_mysql_2_0_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::fermyon::spin::mysql); - $($path_to_types_root)*::exports::fermyon::spin::sqlite::__export_fermyon_spin_sqlite_2_0_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::fermyon::spin::sqlite); - $($path_to_types_root)*::exports::fermyon::spin::key_value::__export_fermyon_spin_key_value_2_0_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::fermyon::spin::key_value); - $($path_to_types_root)*::exports::fermyon::spin::variables::__export_fermyon_spin_variables_2_0_0_cabi!($ty with_types_in $($path_to_types_root)*::exports::fermyon::spin::variables); - ) + ($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::cli0_2_0::environment::__export_wasi_cli_environment_0_2_0_cabi!($ty + with_types_in $($path_to_types_root)*:: exports::wasi::cli0_2_0::environment); + $($path_to_types_root)*:: + exports::wasi::filesystem0_2_0::preopens::__export_wasi_filesystem_preopens_0_2_0_cabi!($ty + with_types_in $($path_to_types_root)*:: + exports::wasi::filesystem0_2_0::preopens); $($path_to_types_root)*:: + exports::wasi::http0_2_0::outgoing_handler::__export_wasi_http_outgoing_handler_0_2_0_cabi!($ty + with_types_in $($path_to_types_root)*:: + exports::wasi::http0_2_0::outgoing_handler); $($path_to_types_root)*:: + exports::wasi::sockets0_2_0::ip_name_lookup::__export_wasi_sockets_ip_name_lookup_0_2_0_cabi!($ty + with_types_in $($path_to_types_root)*:: + exports::wasi::sockets0_2_0::ip_name_lookup); $($path_to_types_root)*:: + exports::wasi::sockets0_2_0::tcp::__export_wasi_sockets_tcp_0_2_0_cabi!($ty + with_types_in $($path_to_types_root)*:: exports::wasi::sockets0_2_0::tcp); + $($path_to_types_root)*:: + exports::wasi::sockets0_2_0::tcp_create_socket::__export_wasi_sockets_tcp_create_socket_0_2_0_cabi!($ty + with_types_in $($path_to_types_root)*:: + exports::wasi::sockets0_2_0::tcp_create_socket); $($path_to_types_root)*:: + exports::wasi::sockets0_2_0::udp::__export_wasi_sockets_udp_0_2_0_cabi!($ty + with_types_in $($path_to_types_root)*:: exports::wasi::sockets0_2_0::udp); + $($path_to_types_root)*:: + exports::wasi::sockets0_2_0::udp_create_socket::__export_wasi_sockets_udp_create_socket_0_2_0_cabi!($ty + with_types_in $($path_to_types_root)*:: + exports::wasi::sockets0_2_0::udp_create_socket); $($path_to_types_root)*:: + exports::fermyon::spin::llm::__export_fermyon_spin_llm_2_0_0_cabi!($ty + with_types_in $($path_to_types_root)*:: exports::fermyon::spin::llm); + $($path_to_types_root)*:: + exports::fermyon::spin::redis::__export_fermyon_spin_redis_2_0_0_cabi!($ty + with_types_in $($path_to_types_root)*:: exports::fermyon::spin::redis); + $($path_to_types_root)*:: + exports::fermyon::spin::mqtt::__export_fermyon_spin_mqtt_2_0_0_cabi!($ty + with_types_in $($path_to_types_root)*:: exports::fermyon::spin::mqtt); + $($path_to_types_root)*:: + exports::fermyon::spin::rdbms_types::__export_fermyon_spin_rdbms_types_2_0_0_cabi!($ty + with_types_in $($path_to_types_root)*:: exports::fermyon::spin::rdbms_types); + $($path_to_types_root)*:: + exports::fermyon::spin::postgres::__export_fermyon_spin_postgres_2_0_0_cabi!($ty + with_types_in $($path_to_types_root)*:: exports::fermyon::spin::postgres); + $($path_to_types_root)*:: + exports::fermyon::spin::mysql::__export_fermyon_spin_mysql_2_0_0_cabi!($ty + with_types_in $($path_to_types_root)*:: exports::fermyon::spin::mysql); + $($path_to_types_root)*:: + exports::fermyon::spin::sqlite::__export_fermyon_spin_sqlite_2_0_0_cabi!($ty + with_types_in $($path_to_types_root)*:: exports::fermyon::spin::sqlite); + $($path_to_types_root)*:: + exports::fermyon::spin::key_value::__export_fermyon_spin_key_value_2_0_0_cabi!($ty + with_types_in $($path_to_types_root)*:: exports::fermyon::spin::key_value); + $($path_to_types_root)*:: + exports::fermyon::spin::variables::__export_fermyon_spin_variables_2_0_0_cabi!($ty + with_types_in $($path_to_types_root)*:: exports::fermyon::spin::variables); + }; } #[doc(inline)] pub(crate) use __export_deny_all_impl as export; - #[cfg(target_arch = "wasm32")] -#[link_section = "component-type:wit-bindgen:0.25.0:deny-all:encoded world"] +#[link_section = "component-type:wit-bindgen:0.35.0:fermyon:spin-virt:deny-all:encoded world"] #[doc(hidden)] -pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 18084] = *b"\ -\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xa4\x8c\x01\x01A\x02\ -\x01AB\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\0\x01B\x0a\ +pub static __WIT_BINDGEN_COMPONENT_TYPE: [u8; 18482] = *b"\ +\0asm\x0d\0\x01\0\0\x19\x16wit-component-encoding\x04\0\x07\xb2\x8f\x01\x01A\x02\ +\x01AH\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\0\x13wasi:io/error@0.2.0\x05\0\x01B\x0a\ \x04\0\x08pollable\x03\x01\x01h\0\x01@\x01\x04self\x01\0\x7f\x04\0\x16[method]po\ llable.ready\x01\x02\x01@\x01\x04self\x01\x01\0\x04\0\x16[method]pollable.block\x01\ -\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04poll\x01\x06\x03\x01\x12wa\ -si:io/poll@0.2.0\x05\x01\x02\x03\0\0\x05error\x02\x03\0\x01\x08pollable\x01B(\x02\ -\x03\x02\x01\x02\x04\0\x05error\x03\0\0\x02\x03\x02\x01\x03\x04\0\x08pollable\x03\ -\0\x02\x01i\x01\x01q\x02\x15last-operation-failed\x01\x04\0\x06closed\0\0\x04\0\x0c\ -stream-error\x03\0\x05\x04\0\x0cinput-stream\x03\x01\x04\0\x0doutput-stream\x03\x01\ +\x03\x01p\x01\x01py\x01@\x01\x02in\x04\0\x05\x04\0\x04poll\x01\x06\x03\0\x12wasi\ +:io/poll@0.2.0\x05\x01\x02\x03\0\0\x05error\x02\x03\0\x01\x08pollable\x01B(\x02\x03\ +\x02\x01\x02\x04\0\x05error\x03\0\0\x02\x03\x02\x01\x03\x04\0\x08pollable\x03\0\x02\ +\x01i\x01\x01q\x02\x15last-operation-failed\x01\x04\0\x06closed\0\0\x04\0\x0cstr\ +eam-error\x03\0\x05\x04\0\x0cinput-stream\x03\x01\x04\0\x0doutput-stream\x03\x01\ \x01h\x07\x01p}\x01j\x01\x0a\x01\x06\x01@\x02\x04self\x09\x03lenw\0\x0b\x04\0\x19\ [method]input-stream.read\x01\x0c\x04\0\"[method]input-stream.blocking-read\x01\x0c\ \x01j\x01w\x01\x06\x01@\x02\x04self\x09\x03lenw\0\x0d\x04\0\x19[method]input-str\ @@ -19900,33 +21291,33 @@ utput-stream.subscribe\x01\x16\x01@\x02\x04self\x11\x03lenw\0\x13\x04\0\"[method ]output-stream.write-zeroes\x01\x17\x04\05[method]output-stream.blocking-write-z\ eroes-and-flush\x01\x17\x01@\x03\x04self\x11\x03src\x09\x03lenw\0\x0d\x04\0\x1c[\ method]output-stream.splice\x01\x18\x04\0%[method]output-stream.blocking-splice\x01\ -\x18\x03\x01\x15wasi:io/streams@0.2.0\x05\x04\x01B\x05\x01r\x02\x07secondsw\x0bn\ -anosecondsy\x04\0\x08datetime\x03\0\0\x01@\0\0\x01\x04\0\x03now\x01\x02\x04\0\x0a\ -resolution\x01\x02\x03\x01\x1cwasi:clocks/wall-clock@0.2.0\x05\x05\x02\x03\0\x02\ -\x0cinput-stream\x02\x03\0\x02\x0doutput-stream\x02\x03\0\x02\x05error\x02\x03\0\ -\x03\x08datetime\x01Br\x02\x03\x02\x01\x06\x04\0\x0cinput-stream\x03\0\0\x02\x03\ -\x02\x01\x07\x04\0\x0doutput-stream\x03\0\x02\x02\x03\x02\x01\x08\x04\0\x05error\ -\x03\0\x04\x02\x03\x02\x01\x09\x04\0\x08datetime\x03\0\x06\x01w\x04\0\x08filesiz\ -e\x03\0\x08\x01m\x08\x07unknown\x0cblock-device\x10character-device\x09directory\ -\x04fifo\x0dsymbolic-link\x0cregular-file\x06socket\x04\0\x0fdescriptor-type\x03\ -\0\x0a\x01n\x06\x04read\x05write\x13file-integrity-sync\x13data-integrity-sync\x14\ -requested-write-sync\x10mutate-directory\x04\0\x10descriptor-flags\x03\0\x0c\x01\ -n\x01\x0esymlink-follow\x04\0\x0apath-flags\x03\0\x0e\x01n\x04\x06create\x09dire\ -ctory\x09exclusive\x08truncate\x04\0\x0aopen-flags\x03\0\x10\x01w\x04\0\x0alink-\ -count\x03\0\x12\x01k\x07\x01r\x06\x04type\x0b\x0alink-count\x13\x04size\x09\x15d\ -ata-access-timestamp\x14\x1bdata-modification-timestamp\x14\x17status-change-tim\ -estamp\x14\x04\0\x0fdescriptor-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\x04\ -names\x04\0\x0fdirectory-entry\x03\0\x19\x01m%\x06access\x0bwould-block\x07alrea\ -dy\x0ebad-descriptor\x04busy\x08deadlock\x05quota\x05exist\x0efile-too-large\x15\ -illegal-byte-sequence\x0bin-progress\x0binterrupted\x07invalid\x02io\x0cis-direc\ -tory\x04loop\x0etoo-many-links\x0cmessage-size\x0dname-too-long\x09no-device\x08\ -no-entry\x07no-lock\x13insufficient-memory\x12insufficient-space\x0dnot-director\ -y\x09not-empty\x0fnot-recoverable\x0bunsupported\x06no-tty\x0eno-such-device\x08\ -overflow\x0dnot-permitted\x04pipe\x09read-only\x0cinvalid-seek\x0etext-file-busy\ -\x0ccross-device\x04\0\x0aerror-code\x03\0\x1b\x01m\x06\x06normal\x0asequential\x06\ -random\x09will-need\x09dont-need\x08no-reuse\x04\0\x06advice\x03\0\x1d\x01r\x02\x05\ -lowerw\x05upperw\x04\0\x13metadata-hash-value\x03\0\x1f\x04\0\x0adescriptor\x03\x01\ +\x18\x03\0\x15wasi:io/streams@0.2.0\x05\x04\x01B\x05\x01r\x02\x07secondsw\x0bnan\ +osecondsy\x04\0\x08datetime\x03\0\0\x01@\0\0\x01\x04\0\x03now\x01\x02\x04\0\x0ar\ +esolution\x01\x02\x03\0\x1cwasi:clocks/wall-clock@0.2.0\x05\x05\x02\x03\0\x02\x0c\ +input-stream\x02\x03\0\x02\x0doutput-stream\x02\x03\0\x02\x05error\x02\x03\0\x03\ +\x08datetime\x01Br\x02\x03\x02\x01\x06\x04\0\x0cinput-stream\x03\0\0\x02\x03\x02\ +\x01\x07\x04\0\x0doutput-stream\x03\0\x02\x02\x03\x02\x01\x08\x04\0\x05error\x03\ +\0\x04\x02\x03\x02\x01\x09\x04\0\x08datetime\x03\0\x06\x01w\x04\0\x08filesize\x03\ +\0\x08\x01m\x08\x07unknown\x0cblock-device\x10character-device\x09directory\x04f\ +ifo\x0dsymbolic-link\x0cregular-file\x06socket\x04\0\x0fdescriptor-type\x03\0\x0a\ +\x01n\x06\x04read\x05write\x13file-integrity-sync\x13data-integrity-sync\x14requ\ +ested-write-sync\x10mutate-directory\x04\0\x10descriptor-flags\x03\0\x0c\x01n\x01\ +\x0esymlink-follow\x04\0\x0apath-flags\x03\0\x0e\x01n\x04\x06create\x09directory\ +\x09exclusive\x08truncate\x04\0\x0aopen-flags\x03\0\x10\x01w\x04\0\x0alink-count\ +\x03\0\x12\x01k\x07\x01r\x06\x04type\x0b\x0alink-count\x13\x04size\x09\x15data-a\ +ccess-timestamp\x14\x1bdata-modification-timestamp\x14\x17status-change-timestam\ +p\x14\x04\0\x0fdescriptor-stat\x03\0\x15\x01q\x03\x09no-change\0\0\x03now\0\0\x09\ +timestamp\x01\x07\0\x04\0\x0dnew-timestamp\x03\0\x17\x01r\x02\x04type\x0b\x04nam\ +es\x04\0\x0fdirectory-entry\x03\0\x19\x01m%\x06access\x0bwould-block\x07already\x0e\ +bad-descriptor\x04busy\x08deadlock\x05quota\x05exist\x0efile-too-large\x15illega\ +l-byte-sequence\x0bin-progress\x0binterrupted\x07invalid\x02io\x0cis-directory\x04\ +loop\x0etoo-many-links\x0cmessage-size\x0dname-too-long\x09no-device\x08no-entry\ +\x07no-lock\x13insufficient-memory\x12insufficient-space\x0dnot-directory\x09not\ +-empty\x0fnot-recoverable\x0bunsupported\x06no-tty\x0eno-such-device\x08overflow\ +\x0dnot-permitted\x04pipe\x09read-only\x0cinvalid-seek\x0etext-file-busy\x0ccros\ +s-device\x04\0\x0aerror-code\x03\0\x1b\x01m\x06\x06normal\x0asequential\x06rando\ +m\x09will-need\x09dont-need\x08no-reuse\x04\0\x06advice\x03\0\x1d\x01r\x02\x05lo\ +werw\x05upperw\x04\0\x13metadata-hash-value\x03\0\x1f\x04\0\x0adescriptor\x03\x01\ \x04\0\x16directory-entry-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.w\ @@ -19961,14 +21352,14 @@ self#\x05other#\0\x7f\x04\0![method]descriptor.is-same-object\x01J\x01j\x01\x20\ @\x03\x04self#\x0apath-flags\x0f\x04paths\0\xcb\0\x04\0#[method]descriptor.metad\ ata-hash-at\x01M\x01h\"\x01k\x1a\x01j\x01\xcf\0\x01\x1c\x01@\x01\x04self\xce\0\0\ \xd0\0\x04\03[method]directory-entry-stream.read-directory-entry\x01Q\x01h\x05\x01\ -k\x1c\x01@\x01\x03err\xd2\0\0\xd3\0\x04\0\x15filesystem-error-code\x01T\x03\x01\x1b\ +k\x1c\x01@\x01\x03err\xd2\0\0\xd3\0\x04\0\x15filesystem-error-code\x01T\x03\0\x1b\ wasi:filesystem/types@0.2.0\x05\x0a\x01B\x0f\x02\x03\x02\x01\x03\x04\0\x08pollab\ le\x03\0\0\x01w\x04\0\x07instant\x03\0\x02\x01w\x04\0\x08duration\x03\0\x04\x01@\ \0\0\x03\x04\0\x03now\x01\x06\x01@\0\0\x05\x04\0\x0aresolution\x01\x07\x01i\x01\x01\ @\x01\x04when\x03\0\x08\x04\0\x11subscribe-instant\x01\x09\x01@\x01\x04when\x05\0\ -\x08\x04\0\x12subscribe-duration\x01\x0a\x03\x01!wasi:clocks/monotonic-clock@0.2\ -.0\x05\x0b\x02\x03\0\x05\x08duration\x01B\xc0\x01\x02\x03\x02\x01\x0c\x04\0\x08d\ -uration\x03\0\0\x02\x03\x02\x01\x06\x04\0\x0cinput-stream\x03\0\x02\x02\x03\x02\x01\ +\x08\x04\0\x12subscribe-duration\x01\x0a\x03\0!wasi:clocks/monotonic-clock@0.2.0\ +\x05\x0b\x02\x03\0\x05\x08duration\x01B\xc0\x01\x02\x03\x02\x01\x0c\x04\0\x08dur\ +ation\x03\0\0\x02\x03\x02\x01\x06\x04\0\x0cinput-stream\x03\0\x02\x02\x03\x02\x01\ \x07\x04\0\x0doutput-stream\x03\0\x04\x02\x03\x02\x01\x02\x04\0\x08io-error\x03\0\ \x06\x02\x03\x02\x01\x03\x04\0\x08pollable\x03\0\x08\x01q\x0a\x03get\0\0\x04head\ \0\0\x04post\0\0\x03put\0\0\x06delete\0\0\x07connect\0\0\x07options\0\0\x05trace\ @@ -20055,196 +21446,203 @@ trailers\xf2\0\0\x81\x01\x04\0\x1c[static]outgoing-body.finish\x01\x82\x01\x01h0 be\x01\x84\x01\x01i+\x01j\x01\x85\x01\x01\x1b\x01j\x01\x86\x01\0\x01k\x87\x01\x01\ @\x01\x04self\x83\x01\0\x88\x01\x04\0$[method]future-incoming-response.get\x01\x89\ \x01\x01h\x07\x01k\x1b\x01@\x01\x03err\x8a\x01\0\x8b\x01\x04\0\x0fhttp-error-cod\ -e\x01\x8c\x01\x03\x01\x15wasi:http/types@0.2.0\x05\x0d\x01B\x11\x04\0\x07network\ -\x03\x01\x01m\x15\x07unknown\x0daccess-denied\x0dnot-supported\x10invalid-argume\ -nt\x0dout-of-memory\x07timeout\x14concurrency-conflict\x0fnot-in-progress\x0bwou\ -ld-block\x0dinvalid-state\x10new-socket-limit\x14address-not-bindable\x0eaddress\ --in-use\x12remote-unreachable\x12connection-refused\x10connection-reset\x12conne\ -ction-aborted\x12datagram-too-large\x11name-unresolvable\x1atemporary-resolver-f\ -ailure\x1apermanent-resolver-failure\x04\0\x0aerror-code\x03\0\x01\x01m\x02\x04i\ -pv4\x04ipv6\x04\0\x11ip-address-family\x03\0\x03\x01o\x04}}}}\x04\0\x0cipv4-addr\ -ess\x03\0\x05\x01o\x08{{{{{{{{\x04\0\x0cipv6-address\x03\0\x07\x01q\x02\x04ipv4\x01\ -\x06\0\x04ipv6\x01\x08\0\x04\0\x0aip-address\x03\0\x09\x01r\x02\x04port{\x07addr\ -ess\x06\x04\0\x13ipv4-socket-address\x03\0\x0b\x01r\x04\x04port{\x09flow-infoy\x07\ -address\x08\x08scope-idy\x04\0\x13ipv6-socket-address\x03\0\x0d\x01q\x02\x04ipv4\ -\x01\x0c\0\x04ipv6\x01\x0e\0\x04\0\x11ip-socket-address\x03\0\x0f\x03\x01\x1awas\ -i:sockets/network@0.2.0\x05\x0e\x01B\x0a\x01o\x02ss\x01p\0\x01@\0\0\x01\x04\0\x0f\ -get-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\x04\x01\x1awasi:cli/environment@0.2.0\x05\ -\x0f\x02\x03\0\x04\x0adescriptor\x01B\x07\x02\x03\x02\x01\x10\x04\0\x0adescripto\ -r\x03\0\0\x01i\x01\x01o\x02\x02s\x01p\x03\x01@\0\0\x04\x04\0\x0fget-directories\x01\ -\x05\x04\x01\x1ewasi:filesystem/preopens@0.2.0\x05\x11\x02\x03\0\x06\x10outgoing\ --request\x02\x03\0\x06\x0frequest-options\x02\x03\0\x06\x18future-incoming-respo\ -nse\x02\x03\0\x06\x0aerror-code\x01B\x0f\x02\x03\x02\x01\x12\x04\0\x10outgoing-r\ -equest\x03\0\0\x02\x03\x02\x01\x13\x04\0\x0frequest-options\x03\0\x02\x02\x03\x02\ -\x01\x14\x04\0\x18future-incoming-response\x03\0\x04\x02\x03\x02\x01\x15\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\x04\x01\x20was\ -i:http/outgoing-handler@0.2.0\x05\x16\x02\x03\0\x07\x07network\x02\x03\0\x07\x0a\ -error-code\x02\x03\0\x07\x0aip-address\x01B\x16\x02\x03\x02\x01\x03\x04\0\x08pol\ -lable\x03\0\0\x02\x03\x02\x01\x17\x04\0\x07network\x03\0\x02\x02\x03\x02\x01\x18\ -\x04\0\x0aerror-code\x03\0\x04\x02\x03\x02\x01\x19\x04\0\x0aip-address\x03\0\x06\ -\x04\0\x16resolve-address-stream\x03\x01\x01h\x08\x01k\x07\x01j\x01\x0a\x01\x05\x01\ -@\x01\x04self\x09\0\x0b\x04\03[method]resolve-address-stream.resolve-next-addres\ -s\x01\x0c\x01i\x01\x01@\x01\x04self\x09\0\x0d\x04\0([method]resolve-address-stre\ -am.subscribe\x01\x0e\x01h\x03\x01i\x08\x01j\x01\x10\x01\x05\x01@\x02\x07network\x0f\ -\x04names\0\x11\x04\0\x11resolve-addresses\x01\x12\x04\x01!wasi:sockets/ip-name-\ -lookup@0.2.0\x05\x1a\x02\x03\0\x07\x11ip-socket-address\x02\x03\0\x07\x11ip-addr\ -ess-family\x01BT\x02\x03\x02\x01\x06\x04\0\x0cinput-stream\x03\0\0\x02\x03\x02\x01\ -\x07\x04\0\x0doutput-stream\x03\0\x02\x02\x03\x02\x01\x03\x04\0\x08pollable\x03\0\ -\x04\x02\x03\x02\x01\x0c\x04\0\x08duration\x03\0\x06\x02\x03\x02\x01\x17\x04\0\x07\ -network\x03\0\x08\x02\x03\x02\x01\x18\x04\0\x0aerror-code\x03\0\x0a\x02\x03\x02\x01\ -\x1b\x04\0\x11ip-socket-address\x03\0\x0c\x02\x03\x02\x01\x1c\x04\0\x11ip-addres\ -s-family\x03\0\x0e\x01m\x03\x07receive\x04send\x04both\x04\0\x0dshutdown-type\x03\ -\0\x10\x04\0\x0atcp-socket\x03\x01\x01h\x12\x01h\x09\x01j\0\x01\x0b\x01@\x03\x04\ -self\x13\x07network\x14\x0dlocal-address\x0d\0\x15\x04\0\x1d[method]tcp-socket.s\ -tart-bind\x01\x16\x01@\x01\x04self\x13\0\x15\x04\0\x1e[method]tcp-socket.finish-\ -bind\x01\x17\x01@\x03\x04self\x13\x07network\x14\x0eremote-address\x0d\0\x15\x04\ -\0\x20[method]tcp-socket.start-connect\x01\x18\x01i\x01\x01i\x03\x01o\x02\x19\x1a\ -\x01j\x01\x1b\x01\x0b\x01@\x01\x04self\x13\0\x1c\x04\0![method]tcp-socket.finish\ --connect\x01\x1d\x04\0\x1f[method]tcp-socket.start-listen\x01\x17\x04\0\x20[meth\ -od]tcp-socket.finish-listen\x01\x17\x01i\x12\x01o\x03\x1e\x19\x1a\x01j\x01\x1f\x01\ -\x0b\x01@\x01\x04self\x13\0\x20\x04\0\x19[method]tcp-socket.accept\x01!\x01j\x01\ -\x0d\x01\x0b\x01@\x01\x04self\x13\0\"\x04\0\x20[method]tcp-socket.local-address\x01\ -#\x04\0![method]tcp-socket.remote-address\x01#\x01@\x01\x04self\x13\0\x7f\x04\0\x1f\ -[method]tcp-socket.is-listening\x01$\x01@\x01\x04self\x13\0\x0f\x04\0![method]tc\ -p-socket.address-family\x01%\x01@\x02\x04self\x13\x05valuew\0\x15\x04\0*[method]\ -tcp-socket.set-listen-backlog-size\x01&\x01j\x01\x7f\x01\x0b\x01@\x01\x04self\x13\ -\0'\x04\0%[method]tcp-socket.keep-alive-enabled\x01(\x01@\x02\x04self\x13\x05val\ -ue\x7f\0\x15\x04\0)[method]tcp-socket.set-keep-alive-enabled\x01)\x01j\x01\x07\x01\ -\x0b\x01@\x01\x04self\x13\0*\x04\0'[method]tcp-socket.keep-alive-idle-time\x01+\x01\ -@\x02\x04self\x13\x05value\x07\0\x15\x04\0+[method]tcp-socket.set-keep-alive-idl\ -e-time\x01,\x04\0&[method]tcp-socket.keep-alive-interval\x01+\x04\0*[method]tcp-\ -socket.set-keep-alive-interval\x01,\x01j\x01y\x01\x0b\x01@\x01\x04self\x13\0-\x04\ -\0#[method]tcp-socket.keep-alive-count\x01.\x01@\x02\x04self\x13\x05valuey\0\x15\ -\x04\0'[method]tcp-socket.set-keep-alive-count\x01/\x01j\x01}\x01\x0b\x01@\x01\x04\ -self\x13\00\x04\0\x1c[method]tcp-socket.hop-limit\x011\x01@\x02\x04self\x13\x05v\ -alue}\0\x15\x04\0\x20[method]tcp-socket.set-hop-limit\x012\x01j\x01w\x01\x0b\x01\ -@\x01\x04self\x13\03\x04\0&[method]tcp-socket.receive-buffer-size\x014\x04\0*[me\ -thod]tcp-socket.set-receive-buffer-size\x01&\x04\0#[method]tcp-socket.send-buffe\ -r-size\x014\x04\0'[method]tcp-socket.set-send-buffer-size\x01&\x01i\x05\x01@\x01\ -\x04self\x13\05\x04\0\x1c[method]tcp-socket.subscribe\x016\x01@\x02\x04self\x13\x0d\ -shutdown-type\x11\0\x15\x04\0\x1b[method]tcp-socket.shutdown\x017\x04\x01\x16was\ -i:sockets/tcp@0.2.0\x05\x1d\x01BD\x02\x03\x02\x01\x03\x04\0\x08pollable\x03\0\0\x02\ -\x03\x02\x01\x17\x04\0\x07network\x03\0\x02\x02\x03\x02\x01\x18\x04\0\x0aerror-c\ -ode\x03\0\x04\x02\x03\x02\x01\x1b\x04\0\x11ip-socket-address\x03\0\x06\x02\x03\x02\ -\x01\x1c\x04\0\x11ip-address-family\x03\0\x08\x01p}\x01r\x02\x04data\x0a\x0eremo\ -te-address\x07\x04\0\x11incoming-datagram\x03\0\x0b\x01k\x07\x01r\x02\x04data\x0a\ -\x0eremote-address\x0d\x04\0\x11outgoing-datagram\x03\0\x0e\x04\0\x0audp-socket\x03\ -\x01\x04\0\x18incoming-datagram-stream\x03\x01\x04\0\x18outgoing-datagram-stream\ -\x03\x01\x01h\x10\x01h\x03\x01j\0\x01\x05\x01@\x03\x04self\x13\x07network\x14\x0d\ -local-address\x07\0\x15\x04\0\x1d[method]udp-socket.start-bind\x01\x16\x01@\x01\x04\ -self\x13\0\x15\x04\0\x1e[method]udp-socket.finish-bind\x01\x17\x01i\x11\x01i\x12\ -\x01o\x02\x18\x19\x01j\x01\x1a\x01\x05\x01@\x02\x04self\x13\x0eremote-address\x0d\ -\0\x1b\x04\0\x19[method]udp-socket.stream\x01\x1c\x01j\x01\x07\x01\x05\x01@\x01\x04\ -self\x13\0\x1d\x04\0\x20[method]udp-socket.local-address\x01\x1e\x04\0![method]u\ -dp-socket.remote-address\x01\x1e\x01@\x01\x04self\x13\0\x09\x04\0![method]udp-so\ -cket.address-family\x01\x1f\x01j\x01}\x01\x05\x01@\x01\x04self\x13\0\x20\x04\0$[\ -method]udp-socket.unicast-hop-limit\x01!\x01@\x02\x04self\x13\x05value}\0\x15\x04\ -\0([method]udp-socket.set-unicast-hop-limit\x01\"\x01j\x01w\x01\x05\x01@\x01\x04\ -self\x13\0#\x04\0&[method]udp-socket.receive-buffer-size\x01$\x01@\x02\x04self\x13\ -\x05valuew\0\x15\x04\0*[method]udp-socket.set-receive-buffer-size\x01%\x04\0#[me\ -thod]udp-socket.send-buffer-size\x01$\x04\0'[method]udp-socket.set-send-buffer-s\ -ize\x01%\x01i\x01\x01@\x01\x04self\x13\0&\x04\0\x1c[method]udp-socket.subscribe\x01\ -'\x01h\x11\x01p\x0c\x01j\x01)\x01\x05\x01@\x02\x04self(\x0bmax-resultsw\0*\x04\0\ -([method]incoming-datagram-stream.receive\x01+\x01@\x01\x04self(\0&\x04\0*[metho\ -d]incoming-datagram-stream.subscribe\x01,\x01h\x12\x01@\x01\x04self-\0#\x04\0+[m\ -ethod]outgoing-datagram-stream.check-send\x01.\x01p\x0f\x01@\x02\x04self-\x09dat\ -agrams/\0#\x04\0%[method]outgoing-datagram-stream.send\x010\x01@\x01\x04self-\0&\ -\x04\0*[method]outgoing-datagram-stream.subscribe\x011\x04\x01\x16wasi:sockets/u\ -dp@0.2.0\x05\x1e\x01B\x1a\x01s\x04\0\x11inferencing-model\x03\0\0\x01r\x06\x0ama\ -x-tokensy\x0erepeat-penaltyv!repeat-penalty-last-n-token-county\x0btemperaturev\x05\ -top-ky\x05top-pv\x04\0\x12inferencing-params\x03\0\x02\x01q\x03\x13model-not-sup\ -ported\0\0\x0druntime-error\x01s\0\x0dinvalid-input\x01s\0\x04\0\x05error\x03\0\x04\ -\x01r\x02\x12prompt-token-county\x15generated-token-county\x04\0\x11inferencing-\ -usage\x03\0\x06\x01r\x02\x04texts\x05usage\x07\x04\0\x12inferencing-result\x03\0\ -\x08\x01s\x04\0\x0fembedding-model\x03\0\x0a\x01r\x01\x12prompt-token-county\x04\ -\0\x10embeddings-usage\x03\0\x0c\x01pv\x01p\x0e\x01r\x02\x0aembeddings\x0f\x05us\ -age\x0d\x04\0\x11embeddings-result\x03\0\x10\x01k\x03\x01j\x01\x09\x01\x05\x01@\x03\ -\x05model\x01\x06prompts\x06params\x12\0\x13\x04\0\x05infer\x01\x14\x01ps\x01j\x01\ -\x11\x01\x05\x01@\x02\x05model\x0b\x04text\x15\0\x16\x04\0\x13generate-embedding\ -s\x01\x17\x04\x01\x16fermyon:spin/llm@2.0.0\x05\x1f\x01B)\x01q\x04\x0finvalid-ad\ -dress\0\0\x14too-many-connections\0\0\x0atype-error\0\0\x05other\x01s\0\x04\0\x05\ -error\x03\0\0\x04\0\x0aconnection\x03\x01\x01p}\x04\0\x07payload\x03\0\x03\x01q\x02\ -\x05int64\x01x\0\x06binary\x01\x04\0\x04\0\x0fredis-parameter\x03\0\x05\x01q\x04\ -\x03nil\0\0\x06status\x01s\0\x05int64\x01x\0\x06binary\x01\x04\0\x04\0\x0credis-\ -result\x03\0\x07\x01i\x02\x01j\x01\x09\x01\x01\x01@\x01\x07addresss\0\x0a\x04\0\x17\ -[static]connection.open\x01\x0b\x01h\x02\x01j\0\x01\x01\x01@\x03\x04self\x0c\x07\ -channels\x07payload\x04\0\x0d\x04\0\x1a[method]connection.publish\x01\x0e\x01k\x04\ -\x01j\x01\x0f\x01\x01\x01@\x02\x04self\x0c\x03keys\0\x10\x04\0\x16[method]connec\ -tion.get\x01\x11\x01@\x03\x04self\x0c\x03keys\x05value\x04\0\x0d\x04\0\x16[metho\ -d]connection.set\x01\x12\x01j\x01x\x01\x01\x01@\x02\x04self\x0c\x03keys\0\x13\x04\ -\0\x17[method]connection.incr\x01\x14\x01ps\x01j\x01y\x01\x01\x01@\x02\x04self\x0c\ -\x04keys\x15\0\x16\x04\0\x16[method]connection.del\x01\x17\x01@\x03\x04self\x0c\x03\ -keys\x06values\x15\0\x16\x04\0\x17[method]connection.sadd\x01\x18\x01j\x01\x15\x01\ -\x01\x01@\x02\x04self\x0c\x03keys\0\x19\x04\0\x1b[method]connection.smembers\x01\ -\x1a\x04\0\x17[method]connection.srem\x01\x18\x01p\x06\x01p\x08\x01j\x01\x1c\x01\ -\x01\x01@\x03\x04self\x0c\x07commands\x09arguments\x1b\0\x1d\x04\0\x1a[method]co\ -nnection.execute\x01\x1e\x04\x01\x18fermyon:spin/redis@2.0.0\x05\x20\x01B\x0f\x01\ -q\x04\x0finvalid-address\0\0\x14too-many-connections\0\0\x11connection-failed\x01\ -s\0\x05other\x01s\0\x04\0\x05error\x03\0\0\x01m\x03\x0cat-most-once\x0dat-least-\ -once\x0cexactly-once\x04\0\x03qos\x03\0\x02\x04\0\x0aconnection\x03\x01\x01p}\x04\ -\0\x07payload\x03\0\x05\x01i\x04\x01j\x01\x07\x01\x01\x01@\x04\x07addresss\x08us\ -ernames\x08passwords\x1bkeep-alive-interval-in-secsw\0\x08\x04\0\x17[static]conn\ -ection.open\x01\x09\x01h\x04\x01j\0\x01\x01\x01@\x04\x04self\x0a\x05topics\x07pa\ -yload\x06\x03qos\x03\0\x0b\x04\0\x1a[method]connection.publish\x01\x0c\x04\x01\x17\ -fermyon:spin/mqtt@2.0.0\x05!\x01B\x11\x01q\x05\x11connection-failed\x01s\0\x0dba\ -d-parameter\x01s\0\x0cquery-failed\x01s\0\x17value-conversion-failed\x01s\0\x05o\ -ther\x01s\0\x04\0\x05error\x03\0\0\x01m\x0e\x07boolean\x04int8\x05int16\x05int32\ -\x05int64\x05uint8\x06uint16\x06uint32\x06uint64\x0afloating32\x0afloating64\x03\ -str\x06binary\x05other\x04\0\x0cdb-data-type\x03\0\x02\x01p}\x01q\x0f\x07boolean\ -\x01\x7f\0\x04int8\x01~\0\x05int16\x01|\0\x05int32\x01z\0\x05int64\x01x\0\x05uin\ -t8\x01}\0\x06uint16\x01{\0\x06uint32\x01y\0\x06uint64\x01w\0\x0afloating32\x01v\0\ -\x0afloating64\x01u\0\x03str\x01s\0\x06binary\x01\x04\0\x07db-null\0\0\x0bunsupp\ -orted\0\0\x04\0\x08db-value\x03\0\x05\x01q\x0e\x07boolean\x01\x7f\0\x04int8\x01~\ -\0\x05int16\x01|\0\x05int32\x01z\0\x05int64\x01x\0\x05uint8\x01}\0\x06uint16\x01\ -{\0\x06uint32\x01y\0\x06uint64\x01w\0\x0afloating32\x01v\0\x0afloating64\x01u\0\x03\ -str\x01s\0\x06binary\x01\x04\0\x07db-null\0\0\x04\0\x0fparameter-value\x03\0\x07\ -\x01r\x02\x04names\x09data-type\x03\x04\0\x06column\x03\0\x09\x01p\x06\x04\0\x03\ -row\x03\0\x0b\x01p\x0a\x01p\x0c\x01r\x02\x07columns\x0d\x04rows\x0e\x04\0\x07row\ --set\x03\0\x0f\x04\x01\x1efermyon:spin/rdbms-types@2.0.0\x05\"\x02\x03\0\x11\x0f\ -parameter-value\x02\x03\0\x11\x07row-set\x02\x03\0\x11\x05error\x01B\x13\x02\x03\ -\x02\x01#\x04\0\x0fparameter-value\x03\0\0\x02\x03\x02\x01$\x04\0\x07row-set\x03\ -\0\x02\x02\x03\x02\x01%\x04\0\x05error\x03\0\x04\x04\0\x0aconnection\x03\x01\x01\ -i\x06\x01j\x01\x07\x01\x05\x01@\x01\x07addresss\0\x08\x04\0\x17[static]connectio\ -n.open\x01\x09\x01h\x06\x01p\x01\x01j\x01\x03\x01\x05\x01@\x03\x04self\x0a\x09st\ -atements\x06params\x0b\0\x0c\x04\0\x18[method]connection.query\x01\x0d\x01j\x01w\ -\x01\x05\x01@\x03\x04self\x0a\x09statements\x06params\x0b\0\x0e\x04\0\x1a[method\ -]connection.execute\x01\x0f\x04\x01\x1bfermyon:spin/postgres@2.0.0\x05&\x01B\x13\ -\x02\x03\x02\x01#\x04\0\x0fparameter-value\x03\0\0\x02\x03\x02\x01$\x04\0\x07row\ --set\x03\0\x02\x02\x03\x02\x01%\x04\0\x05error\x03\0\x04\x04\0\x0aconnection\x03\ -\x01\x01i\x06\x01j\x01\x07\x01\x05\x01@\x01\x07addresss\0\x08\x04\0\x17[static]c\ -onnection.open\x01\x09\x01h\x06\x01p\x01\x01j\x01\x03\x01\x05\x01@\x03\x04self\x0a\ -\x09statements\x06params\x0b\0\x0c\x04\0\x18[method]connection.query\x01\x0d\x01\ -j\0\x01\x05\x01@\x03\x04self\x0a\x09statements\x06params\x0b\0\x0e\x04\0\x1a[met\ -hod]connection.execute\x01\x0f\x04\x01\x18fermyon:spin/mysql@2.0.0\x05'\x01B\x15\ -\x04\0\x0aconnection\x03\x01\x01q\x05\x10no-such-database\0\0\x0daccess-denied\0\ -\0\x12invalid-connection\0\0\x0ddatabase-full\0\0\x02io\x01s\0\x04\0\x05error\x03\ -\0\x01\x01p}\x01q\x05\x07integer\x01x\0\x04real\x01u\0\x04text\x01s\0\x04blob\x01\ -\x03\0\x04null\0\0\x04\0\x05value\x03\0\x04\x01p\x05\x01r\x01\x06values\x06\x04\0\ -\x0arow-result\x03\0\x07\x01ps\x01p\x08\x01r\x02\x07columns\x09\x04rows\x0a\x04\0\ -\x0cquery-result\x03\0\x0b\x01i\0\x01j\x01\x0d\x01\x02\x01@\x01\x08databases\0\x0e\ -\x04\0\x17[static]connection.open\x01\x0f\x01h\0\x01j\x01\x0c\x01\x02\x01@\x03\x04\ -self\x10\x09statements\x0aparameters\x06\0\x11\x04\0\x1a[method]connection.execu\ -te\x01\x12\x04\x01\x19fermyon:spin/sqlite@2.0.0\x05(\x01B\x19\x04\0\x05store\x03\ -\x01\x01q\x04\x10store-table-full\0\0\x0dno-such-store\0\0\x0daccess-denied\0\0\x05\ -other\x01s\0\x04\0\x05error\x03\0\x01\x01i\0\x01j\x01\x03\x01\x02\x01@\x01\x05la\ -bels\0\x04\x04\0\x12[static]store.open\x01\x05\x01h\0\x01p}\x01k\x07\x01j\x01\x08\ -\x01\x02\x01@\x02\x04self\x06\x03keys\0\x09\x04\0\x11[method]store.get\x01\x0a\x01\ -j\0\x01\x02\x01@\x03\x04self\x06\x03keys\x05value\x07\0\x0b\x04\0\x11[method]sto\ -re.set\x01\x0c\x01@\x02\x04self\x06\x03keys\0\x0b\x04\0\x14[method]store.delete\x01\ -\x0d\x01j\x01\x7f\x01\x02\x01@\x02\x04self\x06\x03keys\0\x0e\x04\0\x14[method]st\ -ore.exists\x01\x0f\x01ps\x01j\x01\x10\x01\x02\x01@\x01\x04self\x06\0\x11\x04\0\x16\ -[method]store.get-keys\x01\x12\x04\x01\x1cfermyon:spin/key-value@2.0.0\x05)\x01B\ -\x05\x01q\x04\x0cinvalid-name\x01s\0\x09undefined\x01s\0\x08provider\x01s\0\x05o\ -ther\x01s\0\x04\0\x05error\x03\0\0\x01j\x01s\x01\x01\x01@\x01\x04names\0\x02\x04\ -\0\x03get\x01\x03\x04\x01\x1cfermyon:spin/variables@2.0.0\x05*\x04\x01\x1afermyo\ +e\x01\x8c\x01\x03\0\x15wasi:http/types@0.2.0\x05\x0d\x01B\x11\x04\0\x07network\x03\ +\x01\x01m\x15\x07unknown\x0daccess-denied\x0dnot-supported\x10invalid-argument\x0d\ +out-of-memory\x07timeout\x14concurrency-conflict\x0fnot-in-progress\x0bwould-blo\ +ck\x0dinvalid-state\x10new-socket-limit\x14address-not-bindable\x0eaddress-in-us\ +e\x12remote-unreachable\x12connection-refused\x10connection-reset\x12connection-\ +aborted\x12datagram-too-large\x11name-unresolvable\x1atemporary-resolver-failure\ +\x1apermanent-resolver-failure\x04\0\x0aerror-code\x03\0\x01\x01m\x02\x04ipv4\x04\ +ipv6\x04\0\x11ip-address-family\x03\0\x03\x01o\x04}}}}\x04\0\x0cipv4-address\x03\ +\0\x05\x01o\x08{{{{{{{{\x04\0\x0cipv6-address\x03\0\x07\x01q\x02\x04ipv4\x01\x06\ +\0\x04ipv6\x01\x08\0\x04\0\x0aip-address\x03\0\x09\x01r\x02\x04port{\x07address\x06\ +\x04\0\x13ipv4-socket-address\x03\0\x0b\x01r\x04\x04port{\x09flow-infoy\x07addre\ +ss\x08\x08scope-idy\x04\0\x13ipv6-socket-address\x03\0\x0d\x01q\x02\x04ipv4\x01\x0c\ +\0\x04ipv6\x01\x0e\0\x04\0\x11ip-socket-address\x03\0\x0f\x03\0\x1awasi:sockets/\ +network@0.2.0\x05\x0e\x01B\x0a\x01o\x02ss\x01p\0\x01@\0\0\x01\x04\0\x0fget-envir\ +onment\x01\x02\x01ps\x01@\0\0\x03\x04\0\x0dget-arguments\x01\x04\x01ks\x01@\0\0\x05\ +\x04\0\x0binitial-cwd\x01\x06\x04\0\x1awasi:cli/environment@0.2.0\x05\x0f\x02\x03\ +\0\x04\x0adescriptor\x01B\x07\x02\x03\x02\x01\x10\x04\0\x0adescriptor\x03\0\0\x01\ +i\x01\x01o\x02\x02s\x01p\x03\x01@\0\0\x04\x04\0\x0fget-directories\x01\x05\x04\0\ +\x1ewasi:filesystem/preopens@0.2.0\x05\x11\x02\x03\0\x06\x10outgoing-request\x02\ +\x03\0\x06\x0frequest-options\x02\x03\0\x06\x18future-incoming-response\x02\x03\0\ +\x06\x0aerror-code\x01B\x0f\x02\x03\x02\x01\x12\x04\0\x10outgoing-request\x03\0\0\ +\x02\x03\x02\x01\x13\x04\0\x0frequest-options\x03\0\x02\x02\x03\x02\x01\x14\x04\0\ +\x18future-incoming-response\x03\0\x04\x02\x03\x02\x01\x15\x04\0\x0aerror-code\x03\ +\0\x06\x01i\x01\x01i\x03\x01k\x09\x01i\x05\x01j\x01\x0b\x01\x07\x01@\x02\x07requ\ +est\x08\x07options\x0a\0\x0c\x04\0\x06handle\x01\x0d\x04\0\x20wasi:http/outgoing\ +-handler@0.2.0\x05\x16\x02\x03\0\x07\x07network\x02\x03\0\x07\x0aerror-code\x02\x03\ +\0\x07\x0aip-address\x01B\x16\x02\x03\x02\x01\x03\x04\0\x08pollable\x03\0\0\x02\x03\ +\x02\x01\x17\x04\0\x07network\x03\0\x02\x02\x03\x02\x01\x18\x04\0\x0aerror-code\x03\ +\0\x04\x02\x03\x02\x01\x19\x04\0\x0aip-address\x03\0\x06\x04\0\x16resolve-addres\ +s-stream\x03\x01\x01h\x08\x01k\x07\x01j\x01\x0a\x01\x05\x01@\x01\x04self\x09\0\x0b\ +\x04\03[method]resolve-address-stream.resolve-next-address\x01\x0c\x01i\x01\x01@\ +\x01\x04self\x09\0\x0d\x04\0([method]resolve-address-stream.subscribe\x01\x0e\x01\ +h\x03\x01i\x08\x01j\x01\x10\x01\x05\x01@\x02\x07network\x0f\x04names\0\x11\x04\0\ +\x11resolve-addresses\x01\x12\x04\0!wasi:sockets/ip-name-lookup@0.2.0\x05\x1a\x02\ +\x03\0\x07\x11ip-socket-address\x02\x03\0\x07\x11ip-address-family\x01BT\x02\x03\ +\x02\x01\x06\x04\0\x0cinput-stream\x03\0\0\x02\x03\x02\x01\x07\x04\0\x0doutput-s\ +tream\x03\0\x02\x02\x03\x02\x01\x03\x04\0\x08pollable\x03\0\x04\x02\x03\x02\x01\x0c\ +\x04\0\x08duration\x03\0\x06\x02\x03\x02\x01\x17\x04\0\x07network\x03\0\x08\x02\x03\ +\x02\x01\x18\x04\0\x0aerror-code\x03\0\x0a\x02\x03\x02\x01\x1b\x04\0\x11ip-socke\ +t-address\x03\0\x0c\x02\x03\x02\x01\x1c\x04\0\x11ip-address-family\x03\0\x0e\x01\ +m\x03\x07receive\x04send\x04both\x04\0\x0dshutdown-type\x03\0\x10\x04\0\x0atcp-s\ +ocket\x03\x01\x01h\x12\x01h\x09\x01j\0\x01\x0b\x01@\x03\x04self\x13\x07network\x14\ +\x0dlocal-address\x0d\0\x15\x04\0\x1d[method]tcp-socket.start-bind\x01\x16\x01@\x01\ +\x04self\x13\0\x15\x04\0\x1e[method]tcp-socket.finish-bind\x01\x17\x01@\x03\x04s\ +elf\x13\x07network\x14\x0eremote-address\x0d\0\x15\x04\0\x20[method]tcp-socket.s\ +tart-connect\x01\x18\x01i\x01\x01i\x03\x01o\x02\x19\x1a\x01j\x01\x1b\x01\x0b\x01\ +@\x01\x04self\x13\0\x1c\x04\0![method]tcp-socket.finish-connect\x01\x1d\x04\0\x1f\ +[method]tcp-socket.start-listen\x01\x17\x04\0\x20[method]tcp-socket.finish-liste\ +n\x01\x17\x01i\x12\x01o\x03\x1e\x19\x1a\x01j\x01\x1f\x01\x0b\x01@\x01\x04self\x13\ +\0\x20\x04\0\x19[method]tcp-socket.accept\x01!\x01j\x01\x0d\x01\x0b\x01@\x01\x04\ +self\x13\0\"\x04\0\x20[method]tcp-socket.local-address\x01#\x04\0![method]tcp-so\ +cket.remote-address\x01#\x01@\x01\x04self\x13\0\x7f\x04\0\x1f[method]tcp-socket.\ +is-listening\x01$\x01@\x01\x04self\x13\0\x0f\x04\0![method]tcp-socket.address-fa\ +mily\x01%\x01@\x02\x04self\x13\x05valuew\0\x15\x04\0*[method]tcp-socket.set-list\ +en-backlog-size\x01&\x01j\x01\x7f\x01\x0b\x01@\x01\x04self\x13\0'\x04\0%[method]\ +tcp-socket.keep-alive-enabled\x01(\x01@\x02\x04self\x13\x05value\x7f\0\x15\x04\0\ +)[method]tcp-socket.set-keep-alive-enabled\x01)\x01j\x01\x07\x01\x0b\x01@\x01\x04\ +self\x13\0*\x04\0'[method]tcp-socket.keep-alive-idle-time\x01+\x01@\x02\x04self\x13\ +\x05value\x07\0\x15\x04\0+[method]tcp-socket.set-keep-alive-idle-time\x01,\x04\0\ +&[method]tcp-socket.keep-alive-interval\x01+\x04\0*[method]tcp-socket.set-keep-a\ +live-interval\x01,\x01j\x01y\x01\x0b\x01@\x01\x04self\x13\0-\x04\0#[method]tcp-s\ +ocket.keep-alive-count\x01.\x01@\x02\x04self\x13\x05valuey\0\x15\x04\0'[method]t\ +cp-socket.set-keep-alive-count\x01/\x01j\x01}\x01\x0b\x01@\x01\x04self\x13\00\x04\ +\0\x1c[method]tcp-socket.hop-limit\x011\x01@\x02\x04self\x13\x05value}\0\x15\x04\ +\0\x20[method]tcp-socket.set-hop-limit\x012\x01j\x01w\x01\x0b\x01@\x01\x04self\x13\ +\03\x04\0&[method]tcp-socket.receive-buffer-size\x014\x04\0*[method]tcp-socket.s\ +et-receive-buffer-size\x01&\x04\0#[method]tcp-socket.send-buffer-size\x014\x04\0\ +'[method]tcp-socket.set-send-buffer-size\x01&\x01i\x05\x01@\x01\x04self\x13\05\x04\ +\0\x1c[method]tcp-socket.subscribe\x016\x01@\x02\x04self\x13\x0dshutdown-type\x11\ +\0\x15\x04\0\x1b[method]tcp-socket.shutdown\x017\x04\0\x16wasi:sockets/tcp@0.2.0\ +\x05\x1d\x02\x03\0\x0c\x0atcp-socket\x01B\x0c\x02\x03\x02\x01\x17\x04\0\x07netwo\ +rk\x03\0\0\x02\x03\x02\x01\x18\x04\0\x0aerror-code\x03\0\x02\x02\x03\x02\x01\x1c\ +\x04\0\x11ip-address-family\x03\0\x04\x02\x03\x02\x01\x1e\x04\0\x0atcp-socket\x03\ +\0\x06\x01i\x07\x01j\x01\x08\x01\x03\x01@\x01\x0eaddress-family\x05\0\x09\x04\0\x11\ +create-tcp-socket\x01\x0a\x04\0$wasi:sockets/tcp-create-socket@0.2.0\x05\x1f\x01\ +BD\x02\x03\x02\x01\x03\x04\0\x08pollable\x03\0\0\x02\x03\x02\x01\x17\x04\0\x07ne\ +twork\x03\0\x02\x02\x03\x02\x01\x18\x04\0\x0aerror-code\x03\0\x04\x02\x03\x02\x01\ +\x1b\x04\0\x11ip-socket-address\x03\0\x06\x02\x03\x02\x01\x1c\x04\0\x11ip-addres\ +s-family\x03\0\x08\x01p}\x01r\x02\x04data\x0a\x0eremote-address\x07\x04\0\x11inc\ +oming-datagram\x03\0\x0b\x01k\x07\x01r\x02\x04data\x0a\x0eremote-address\x0d\x04\ +\0\x11outgoing-datagram\x03\0\x0e\x04\0\x0audp-socket\x03\x01\x04\0\x18incoming-\ +datagram-stream\x03\x01\x04\0\x18outgoing-datagram-stream\x03\x01\x01h\x10\x01h\x03\ +\x01j\0\x01\x05\x01@\x03\x04self\x13\x07network\x14\x0dlocal-address\x07\0\x15\x04\ +\0\x1d[method]udp-socket.start-bind\x01\x16\x01@\x01\x04self\x13\0\x15\x04\0\x1e\ +[method]udp-socket.finish-bind\x01\x17\x01i\x11\x01i\x12\x01o\x02\x18\x19\x01j\x01\ +\x1a\x01\x05\x01@\x02\x04self\x13\x0eremote-address\x0d\0\x1b\x04\0\x19[method]u\ +dp-socket.stream\x01\x1c\x01j\x01\x07\x01\x05\x01@\x01\x04self\x13\0\x1d\x04\0\x20\ +[method]udp-socket.local-address\x01\x1e\x04\0![method]udp-socket.remote-address\ +\x01\x1e\x01@\x01\x04self\x13\0\x09\x04\0![method]udp-socket.address-family\x01\x1f\ +\x01j\x01}\x01\x05\x01@\x01\x04self\x13\0\x20\x04\0$[method]udp-socket.unicast-h\ +op-limit\x01!\x01@\x02\x04self\x13\x05value}\0\x15\x04\0([method]udp-socket.set-\ +unicast-hop-limit\x01\"\x01j\x01w\x01\x05\x01@\x01\x04self\x13\0#\x04\0&[method]\ +udp-socket.receive-buffer-size\x01$\x01@\x02\x04self\x13\x05valuew\0\x15\x04\0*[\ +method]udp-socket.set-receive-buffer-size\x01%\x04\0#[method]udp-socket.send-buf\ +fer-size\x01$\x04\0'[method]udp-socket.set-send-buffer-size\x01%\x01i\x01\x01@\x01\ +\x04self\x13\0&\x04\0\x1c[method]udp-socket.subscribe\x01'\x01h\x11\x01p\x0c\x01\ +j\x01)\x01\x05\x01@\x02\x04self(\x0bmax-resultsw\0*\x04\0([method]incoming-datag\ +ram-stream.receive\x01+\x01@\x01\x04self(\0&\x04\0*[method]incoming-datagram-str\ +eam.subscribe\x01,\x01h\x12\x01@\x01\x04self-\0#\x04\0+[method]outgoing-datagram\ +-stream.check-send\x01.\x01p\x0f\x01@\x02\x04self-\x09datagrams/\0#\x04\0%[metho\ +d]outgoing-datagram-stream.send\x010\x01@\x01\x04self-\0&\x04\0*[method]outgoing\ +-datagram-stream.subscribe\x011\x04\0\x16wasi:sockets/udp@0.2.0\x05\x20\x02\x03\0\ +\x0e\x0audp-socket\x01B\x0c\x02\x03\x02\x01\x17\x04\0\x07network\x03\0\0\x02\x03\ +\x02\x01\x18\x04\0\x0aerror-code\x03\0\x02\x02\x03\x02\x01\x1c\x04\0\x11ip-addre\ +ss-family\x03\0\x04\x02\x03\x02\x01!\x04\0\x0audp-socket\x03\0\x06\x01i\x07\x01j\ +\x01\x08\x01\x03\x01@\x01\x0eaddress-family\x05\0\x09\x04\0\x11create-udp-socket\ +\x01\x0a\x04\0$wasi:sockets/udp-create-socket@0.2.0\x05\"\x01B\x1a\x01s\x04\0\x11\ +inferencing-model\x03\0\0\x01r\x06\x0amax-tokensy\x0erepeat-penaltyv!repeat-pena\ +lty-last-n-token-county\x0btemperaturev\x05top-ky\x05top-pv\x04\0\x12inferencing\ +-params\x03\0\x02\x01q\x03\x13model-not-supported\0\0\x0druntime-error\x01s\0\x0d\ +invalid-input\x01s\0\x04\0\x05error\x03\0\x04\x01r\x02\x12prompt-token-county\x15\ +generated-token-county\x04\0\x11inferencing-usage\x03\0\x06\x01r\x02\x04texts\x05\ +usage\x07\x04\0\x12inferencing-result\x03\0\x08\x01s\x04\0\x0fembedding-model\x03\ +\0\x0a\x01r\x01\x12prompt-token-county\x04\0\x10embeddings-usage\x03\0\x0c\x01pv\ +\x01p\x0e\x01r\x02\x0aembeddings\x0f\x05usage\x0d\x04\0\x11embeddings-result\x03\ +\0\x10\x01k\x03\x01j\x01\x09\x01\x05\x01@\x03\x05model\x01\x06prompts\x06params\x12\ +\0\x13\x04\0\x05infer\x01\x14\x01ps\x01j\x01\x11\x01\x05\x01@\x02\x05model\x0b\x04\ +text\x15\0\x16\x04\0\x13generate-embeddings\x01\x17\x04\0\x16fermyon:spin/llm@2.\ +0.0\x05#\x01B)\x01q\x04\x0finvalid-address\0\0\x14too-many-connections\0\0\x0aty\ +pe-error\0\0\x05other\x01s\0\x04\0\x05error\x03\0\0\x04\0\x0aconnection\x03\x01\x01\ +p}\x04\0\x07payload\x03\0\x03\x01q\x02\x05int64\x01x\0\x06binary\x01\x04\0\x04\0\ +\x0fredis-parameter\x03\0\x05\x01q\x04\x03nil\0\0\x06status\x01s\0\x05int64\x01x\ +\0\x06binary\x01\x04\0\x04\0\x0credis-result\x03\0\x07\x01i\x02\x01j\x01\x09\x01\ +\x01\x01@\x01\x07addresss\0\x0a\x04\0\x17[static]connection.open\x01\x0b\x01h\x02\ +\x01j\0\x01\x01\x01@\x03\x04self\x0c\x07channels\x07payload\x04\0\x0d\x04\0\x1a[\ +method]connection.publish\x01\x0e\x01k\x04\x01j\x01\x0f\x01\x01\x01@\x02\x04self\ +\x0c\x03keys\0\x10\x04\0\x16[method]connection.get\x01\x11\x01@\x03\x04self\x0c\x03\ +keys\x05value\x04\0\x0d\x04\0\x16[method]connection.set\x01\x12\x01j\x01x\x01\x01\ +\x01@\x02\x04self\x0c\x03keys\0\x13\x04\0\x17[method]connection.incr\x01\x14\x01\ +ps\x01j\x01y\x01\x01\x01@\x02\x04self\x0c\x04keys\x15\0\x16\x04\0\x16[method]con\ +nection.del\x01\x17\x01@\x03\x04self\x0c\x03keys\x06values\x15\0\x16\x04\0\x17[m\ +ethod]connection.sadd\x01\x18\x01j\x01\x15\x01\x01\x01@\x02\x04self\x0c\x03keys\0\ +\x19\x04\0\x1b[method]connection.smembers\x01\x1a\x04\0\x17[method]connection.sr\ +em\x01\x18\x01p\x06\x01p\x08\x01j\x01\x1c\x01\x01\x01@\x03\x04self\x0c\x07comman\ +ds\x09arguments\x1b\0\x1d\x04\0\x1a[method]connection.execute\x01\x1e\x04\0\x18f\ +ermyon:spin/redis@2.0.0\x05$\x01B\x0f\x01q\x04\x0finvalid-address\0\0\x14too-man\ +y-connections\0\0\x11connection-failed\x01s\0\x05other\x01s\0\x04\0\x05error\x03\ +\0\0\x01m\x03\x0cat-most-once\x0dat-least-once\x0cexactly-once\x04\0\x03qos\x03\0\ +\x02\x04\0\x0aconnection\x03\x01\x01p}\x04\0\x07payload\x03\0\x05\x01i\x04\x01j\x01\ +\x07\x01\x01\x01@\x04\x07addresss\x08usernames\x08passwords\x1bkeep-alive-interv\ +al-in-secsw\0\x08\x04\0\x17[static]connection.open\x01\x09\x01h\x04\x01j\0\x01\x01\ +\x01@\x04\x04self\x0a\x05topics\x07payload\x06\x03qos\x03\0\x0b\x04\0\x1a[method\ +]connection.publish\x01\x0c\x04\0\x17fermyon:spin/mqtt@2.0.0\x05%\x01B\x11\x01q\x05\ +\x11connection-failed\x01s\0\x0dbad-parameter\x01s\0\x0cquery-failed\x01s\0\x17v\ +alue-conversion-failed\x01s\0\x05other\x01s\0\x04\0\x05error\x03\0\0\x01m\x0e\x07\ +boolean\x04int8\x05int16\x05int32\x05int64\x05uint8\x06uint16\x06uint32\x06uint6\ +4\x0afloating32\x0afloating64\x03str\x06binary\x05other\x04\0\x0cdb-data-type\x03\ +\0\x02\x01p}\x01q\x0f\x07boolean\x01\x7f\0\x04int8\x01~\0\x05int16\x01|\0\x05int\ +32\x01z\0\x05int64\x01x\0\x05uint8\x01}\0\x06uint16\x01{\0\x06uint32\x01y\0\x06u\ +int64\x01w\0\x0afloating32\x01v\0\x0afloating64\x01u\0\x03str\x01s\0\x06binary\x01\ +\x04\0\x07db-null\0\0\x0bunsupported\0\0\x04\0\x08db-value\x03\0\x05\x01q\x0e\x07\ +boolean\x01\x7f\0\x04int8\x01~\0\x05int16\x01|\0\x05int32\x01z\0\x05int64\x01x\0\ +\x05uint8\x01}\0\x06uint16\x01{\0\x06uint32\x01y\0\x06uint64\x01w\0\x0afloating3\ +2\x01v\0\x0afloating64\x01u\0\x03str\x01s\0\x06binary\x01\x04\0\x07db-null\0\0\x04\ +\0\x0fparameter-value\x03\0\x07\x01r\x02\x04names\x09data-type\x03\x04\0\x06colu\ +mn\x03\0\x09\x01p\x06\x04\0\x03row\x03\0\x0b\x01p\x0a\x01p\x0c\x01r\x02\x07colum\ +ns\x0d\x04rows\x0e\x04\0\x07row-set\x03\0\x0f\x04\0\x1efermyon:spin/rdbms-types@\ +2.0.0\x05&\x02\x03\0\x13\x0fparameter-value\x02\x03\0\x13\x07row-set\x02\x03\0\x13\ +\x05error\x01B\x13\x02\x03\x02\x01'\x04\0\x0fparameter-value\x03\0\0\x02\x03\x02\ +\x01(\x04\0\x07row-set\x03\0\x02\x02\x03\x02\x01)\x04\0\x05error\x03\0\x04\x04\0\ +\x0aconnection\x03\x01\x01i\x06\x01j\x01\x07\x01\x05\x01@\x01\x07addresss\0\x08\x04\ +\0\x17[static]connection.open\x01\x09\x01h\x06\x01p\x01\x01j\x01\x03\x01\x05\x01\ +@\x03\x04self\x0a\x09statements\x06params\x0b\0\x0c\x04\0\x18[method]connection.\ +query\x01\x0d\x01j\x01w\x01\x05\x01@\x03\x04self\x0a\x09statements\x06params\x0b\ +\0\x0e\x04\0\x1a[method]connection.execute\x01\x0f\x04\0\x1bfermyon:spin/postgre\ +s@2.0.0\x05*\x01B\x13\x02\x03\x02\x01'\x04\0\x0fparameter-value\x03\0\0\x02\x03\x02\ +\x01(\x04\0\x07row-set\x03\0\x02\x02\x03\x02\x01)\x04\0\x05error\x03\0\x04\x04\0\ +\x0aconnection\x03\x01\x01i\x06\x01j\x01\x07\x01\x05\x01@\x01\x07addresss\0\x08\x04\ +\0\x17[static]connection.open\x01\x09\x01h\x06\x01p\x01\x01j\x01\x03\x01\x05\x01\ +@\x03\x04self\x0a\x09statements\x06params\x0b\0\x0c\x04\0\x18[method]connection.\ +query\x01\x0d\x01j\0\x01\x05\x01@\x03\x04self\x0a\x09statements\x06params\x0b\0\x0e\ +\x04\0\x1a[method]connection.execute\x01\x0f\x04\0\x18fermyon:spin/mysql@2.0.0\x05\ ++\x01B\x15\x04\0\x0aconnection\x03\x01\x01q\x05\x10no-such-database\0\0\x0dacces\ +s-denied\0\0\x12invalid-connection\0\0\x0ddatabase-full\0\0\x02io\x01s\0\x04\0\x05\ +error\x03\0\x01\x01p}\x01q\x05\x07integer\x01x\0\x04real\x01u\0\x04text\x01s\0\x04\ +blob\x01\x03\0\x04null\0\0\x04\0\x05value\x03\0\x04\x01p\x05\x01r\x01\x06values\x06\ +\x04\0\x0arow-result\x03\0\x07\x01ps\x01p\x08\x01r\x02\x07columns\x09\x04rows\x0a\ +\x04\0\x0cquery-result\x03\0\x0b\x01i\0\x01j\x01\x0d\x01\x02\x01@\x01\x08databas\ +es\0\x0e\x04\0\x17[static]connection.open\x01\x0f\x01h\0\x01j\x01\x0c\x01\x02\x01\ +@\x03\x04self\x10\x09statements\x0aparameters\x06\0\x11\x04\0\x1a[method]connect\ +ion.execute\x01\x12\x04\0\x19fermyon:spin/sqlite@2.0.0\x05,\x01B\x19\x04\0\x05st\ +ore\x03\x01\x01q\x04\x10store-table-full\0\0\x0dno-such-store\0\0\x0daccess-deni\ +ed\0\0\x05other\x01s\0\x04\0\x05error\x03\0\x01\x01i\0\x01j\x01\x03\x01\x02\x01@\ +\x01\x05labels\0\x04\x04\0\x12[static]store.open\x01\x05\x01h\0\x01p}\x01k\x07\x01\ +j\x01\x08\x01\x02\x01@\x02\x04self\x06\x03keys\0\x09\x04\0\x11[method]store.get\x01\ +\x0a\x01j\0\x01\x02\x01@\x03\x04self\x06\x03keys\x05value\x07\0\x0b\x04\0\x11[me\ +thod]store.set\x01\x0c\x01@\x02\x04self\x06\x03keys\0\x0b\x04\0\x14[method]store\ +.delete\x01\x0d\x01j\x01\x7f\x01\x02\x01@\x02\x04self\x06\x03keys\0\x0e\x04\0\x14\ +[method]store.exists\x01\x0f\x01ps\x01j\x01\x10\x01\x02\x01@\x01\x04self\x06\0\x11\ +\x04\0\x16[method]store.get-keys\x01\x12\x04\0\x1cfermyon:spin/key-value@2.0.0\x05\ +-\x01B\x05\x01q\x04\x0cinvalid-name\x01s\0\x09undefined\x01s\0\x08provider\x01s\0\ +\x05other\x01s\0\x04\0\x05error\x03\0\0\x01j\x01s\x01\x01\x01@\x01\x04names\0\x02\ +\x04\0\x03get\x01\x03\x04\0\x1cfermyon:spin/variables@2.0.0\x05.\x04\0\x1afermyo\ n:spin-virt/deny-all\x04\0\x0b\x0e\x01\0\x08deny-all\x03\0\0\0G\x09producers\x01\ -\x0cprocessed-by\x02\x0dwit-component\x070.208.1\x10wit-bindgen-rust\x060.25.0"; - +\x0cprocessed-by\x02\x0dwit-component\x070.220.0\x10wit-bindgen-rust\x060.35.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/crates/compose/deny-all/src/wasi.rs b/crates/compose/deny-all/src/wasi.rs index 7bbc9480e1..f913492a82 100644 --- a/crates/compose/deny-all/src/wasi.rs +++ b/crates/compose/deny-all/src/wasi.rs @@ -1,8 +1,11 @@ -use crate::bindings::exports::wasi::{ - cli0_2_0 as cli, - filesystem0_2_0 as filesystem, - http0_2_0 as http, - sockets0_2_0 as sockets, +use crate::bindings::{ + exports::wasi::{ + cli0_2_0 as cli, + filesystem0_2_0 as filesystem, + http0_2_0 as http, + sockets0_2_0 as sockets, + }, + wasi::sockets0_2_0::network, }; use crate::format_deny_error; @@ -228,6 +231,22 @@ impl sockets::tcp::Guest for crate::Component { type TcpSocket = TcpSocket; } +impl sockets::tcp_create_socket::Guest for crate::Component { + fn create_tcp_socket( + address_family: network::IpAddressFamily, + ) -> Result { + Err(network::ErrorCode::AccessDenied) + } +} + +impl sockets::udp_create_socket::Guest for crate::Component { + fn create_udp_socket( + address_family: network::IpAddressFamily, + ) -> Result { + Err(network::ErrorCode::AccessDenied) + } +} + pub struct UdpSocket; impl sockets::udp::GuestUdpSocket for UdpSocket { diff --git a/crates/compose/deny-all/wit/world.wit b/crates/compose/deny-all/wit/world.wit index d212359fdc..480bcc10f0 100644 --- a/crates/compose/deny-all/wit/world.wit +++ b/crates/compose/deny-all/wit/world.wit @@ -5,7 +5,9 @@ world deny-all { export wasi:filesystem/preopens@0.2.0; export wasi:http/outgoing-handler@0.2.0; export wasi:sockets/ip-name-lookup@0.2.0; + export wasi:sockets/tcp-create-socket@0.2.0; export wasi:sockets/tcp@0.2.0; + export wasi:sockets/udp-create-socket@0.2.0; export wasi:sockets/udp@0.2.0; export fermyon:spin/llm@2.0.0; diff --git a/crates/compose/deny_all.wasm b/crates/compose/deny_all.wasm index e5a7eadfcd..55c05c4457 100644 Binary files a/crates/compose/deny_all.wasm and b/crates/compose/deny_all.wasm differ