// Generated by `wit-bindgen` 0.39.0. DO NOT EDIT! // Options used: // * std_feature // * runtime_path: "wit_bindgen_rt" // * type_section_suffix: "rust-wasi-from-crates-io" #[rustfmt::skip] #[allow(dead_code, clippy::all)] pubmod wasi { pubmod cli { #[allow(dead_code, unused_imports, clippy::all)] pubmod environment { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; usesuper::super::super::_rt; #[allow(unused_unsafe, clippy::all)] /// Get the POSIX-style environment variables. /// /// Each environment variable is provided as a pair of string variable names /// and string value. /// /// Morally, these are a value import, but until value imports are available /// in the component model, this import function should return the same /// values each time it is called. pub fn get_environment() -> _rt::Vec<(_rt::String, _rt::String)> { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit<u8>; 8]); letmut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:cli/environment@0.2.4")] extern"C" { #[link_name = "get-environment"]
fn wit_import1(_: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: *mut u8) {
unreachable!()
}
wit_import1(ptr0); let l2 = *ptr0.add(0).cast::<*mut u8>(); let l3 = *ptr0.add(4).cast::<usize>(); let base10 = l2; let len10 = l3; letmut result10 = _rt::Vec::with_capacity(len10);
for i in 0..len10 { let base = base10.add(i * 16); let e10 = { let l4 = *base.add(0).cast::<*mut u8>(); let l5 = *base.add(4).cast::<usize>(); let len6 = l5; let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6); let l7 = *base.add(8).cast::<*mut u8>(); let l8 = *base.add(12).cast::<usize>(); let len9 = l8; let bytes9 = _rt::Vec::from_raw_parts(l7.cast(), len9, len9);
(_rt::string_lift(bytes6), _rt::string_lift(bytes9))
};
result10.push(e10);
}
_rt::cabi_dealloc(base10, len10 * 16, 4); let result11 = result10;
result11
}
} #[allow(unused_unsafe, clippy::all)] /// Get the POSIX-style arguments to the program. pub fn get_arguments() -> _rt::Vec<_rt::String> { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit<u8>; 8]); letmut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:cli/environment@0.2.4")] extern"C" { #[link_name = "get-arguments"]
fn wit_import1(_: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: *mut u8) {
unreachable!()
}
wit_import1(ptr0); let l2 = *ptr0.add(0).cast::<*mut u8>(); let l3 = *ptr0.add(4).cast::<usize>(); let base7 = l2; let len7 = l3; letmut result7 = _rt::Vec::with_capacity(len7);
for i in 0..len7 { let base = base7.add(i * 8); let e7 = { let l4 = *base.add(0).cast::<*mut u8>(); let l5 = *base.add(4).cast::<usize>(); let len6 = l5; let bytes6 = _rt::Vec::from_raw_parts(l4.cast(), len6, len6);
_rt::string_lift(bytes6)
};
result7.push(e7);
}
_rt::cabi_dealloc(base7, len7 * 8, 4); let result8 = result7;
result8
}
} #[allow(unused_unsafe, clippy::all)] /// Return a path that programs should use as their initial current working /// directory, interpreting `.` as shorthand for this. pub fn initial_cwd() -> Option<_rt::String> { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit<u8>; 12]); letmut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 12]); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:cli/environment@0.2.4")] extern"C" { #[link_name = "initial-cwd"]
fn wit_import1(_: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: *mut u8) {
unreachable!()
}
wit_import1(ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result6 = match l2 { 0 => None, 1 => { let e = { let l3 = *ptr0.add(4).cast::<*mut u8>(); let l4 = *ptr0.add(8).cast::<usize>(); let len5 = l4; let bytes5 = _rt::Vec::from_raw_parts(
l3.cast(),
len5,
len5,
);
_rt::string_lift(bytes5)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result6
}
}
} #[allow(dead_code, unused_imports, clippy::all)] pubmod exit { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; #[allow(unused_unsafe, clippy::all)] /// Exit the current instance and any linked instances. pub fn exit(status: Result<(), ()>) -> () { unsafe { let result0 = match status {
Ok(_) => 0i32,
Err(_) => 1i32,
}; #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:cli/exit@0.2.4")] extern"C" { #[link_name = "exit"]
fn wit_import1(_: i32);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32) {
unreachable!()
}
wit_import1(result0);
}
}
} #[allow(dead_code, unused_imports, clippy::all)] pubmod stdin { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; pubtype InputStream = super::super::super::wasi::io::streams::InputStream; #[allow(unused_unsafe, clippy::all)] pub fn get_stdin() -> InputStream { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:cli/stdin@0.2.4")] extern"C" { #[link_name = "get-stdin"]
fn wit_import0() -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0() -> i32 {
unreachable!()
} let ret = wit_import0(); super::super::super::wasi::io::streams::InputStream::from_handle(
ret as u32,
)
}
}
} #[allow(dead_code, unused_imports, clippy::all)] pubmod stdout { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; pubtype OutputStream = super::super::super::wasi::io::streams::OutputStream; #[allow(unused_unsafe, clippy::all)] pub fn get_stdout() -> OutputStream { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:cli/stdout@0.2.4")] extern"C" { #[link_name = "get-stdout"]
fn wit_import0() -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0() -> i32 {
unreachable!()
} let ret = wit_import0(); super::super::super::wasi::io::streams::OutputStream::from_handle(
ret as u32,
)
}
}
} #[allow(dead_code, unused_imports, clippy::all)] pubmod stderr { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; pubtype OutputStream = super::super::super::wasi::io::streams::OutputStream; #[allow(unused_unsafe, clippy::all)] pub fn get_stderr() -> OutputStream { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:cli/stderr@0.2.4")] extern"C" { #[link_name = "get-stderr"]
fn wit_import0() -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0() -> i32 {
unreachable!()
} let ret = wit_import0(); super::super::super::wasi::io::streams::OutputStream::from_handle(
ret as u32,
)
}
}
} /// Terminal input. /// /// In the future, this may include functions for disabling echoing, /// disabling input buffering so that keyboard events are sent through /// immediately, querying supported features, and so on. #[allow(dead_code, unused_imports, clippy::all)] pubmod terminal_input { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; usesuper::super::super::_rt; /// The input side of a terminal. #[derive(Debug)] #[repr(transparent)] pubstruct TerminalInput {
handle: _rt::Resource<TerminalInput>,
} impl TerminalInput { #[doc(hidden)] pubunsafe 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)
}
} unsafeimpl _rt::WasmResource for TerminalInput { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))]
unreachable!(); #[cfg(target_arch = "wasm32")]
{ #[link(wasm_import_module = "wasi:cli/terminal-input@0.2.4")] extern"C" { #[link_name = "[resource-drop]terminal-input"]
fn drop(_: u32);
}
drop(_handle);
}
}
}
} /// Terminal output. /// /// In the future, this may include functions for querying the terminal /// size, being notified of terminal size changes, querying supported /// features, and so on. #[allow(dead_code, unused_imports, clippy::all)] pubmod terminal_output { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; usesuper::super::super::_rt; /// The output side of a terminal. #[derive(Debug)] #[repr(transparent)] pubstruct TerminalOutput {
handle: _rt::Resource<TerminalOutput>,
} impl TerminalOutput { #[doc(hidden)] pubunsafe 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)
}
} unsafeimpl _rt::WasmResource for TerminalOutput { #[inline] unsafe fn drop(_handle: u32) { #[cfg(not(target_arch = "wasm32"))]
unreachable!(); #[cfg(target_arch = "wasm32")]
{ #[link(wasm_import_module = "wasi:cli/terminal-output@0.2.4")] extern"C" { #[link_name = "[resource-drop]terminal-output"]
fn drop(_: u32);
}
drop(_handle);
}
}
}
} /// An interface providing an optional `terminal-input` for stdin as a /// link-time authority. #[allow(dead_code, unused_imports, clippy::all)] pubmod terminal_stdin { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; usesuper::super::super::_rt; pubtype TerminalInput = super::super::super::wasi::cli::terminal_input::TerminalInput; #[allow(unused_unsafe, clippy::all)] /// If stdin is connected to a terminal, return a `terminal-input` handle /// allowing further interaction with it. pub fn get_terminal_stdin() -> Option<TerminalInput> { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit<u8>; 8]); letmut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:cli/terminal-stdin@0.2.4")] extern"C" { #[link_name = "get-terminal-stdin"]
fn wit_import1(_: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: *mut u8) {
unreachable!()
}
wit_import1(ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result4 = match l2 { 0 => None, 1 => { let e = { let l3 = *ptr0.add(4).cast::<i32>(); super::super::super::wasi::cli::terminal_input::TerminalInput::from_handle(
l3 as u32,
)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
} /// An interface providing an optional `terminal-output` for stdout as a /// link-time authority. #[allow(dead_code, unused_imports, clippy::all)] pubmod terminal_stdout { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; usesuper::super::super::_rt; pubtype TerminalOutput = super::super::super::wasi::cli::terminal_output::TerminalOutput; #[allow(unused_unsafe, clippy::all)] /// If stdout is connected to a terminal, return a `terminal-output` handle /// allowing further interaction with it. pub fn get_terminal_stdout() -> Option<TerminalOutput> { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit<u8>; 8]); letmut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:cli/terminal-stdout@0.2.4")] extern"C" { #[link_name = "get-terminal-stdout"]
fn wit_import1(_: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: *mut u8) {
unreachable!()
}
wit_import1(ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result4 = match l2 { 0 => None, 1 => { let e = { let l3 = *ptr0.add(4).cast::<i32>(); super::super::super::wasi::cli::terminal_output::TerminalOutput::from_handle(
l3 as u32,
)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
} /// An interface providing an optional `terminal-output` for stderr as a /// link-time authority. #[allow(dead_code, unused_imports, clippy::all)] pubmod terminal_stderr { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; usesuper::super::super::_rt; pubtype TerminalOutput = super::super::super::wasi::cli::terminal_output::TerminalOutput; #[allow(unused_unsafe, clippy::all)] /// If stderr is connected to a terminal, return a `terminal-output` handle /// allowing further interaction with it. pub fn get_terminal_stderr() -> Option<TerminalOutput> { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit<u8>; 8]); letmut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:cli/terminal-stderr@0.2.4")] extern"C" { #[link_name = "get-terminal-stderr"]
fn wit_import1(_: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: *mut u8) {
unreachable!()
}
wit_import1(ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result4 = match l2 { 0 => None, 1 => { let e = { let l3 = *ptr0.add(4).cast::<i32>(); super::super::super::wasi::cli::terminal_output::TerminalOutput::from_handle(
l3 as u32,
)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
}
} pubmod clocks { /// WASI Monotonic Clock is a clock API intended to let users measure elapsed /// time. /// /// It is intended to be portable at least between Unix-family platforms and /// Windows. /// /// A monotonic clock is a clock which has an unspecified initial value, and /// successive reads of the clock will produce non-decreasing values. #[allow(dead_code, unused_imports, clippy::all)] pubmod monotonic_clock { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; usesuper::super::super::_rt; pubtype Pollable = super::super::super::wasi::io::poll::Pollable; /// An instant in time, in nanoseconds. An instant is relative to an /// unspecified initial value, and can only be compared to instances from /// the same monotonic-clock. pubtype Instant = u64; /// A duration of time, in nanoseconds. pubtype Duration = u64; #[allow(unused_unsafe, clippy::all)] /// Read the current value of the clock. /// /// The clock is monotonic, therefore calling this function repeatedly will /// produce a sequence of non-decreasing values. pub fn now() -> Instant { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.4")] extern"C" { #[link_name = "now"]
fn wit_import0() -> i64;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0() -> i64 {
unreachable!()
} let ret = wit_import0();
ret as u64
}
} #[allow(unused_unsafe, clippy::all)] /// Query the resolution of the clock. Returns the duration of time /// corresponding to a clock tick. pub fn resolution() -> Duration { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.4")] extern"C" { #[link_name = "resolution"]
fn wit_import0() -> i64;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0() -> i64 {
unreachable!()
} let ret = wit_import0();
ret as u64
}
} #[allow(unused_unsafe, clippy::all)] /// Create a `pollable` which will resolve once the specified instant /// has occurred. pub fn subscribe_instant(when: Instant) -> Pollable { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.4")] extern"C" { #[link_name = "subscribe-instant"]
fn wit_import0(_: i64) -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0(_: i64) -> i32 {
unreachable!()
} let ret = wit_import0(_rt::as_i64(when)); super::super::super::wasi::io::poll::Pollable::from_handle(
ret as u32,
)
}
} #[allow(unused_unsafe, clippy::all)] /// Create a `pollable` that will resolve after the specified duration has /// elapsed from the time this function is invoked. pub fn subscribe_duration(when: Duration) -> Pollable { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/monotonic-clock@0.2.4")] extern"C" { #[link_name = "subscribe-duration"]
fn wit_import0(_: i64) -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0(_: i64) -> i32 {
unreachable!()
} let ret = wit_import0(_rt::as_i64(when)); super::super::super::wasi::io::poll::Pollable::from_handle(
ret as u32,
)
}
}
} /// WASI Wall Clock is a clock API intended to let users query the current /// time. The name "wall" makes an analogy to a "clock on the wall", which /// is not necessarily monotonic as it may be reset. /// /// It is intended to be portable at least between Unix-family platforms and /// Windows. /// /// A wall clock is a clock which measures the date and time according to /// some external reference. /// /// External references may be reset, so this clock is not necessarily /// monotonic, making it unsuitable for measuring elapsed time. /// /// It is intended for reporting the current date and time for humans. #[allow(dead_code, unused_imports, clippy::all)] pubmod wall_clock { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; /// A time and date in seconds plus nanoseconds. #[repr(C)] #[derive(Clone, Copy)] pubstruct Datetime { pub seconds: u64, pub nanoseconds: u32,
} impl ::core::fmt::Debug for Datetime {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.debug_struct("Datetime")
.field("seconds", &self.seconds)
.field("nanoseconds", &self.nanoseconds)
.finish()
}
} #[allow(unused_unsafe, clippy::all)] /// Read the current value of the clock. /// /// This clock is not monotonic, therefore calling this function repeatedly /// will not necessarily produce a sequence of non-decreasing values. /// /// The returned timestamps represent the number of seconds since /// 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch], /// also known as [Unix Time]. /// /// The nanoseconds field of the output is always less than 1000000000. /// /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16 /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time pub fn now() -> Datetime { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit<u8>; 16]); letmut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.4")] extern"C" { #[link_name = "now"]
fn wit_import1(_: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: *mut u8) {
unreachable!()
}
wit_import1(ptr0); let l2 = *ptr0.add(0).cast::<i64>(); let l3 = *ptr0.add(8).cast::<i32>(); let result4 = Datetime {
seconds: l2 as u64,
nanoseconds: l3 as u32,
};
result4
}
} #[allow(unused_unsafe, clippy::all)] /// Query the resolution of the clock. /// /// The nanoseconds field of the output is always less than 1000000000. pub fn resolution() -> Datetime { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit<u8>; 16]); letmut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 16]); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:clocks/wall-clock@0.2.4")] extern"C" { #[link_name = "resolution"]
fn wit_import1(_: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: *mut u8) {
unreachable!()
}
wit_import1(ptr0); let l2 = *ptr0.add(0).cast::<i64>(); let l3 = *ptr0.add(8).cast::<i32>(); let result4 = Datetime {
seconds: l2 as u64,
nanoseconds: l3 as u32,
};
result4
}
}
}
} pubmod filesystem { /// WASI filesystem is a filesystem API primarily intended to let users run WASI /// programs that access their files on their existing filesystems, without /// significant overhead. /// /// It is intended to be roughly portable between Unix-family platforms and /// Windows, though it does not hide many of the major differences. /// /// Paths are passed as interface-type `string`s, meaning they must consist of /// a sequence of Unicode Scalar Values (USVs). Some filesystems may contain /// paths which are not accessible by this API. /// /// The directory separator in WASI is always the forward-slash (`/`). /// /// All paths in WASI are relative paths, and are interpreted relative to a /// `descriptor` referring to a base directory. If a `path` argument to any WASI /// function starts with `/`, or if any step of resolving a `path`, including /// `..` and symbolic link steps, reaches a directory outside of the base /// directory, or reaches a symlink to an absolute or rooted path in the /// underlying filesystem, the function fails with `error-code::not-permitted`. /// /// For more information about WASI path resolution and sandboxing, see /// [WASI filesystem path resolution]. /// /// [WASI filesystem path resolution]: https://github.com/WebAssembly/wasi-filesystem/blob/main/path-resolution.md #[allow(dead_code, unused_imports, clippy::all)] pubmod types { #[used] #[doc(hidden)] static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports; usesuper::super::super::_rt; pubtype InputStream = super::super::super::wasi::io::streams::InputStream; pubtype OutputStream = super::super::super::wasi::io::streams::OutputStream; pubtype Error = super::super::super::wasi::io::streams::Error; pubtype Datetime = super::super::super::wasi::clocks::wall_clock::Datetime; /// File size or length of a region within a file. pubtype 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, Ord, PartialEq, PartialOrd)] pubenum 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 { matchself {
DescriptorType::Unknown => {
f.debug_tuple("DescriptorType::Unknown").finish()
}
DescriptorType::BlockDevice => {
f.debug_tuple("DescriptorType::BlockDevice").finish()
}
DescriptorType::CharacterDevice => {
f.debug_tuple("DescriptorType::CharacterDevice").finish()
}
DescriptorType::Directory => {
f.debug_tuple("DescriptorType::Directory").finish()
}
DescriptorType::Fifo => {
f.debug_tuple("DescriptorType::Fifo").finish()
}
DescriptorType::SymbolicLink => {
f.debug_tuple("DescriptorType::SymbolicLink").finish()
}
DescriptorType::RegularFile => {
f.debug_tuple("DescriptorType::RegularFile").finish()
}
DescriptorType::Socket => {
f.debug_tuple("DescriptorType::Socket").finish()
}
}
}
} impl DescriptorType { #[doc(hidden)] pubunsafe fn _lift(val: u8) -> DescriptorType { if !cfg!(debug_assertions) { return ::core::mem::transmute(val);
} match val { 0 => DescriptorType::Unknown, 1 => DescriptorType::BlockDevice, 2 => DescriptorType::CharacterDevice, 3 => DescriptorType::Directory, 4 => DescriptorType::Fifo, 5 => DescriptorType::SymbolicLink, 6 => DescriptorType::RegularFile, 7 => DescriptorType::Socket,
_ => panic!("invalid enum discriminant"),
}
}
}
wit_bindgen_rt::bitflags::bitflags! { #[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 integrity"] #[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! { #[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! { #[doc = " Open flags used by `open-at`."] #[derive(PartialEq, Eq,
PartialOrd, Ord, Hash, Debug, Clone, Copy)] pubstruct 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. pubtype LinkCount = u64; /// File attributes. /// /// Note: This was called `filestat` in earlier versions of WASI. #[repr(C)] #[derive(Clone, Copy)] pubstruct 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<Datetime>, /// 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<Datetime>, /// 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<Datetime>,
} impl ::core::fmt::Debug for DescriptorStat {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.debug_struct("DescriptorStat")
.field("type", &self.type_)
.field("link-count", &self.link_count)
.field("size", &self.size)
.field("data-access-timestamp", &self.data_access_timestamp)
.field( "data-modification-timestamp",
&self.data_modification_timestamp,
)
.field("status-change-timestamp", &self.status_change_timestamp)
.finish()
}
} /// When setting a timestamp, this gives the value to set it to. #[derive(Clone, Copy)] pubenum 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 { matchself {
NewTimestamp::NoChange => {
f.debug_tuple("NewTimestamp::NoChange").finish()
}
NewTimestamp::Now => f.debug_tuple("NewTimestamp::Now").finish(),
NewTimestamp::Timestamp(e) => {
f.debug_tuple("NewTimestamp::Timestamp").field(e).finish()
}
}
}
} /// A directory entry. #[derive(Clone)] pubstruct DirectoryEntry { /// The type of the file referred to by this directory entry. pub type_: DescriptorType, /// The name of the object. pub name: _rt::String,
} impl ::core::fmt::Debug for DirectoryEntry {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.debug_struct("DirectoryEntry")
.field("type", &self.type_)
.field("name", &self.name)
.finish()
}
} /// Error codes returned by functions, similar to `errno` in POSIX. /// Not all of these error codes are returned by the functions provided by this /// API; some are used in higher-level library layers, and others are provided /// merely for alignment with POSIX. #[repr(u8)] #[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)] pubenum 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. :ngCore;
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 /// No such file or directory, similar to `ENOENT` in POSIX.
NoEntry, /// No locks available, similar to `ENOLCK` in POSIX.pubfnfrom_bytes( &[8)-> IdpfInput java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
,
java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 pub fn clone_with_suffix(&self, suffix: &[bool]) -> IdpfInput {
InsufficientSpace, /// Not a directory or a symbolic link to a directory, similar to `ENOTDIR` in POSIX.extend_from_bitsliceself)
NotDirectory,
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
NotEmpty, self.java.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 29
NotRecoverable, /// Not supported, similar to `ENOTSUP` and `ENOSYS` in POSIX.
let mut veclet vec = BitVec:<u8 Msb0>:with_capacity(self.indexlen);
vec.&self.;
vec.into_vec() /// 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.
/// Operation not permitted, similar to `EPERM` in POSIX.
java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
Output= BitSlice I>:Output // Read-only file system, similar to `EROFS` in POSIX.
java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 3 /// Invalid seek, similar to `ESPIPE` in POSIX.
InvalidSeek+AddAssign /// Text file busy, similar to `ETXTBSY` in POSIX.
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 11 /// Cross-device link, similar to `EXDEV` in POSIX.
CrossDevice,
} impl ErrorCode { pub name(&elf) > 'static str {
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 0 // This is the same as in [`subtle::ConditionallySelectable`], but without the [`Copy`] bound. a &, b:&,:Choice)-Self;
ErrorCode::= would-",
ErrorCode::Already => "alreadyjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
: > bad-"java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69 let buffer=0864;
: = ",
ErrorCode::Quota =>"quota",
ErrorCode::Exist => "exist",
ErrorCode::FileTooLarge seed_stream.fill_bytes(&mutbuffer[..F::ENCODED_SIZE]);
ErrorCode::IllegalByteSequence => "illegal-byte-sequence",
ControlFlow::Break(x) => return x,
ErrorCode::Interrupted => "interrupted",
ErrorCode::Invalid => "invalid",
fn zero(:&) >Self {
fnconditional_select(: Self b: &Self, choice: Choice) -> Self {
ErrorCode::Loop => "loop",
ErrorCode::TooManyLinks => "too-many-links",
::essageSize => "message-size",
ErrorCode::NameTooLong => "name-too-long" (VI),
ErrorCode::NoDevice => "no-device",
ErrorCode::NoEntry => "no-,
ErrorCode::NoLock VL:IdpfValue,
ErrorCode:: /// Combine two output share values into one.
ErrorCode:
ErrorCode: (IdpfOutputShare:Innermutself_value),IdpfOutputShare::Inner(other_value)) >{
ErrorCode::(IdpfOutputShare:self_value)
ErrorCode::NotRecoverable => "not-recoverable",
: = "unsupported,
ErrorCode:NoTty = notty,
ErrorCode:NoSuchDevice >"osuch-device"
ErrorCode::Overflow => "overflow",
: = "permitted"java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
e:Pipe => "ipe",
ErrorCode::ReadOnly => "read-only",
rrorCode::InvalidSeek => "invalid-seek",
ErrorCode::TextFileBusy => "text-file-busy",
ErrorCode::CrossDevice => "cross-device",
fn convert<V>(
} pub fn message : &[8 16, matchself {
ErrorCode::Access => {
java.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5
}
ErrorCode::WouldBlock => {
next_seed);
}
ErrorCode::Already => { "Connection already in progress, similar to `value: V
}
ErrorCode: =>java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
B ,similarto `` inPOSIX.
ErrorCode::java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 0
Deviceor resource busy,similar to `EBUSY` in POSIX."
}
ErrorCode:::eadlock=> { "Resource deadlock control_bits_0[0] ^ control_bits_1[0] ^ inpu ^Choice::from(1),
ErrorCode::Quota => {:java.lang.StringIndexOutOfBoundsException: Range [36, 34) out of bounds for length 83
Choiceconditional_select(java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 81
}
:Exist=> File,similar to `EEXIST` in POSIX.",
ErrorCode::ileTooLarge= { "File too large, similar to `let seeds_corrected = [
}
ErrorCode::IllegalByteSequence => { "convert:V(seeds_corrected[0], convert_xof_fixed_key, parameter);
}
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 => { " java.lang.StringIndexOutOfBoundsException: Range [56, 55) out of bounds for length 75
=
Message to ` POSIX crate fngen_with_random<M:IntoIterator< = VI>(
ErrorCode::NameTooLong => { "Filename too long, similar to `ENAMETOOLONG` in POSIX."
}
ErrorCode::NoDevice => { "No such device, similar to binder:&u]java.lang.StringIndexOutOfBoundsException: Index 22 out of bounds for length 22
ErrorCode::NoEntry => { "No such file or directory0 0 /* usage */
VERSION1/* algorithm class */0,00,
ErrorCode::NoLock => { "No locks available, similar to `ENOLCK` in POSIX."
= :wjava.lang.StringIndexOutOfBoundsException: Range [60, 59) out of bounds for length 70
ErrorCode:InsufficientMemory > {
N space,similar to`NOMEM`in "
into();
::java.lang.StringIndexOutOfBoundsException: Range [54, 52) out of bounds for length 57
device,similar ` POSIX
}
ErrorCode "java.lang.StringIndexOutOfBoundsException: Range [12, 32) out of bounds for length 14
}
:NotEmpty=> { "&mut control_bits,
}
ErrorCode::NotRecoverable => {
not recoverable to ``inPOSIX.java.lang.StringIndexOutOfBoundsException: Index 91 out of bounds for length 91
ErrorCode::Unsupported => {
<>(
input: I,
:VL "Inappropriate I/ control operation, similar to `ENOTTY` in POSIX."
} where "No such device java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
ErrorCode:O= java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
largeto indata type similar to ``in
}
ErrorCode::NotPermitted => {
to `EPERM` POSIX" /// Evaluate an IDPF share on `prefix`, starting from a particular tree level with known
ErrorCode::Pipe => "Broken pipe, similar to `EPIPE` in POSIX.",
ErrorCode:ReadOnly =>java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48 "Read-only file system, similar to ` start_level: usize,
}
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,0/* usage */
)- ::f:Result {
f.debug_struct("ErrorCode")
= XofFixedKeyAes128Key:new,binder;
.field("name", &self.name())
.field("message", &self.message(for(correction_word,input_bit) )injava.lang.StringIndexOutOfBoundsException: Range [66, 65) out of bounds for length 88
.finish()
}
} impl Choice:from(input_bit )
)
s
f java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
) -> ::core::fmt::Result {
write!(f, "{} &mutkeyjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
}
} #[cfg(feature = "std / : there's no point caching this node'skey because wewill always run implstd::Error forErrorCode { impl ErrorCode } #[doc(hidden)] pub ifpub fnevaljava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16 return ::core::mem:transmute(al;
} match val{ 0 => ErrorCode::Access, 1 => ErrorCode::WouldBlock, 2= ErrorCode:Already, 3 => ErrorCode:: return(dpfError:Iformat!( 4 => ErrorCode:java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 16 5 => (IdpfError:" java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 80 6 =); 7 => ErrorCode::Exist, 8 => ErrorCode::FileTooLargeif.len() 1{ 9 => ErrorCode::IllegalByteSequence,
=> :java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52 11 => ErrorCode::Interrupted, 12 >ErrorCode::, 13 => ErrorCode::Io, 14 => ErrorCode::Choice::from(control_bit) 15 => ErrorCode::java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 30 16, 17 => ErrorCode::MessageSize, 18 = ErrorCode:NameTooLong, 19 => ErrorCodeis_leader 20 => ErrorCode::NoEntry, 21 prefix, 22 => ErrorCode::InsufficientMemory, 23 => ErrorCode/// An IDPF public share. This contains the list of correction words used by all parties when 24 =>:java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54 25 => ErrorCode::leaf_correction_word: IdpfCorrectionWord<VL>, 26 => ErrorCode<VI VL ConstantTimeEq IdpfPublicShare<I VL 27 => ErrorCode:java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
> :oTty, 29 => ErrorCode::NoSuchDevice, 30 I java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 23 31
ipe, 33 => ErrorCode::java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 23 34 => ErrorCode::InvalidSeek, 35=> ErrorCode:TextFileBusy, 36 => ErrorCode::CrossDevice,
_ => panic!("invalid enum discriminant"),
}
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
} /// File or memory access pattern advisory information.
repru8)java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
[deriveClone,Copy,Eq PartialEq,PartialOrd)java.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66 pubenum Advicejava.lang.StringIndexOutOfBoundsException: Range [21, 20) out of bounds for length 28 /// The application has no advice to give on its behavior with respect
/// The application expects to access the specified data sequentially /// from lower offsets to higher offsets.
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 5
specifieddata ina random
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 let packed_control_len = (bits + 3) / java.lang.StringIndexOutOfBoundsException: Range [32, 30) out of bounds for length 48
fn fmt(
&java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 0
f &:::fmt:<>,
> :core:mt:Result {java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 matchself {
Advice:: control_bits,
:= java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
debug_tuple":".()
}
Advice::Random =>];
Advice::WillNeed => f.debug_tuple :decode(?;
Advice::DontNeed => f.debug_tuple("Advice::DontNeed").finish(),
Advice::NoReuse => f.debug_tuple("Advice::NoReuse").finish(),
}
}
} impl Advice { #doc()
; if !cfg!(if unpacked_control_bits[bits]any( {
Err(:;
, match})
<>{ 2 > ::, 3 => Advice
:java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 22 5 => Advice::NoReuse self.ct_eq&thervaluejava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
_ => panic!("java.lang.StringIndexOutOfBoundsException: Range [0, 44) out of bounds for length 22
}
}
java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 13
/// A 128-bit hash value, split into parts because wasm doesn't have a /// 128-bit integer type. #[repr(C)] #[derive(Clone, Copy)] pubpubstruct MetadataHashValue {
seed
of a128bithash java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60 pub for (a, (b, c)) in left)(.iter).ip(eed.() {
}
tadataHashValue {
fn fmt(
&self,
::::java.lang.StringIndexOutOfBoundsException: Range [51, 50) out of bounds for length 55
) -> ::core::fmt::Result {
f.debug_struct("MetadataHashValue")
.field("lower"let = -unwrap_u8( as ) as u8;
.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.
veDebug) #[repr(transparent pubstruct Descriptor {
: rt:Descriptor>java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
} impl Descriptor {
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 unsafe from_handlehandle: - Self{
{
handle: _rt::Resource::from_handlejava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
} /// In typical use, IDPFs will be evaluated repeatedly on inputs of increasing length, as part of a #[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)
}
} unsafeimpl _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.4")] extern"C" { #[link_name = "[resource-drop]descriptor"]
fn drop(_: u32);
}
drop(_handle);
}
}
} /// A stream of directory entries. #[derive(Debug)] #[repr(transparent)]
forNoCache{
handle: _rt::java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 12
java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13 impl DirectoryEntryStream { #[doc(hidden)] pubunsafe fn map: HashMap<BitBox, ([u8; 16),
java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
handle: _rt::Resource::from_handle(HashMapCache:default(java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
} #[doc(hidden)] pub
: BitSlice) - Option<([u8; 16], u8> {
} #[doc(hidden)] pub fn handle(&self) -> u32 {
_t::handle(&selfhandle)
}
} unsafe/// A simple [`IdpfCache`] implementation that caches intermediate results in memory, with #[inline unsafe drop_:u32){ #[cfg(not(target_arch = "wasm32capacity, ),
unreachable!(); #[cfg( fngetself input B)- Option(u; ],u8>{
{ #[link(java.lang.StringIndexOutOfBoundsException: Range [16, 1) out of bounds for length 48 extern"C" selfringlen)=self
fn.(nputjava.lang.StringIndexOutOfBoundsException: Range [39, 38) out of bounds for length 85
}
drop(_handle);
}
}
} impl Descriptor { #[allow(/// to the Zipf distribution with `java.lang.StringIndexOutOfBoundsException: Range [83, 82) out of bounds for length 95 /// Return a stream for reading from a file, if available. /// /// May fail with an error-code describing why the file cannot be read.,
threshold:usize
java.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 27 /// 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< ErrorCode>{ unsafe { // Compute the prefix tree for the desired threshold.
letmut (, prefix in hit_counts.ter_mut().zip(prefix_tree[.(){
[::core::mem::MaybeUninit::uninit(); 8],
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
[fg(arget_arch ="wasm32")java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54 #[link(wasm_import_module = "wasi:filesystem/types@0.2.4")] extern" #"]
wit_import1(: i32, :,_: *ut u8)java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
}
[fgnottarget_arch = "wasm32"))]
}
unreachable!(
}
java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0
:f(ptr0()cast:<u8>()java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70 let result5 = match l2 { 0 = java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 let e = {
prelude:{BitBox,Lsb0}, super::super: ::BitVec,
u32,
)
Ok(e)
} 1 => java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 let e = { let l4 ]java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
:lift(4asu8)
};
Err(e assert_eq!(input_1[..], bits);
}
_ => _rt::invalid_enum_discriminant(),
};
java.lang.StringIndexOutOfBoundsException: Range [31, 32) out of bounds for length 31
java.lang.StringIndexOutOfBoundsException: Range [23, 22) out of bounds for length 33
}
} impl Descriptor { #[allow(java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 20
} /// /// 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.
fn
&self,
offset: Filesizejava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
) -> Result<::new(Vec:new()java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50 unsafe { #ralign(4)java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41 struct fn get(&self, input: &BitSlice<[; java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
java.lang.StringIndexOutOfBoundsException: Range [33, 32) out of bounds for length 72 #
java.lang.StringIndexOutOfBoundsException: Range [50, 49) out of bounds for length 83 extern(
java.lang.StringIndexOutOfBoundsException: Range [40, 39) out of bounds for length 80
fn wit_import1.:<Vec_>)java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, ],
unreachablejava.lang.StringIndexOutOfBoundsException: Range [26, 25) out of bounds for length 26
}
wit_import1((self).handle() as i32, _rt::as_i64(offset), ptr0); let l2 = let result5 = match l2 { 0 => {
e ={ let add(4).ast::<i32>) supersupersuper::i:streams:java.lang.StringIndexOutOfBoundsException: Range [102, 101) out of bounds for length 102
l3 as java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50
)
};
Ok(e)
}
:( ))
java.lang.StringIndexOutOfBoundsException: Range [38, 37) out of bounds for length 41 let java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
:liftl4 asu8
};
Err(e)
}
_ => java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 14
};
result5
}
}
} impl Descriptor { #[allow(unused_unsafejava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 17 /// Return a stream for appending to a file, if available. ///
/ /// /// Note: This allows using `write-stream`, which is similar to `write` withP:[z() 2; ]java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76
/Wrongnumber ofvalues
append_via_stream(&self- < unsafe { #[repr(align(4))] java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 19
&bitbox![; 10]into), letmut ret_area = RetArea(
[::mem::(); ]
.java.lang.StringIndexOutOfBoundsException: Range [22, 19) out of bounds for length 22
#[cfg(0java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25 #[link(java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 23 externC #[link_name = "[method] bitbox[ ]()java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
_i32_: *
} #[cfg(not(inner_correction_words: Vec::from([ extern"C"seed 016,
unreachable!()
,
wit_import1java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35 let l2 = Field64::fromu64, let result5 = match l2 { 0 => { let e = { let l3 = *ptr0.add(4).cast::<i32>();
java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 14
l3 as u32,
)
};
Ok(e)
}
> let ,// field element correction word, continued let l40100000000000000000000000000000000000000000000000000000000000000",
ErrorCode::_lift(l4 as ))
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
}
result5
}
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
}
Descriptor #[allow(unused_unsafe, clippy::all)]
java.lang.StringIndexOutOfBoundsException: Index 85 out of bounds for length 85 /// /// This is similar to `posix_fadvise` in POSIX. pub
&self,
offset: Filesize,
control_bits:[hoice:from1)Choice::(0],
advice: ,
) -> ResultIdpfCorrectionWord unsafe { #[repr(align(1))] struct RetArea([::core: IdpfCorrectionWord{ letmut ret_area = RetArea(
::::mem::MaybeUninit:uninit() 2,
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32") :[Choice::rom(0, :from),
[inkwasm_import_module= wasi:/0..4") "" #[link_name = "[method]descriptor.advise"]
fn wit_import1(_: i32, _: i64, _: i64, _: i32, _: *mut value: Poplar1IdpfValue::new([Field64::zero(), Field64::zero()]),Field64:zero() Field64:zero(],
} #[cfg(not(target_arch = "wasm32"))] extern"C" fncontrol_bits: [hoice::() Choice:from()]
: java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
:[0 ]
_: i64,
_: i32,
_: *mut u8,
) {
"",
wit_import1(
(self).handle() as i32,
_rt::as_i64(offset),
_rt::as_i64(length),
advice.clone() as i32,
ptr00000000000000000,
); let l2 = i32::from(*ptr0.add(0).cast::<u8>());""java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 let result4 = java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 31 0 => { let e = ();
Ok())
}
let e = { let l3 = i32::from(*ptr0
ErrorCode::_lift(l3 as u8)
.[[)
[,false,true , [.,
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
} impl Descriptor { #[allow(unused_unsafe, clippy::all)] /// Synchronize the data of a file to disk. ///
/ /// opened for writing. /// /// Note: This is similar to `fdatasync` in POSIX. pub sync_data(self - <(,ErrorCode
#[align(1)] struct RetArea([::java.lang.StringIndexOutOfBoundsException: Range [0, 46) out of bounds for length 0 letmut ret_area = RetArea(
<java.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43
); let ptr0.ap(|| java.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53
[fg(= wasm32")java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
024"]
.(, #[link_name = "[method]descriptor.sync-data java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
fn wit_import1(_ value: Poplar1IdpfValue:new([ield255:zero(;2)
}
idpf_bits len) / 2java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51 extern"Cletsize_field_vecs java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
unreachable!()
java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
wit_import1(java.lang.StringIndexOutOfBoundsException: Range [36, 35) out of bounds for length 85 let l2 = i32::from(*ptr0.add(0 ublic_share let result4 = match l2 {
> { let e = ();
Ok(e)
} 1 => { let e = { let l3 = i32::from(*ptr0assert_matches!err, CodecError::)
ErrorCode::_java.lang.StringIndexOutOfBoundsException: Range [0, 52) out of bounds for length 24
};
Err(e)
}
_ = _:(,
};
result4
}
}
} impl Descriptor { #[allow(unused_unsafe, clippy:: !err :; /// 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 binder: Vec<u8>, pub fn get_flags(&self) -> Result<DescriptorFlagsalpha: IdpfInput, unsafe { #[repr(align(1))] struct RetArea([::core::mem::MaybeUninit<u8>; 2]); letmut ret_area = RetArea(public_share: Vec<u8>,
[::core::mem::MaybeUninit::uninit() }
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
(target_arch "asm32"] #[w= "wasi:filesystem/types@0.4" extern"C"let bits test_vec_obj #[link_name =.(java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
fn wit_import1(_: i32, _: *mut u8);
} #[cfg(not(target_arch = ha_str).unwrap(); "C wit_import1i32_ *ut u8){
unreachable!()
}
wit_import1((.map| &> (-level - ) && !) let l2 = i32::from(*ptr0.add(0).java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 38 let result5 = match l2 {
={
=
=:(java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47
| DescriptorFlags::from_bits_retain(((l3 as u8) << 0) as _)
}
Okunwrap)
} 1 => { let e = { let l4 = i32::from(*ptr0.add(1).cast::<u8>());
ErrorCode::_lift(l4 as u8)
Err(e)
}
_ => _rt::java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 0
};
result5
}
}
} impl(
ex::decode(keys_array[1].as_str().unwrap()) /// Get the dynamic type of a descriptor..unwrap(java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
; let public_share_hex = test_vec_obj.get("public_share").unwrap(); /// 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( )ijava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 unsafe { #[repr(aligntest_vector., struct RetArea([::core::mem::MaybeUninit<u8>; 2]);
[::core::mem::MaybeUninit::uninit( assert_eq!([1].,.keys1];
); let ptr0 = for (evel (java.lang.StringIndexOutOfBoundsException: Range [65, 64) out of bounds for length 82 # enumerate(java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24
lwasm_import_module "asi:filesystem/0.24" extern"C" { #[ ;
wit_import1_ i32,_* )java.lang.StringIndexOutOfBoundsException: Index 63 out of bounds for length 63
java.lang.StringIndexOutOfBoundsException: Range [25, 24) out of bounds for length 46
extern"C" fn wit_import1(_: i32, _: *mut u8"public share did not match\n{public_share:#x?}\n{expected_public_share:#x?}"
unreachable!()
}
java.lang.StringIndexOutOfBoundsException: Range [41, 35) out of bounds for length 66 let l2 = i32::from(*ptr0.add(0).
test_casetest_casesjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 0 >
,[254];
=i32:rom*tr0.add1)cast:<u8>()java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
DescriptorType::_lift(l3 as u8)
};
Ok(e)
} 1 ) let let l4 = i32::from(*ptr0.add( type =();
ErrorCode: java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
};
Err(e)
}
_ => _ MyUnit
};
result5
}
}
} impl Descriptor {
( :ll] /// 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 fnset_size(self, size Filesize)- Result<(,ErrorCode> { unsafe {
MyUnit struct RetArea([::core::mem::MaybeUninit<u8>; 2]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 2],
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[ impl Add for MyUnit #[wasm_import_module "asi:filesystem/ypes..4)java.lang.StringIndexOutOfBoundsException: Index 83 out of bounds for length 83 extern"C" { #[link_name = "[method]descriptor.set-size"]
fn wit_import1(_: i32, _: i64, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: i64, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, _rt::as_i64(size), ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result4 = match l2 { 0 => { lete=(;
Ok(e)
} 1 => { let e = { let l3 = i32::from(*ptr0. :RngCore,
mutoutput=vec!<Field128 as FieldElement>::zero(); *length];
}
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
} impl Descriptor { #[allow(unused_unsafe, clippy::all)] /// Adjust the timestamps of an open file or directory.fn a&,b Self choice: Choice) >Self java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 /// /// Note: This is similar to `futimens` in POSIX. /// /// Note: This was called `fd_filestat_set_times` in earlier versions of WASI. Field128 :c( pub fn set_times(
&self,
java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 0
NewTimestamp
) unsafe { #[repr(align(1))] structRetArea([:core:mem:MaybeUninit<; ]; letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninitelement.c)
); let (result1_0, result1_1, result1_2) = match data_access_timestamp {
NewTimestamp::NoChange => (0i32, 0i64, 0i32),
NewTimestamp::Now => (1i32, add(elf, rhs: >Self::utput
NewTimestamp::Timestamp(e) => { letsuper::super::super::wasi::clocks::wall_clock::Datetime {
seconds: seconds0,
nanoseconds: nanoseconds0,
} = e;
(2i32, MyVectoroutput
}
}; let (result3_0, result3_1, result3_2) = match data_modification_timestamp {
NewTimestamp::NoChange => (0i32, 0i64, 0i32),
NewTimestamp:Now >(i32,0,0i32,
NewTimestamp::Timestamp(e) implfor
seconds: seconds2,
nanoseconds: nanoseconds2,
} = e;
(2i32, _rt::as_i64(seconds2), _rt::as_i32(nanoseconds2))
}
}; let ptr4 MyVector() #[cfg #[link(wasm_import_module// the leaf nodes, to test out values that require runtime parameters. extern"C" { #[link_name = "[ &dpfInput:from_bytes(b"ae"),
f(1,
_: i32,
_: i32,
_: i64,
_: i32,
_: i32,
_: i64,
_: i32,
_1,
;
} #[cfg(not(target_arch = "wasm32")&mut:)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 extern"C" fn wit_import5(
i32,
_: i32,
_ java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
_: i32,
_: i32,
_: i64,
_: i32,
_: *java.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 23
) {
java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 22
}
(
(self).!(value.0[2], Field128)java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
result1_0,
result1_1,
result1_2,
result3_0,
result3_1,
result3_2,
ptr4,
); let l6 = i32::from(*ptr4.add(0).cast::<u8>()); let result8 = match l6 { 0 => { let e = ();
Ok(e)
} 1 => { let e = { let l7 = i32::from(*ptr4.add(1).cast::<u8>());
ErrorCode::_lift(l7 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result8
}
}
} 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<u8, error-code>`. /// /// Note: This is similar to `pread` in POSIX. pub fn read(
&self,
length: Filesize,
offset: Filesize,
) -> Result<(_rt::Vec<u8>, bool), ErrorCode> { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit<u8>; 16]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 16],
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:filesystem/types@0.2.4")] extern"C" { #[link_name = "[method]descriptor.read"]
fn wit_import1(_: i32, _: i64, _: i64, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: i64, _: i64, _: *mut u8) {
unreachable!()
}
wit_import1(
(self).handle() as i32,
_rt::as_i64(length),
_rt::as_i64(offset),
ptr0,
); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result8 = match l2 { 0 => { let e = { let l3 = *ptr0.add(4).cast::<*mut u8>(); let l4 = *ptr0.add(8).cast::<usize>(); let len5 = l4; let l6 = i32::from(*ptr0.add(12).cast::<u8>());
(
_rt::Vec::from_raw_parts(l3.cast(), len5, len5),
_rt::bool_lift(l6 as u8),
)
};
Ok(e)
} 1 => { let e = { let l7 = i32::from(*ptr0.add(4).cast::<u8>());
ErrorCode::_lift(l7 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result8
}
}
} 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<u8, error-code>`. /// /// Note: This is similar to `pwrite` in POSIX. pub fn write(
&self,
buffer: &[u8],
offset: Filesize,
) -> Result<Filesize, ErrorCode> { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit<u8>; 16]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 16],
); let vec0 = buffer; let ptr0 = vec0.as_ptr().cast::<u8>(); let len0 = vec0.len(); let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:filesystem/types@0.2.4")] extern"C" { #[link_name = "[method]descriptor.write"]
fn wit_import2(
_: i32,
_: *mut u8,
_: usize,
_: i64,
_: *mut u8,
);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import2(
_: i32,
_: *mut u8,
_: usize,
_: i64,
_: *mut u8,
) {
unreachable!()
}
wit_import2(
(self).handle() as i32,
ptr0.cast_mut(),
len0,
_rt::as_i64(offset),
ptr1,
); let l3 = i32::from(*ptr1.add(0).cast::<u8>()); let result6 = match l3 { 0 => { let e = { let l4 = *ptr1.add(8).cast::<i64>();
l4 as u64
};
Ok(e)
} 1 => { let e = { let l5 = i32::from(*ptr1.add(8).cast::<u8>());
ErrorCode::_lift(l5 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result6
}
}
} 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<DirectoryEntryStream, ErrorCode> { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit<u8>; 8]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 8],
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:filesystem/types@0.2.4")] extern"C" { #[link_name = "[method]descriptor.read-directory"]
fn wit_import1(_: i32, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result5 = match l2 { 0 => { let e = { let l3 = *ptr0.add(4).cast::<i32>();
DirectoryEntryStream::from_handle(l3 as u32)
};
Ok(e)
} 1 => { let e = { let l4 = i32::from(*ptr0.add(4).cast::<u8>());
ErrorCode::_lift(l4 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result5
}
}
} 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<u8>; 2]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 2],
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:filesystem/types@0.2.4")] extern"C" { #[link_name = "[method]descriptor.sync"]
fn wit_import1(_: i32, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result4 = match l2 { 0 => { let e = ();
Ok(e)
} 1 => { let e = { let l3 = i32::from(*ptr0.add(1).cast::<u8>());
ErrorCode::_lift(l3 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
} 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<u8>; 2]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 2],
); let vec0 = path; let ptr0 = vec0.as_ptr().cast::<u8>(); let len0 = vec0.len(); let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:filesystem/types@0.2.4")] extern"C" { #[link_name = "[method]descriptor.create-directory-at"]
fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import2(
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
) {
unreachable!()
}
wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1); let l3 = i32::from(*ptr1.add(0).cast::<u8>()); let result5 = match l3 { 0 => { let e = ();
Ok(e)
} 1 => { let e = { let l4 = i32::from(*ptr1.add(1).cast::<u8>());
ErrorCode::_lift(l4 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result5
}
}
} 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<DescriptorStat, ErrorCode> { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit<u8>; 104]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 104],
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:filesystem/types@0.2.4")] extern"C" { #[link_name = "[method]descriptor.stat"]
fn wit_import1(_: i32, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result16 = match l2 { 0 => { let e = { let l3 = i32::from(*ptr0.add(8).cast::<u8>()); let l4 = *ptr0.add(16).cast::<i64>(); let l5 = *ptr0.add(24).cast::<i64>(); let l6 = i32::from(*ptr0.add(32).cast::<u8>()); let l9 = i32::from(*ptr0.add(56).cast::<u8>()); let l12 = i32::from(*ptr0.add(80).cast::<u8>());
DescriptorStat {
type_: DescriptorType::_lift(l3 as u8),
link_count: l4 as u64,
size: l5 as u64,
data_access_timestamp: match l6 { 0 => None, 1 => { let e = { let l7 = *ptr0.add(40).cast::<i64>(); let l8 = *ptr0.add(48).cast::<i32>(); super::super::super::wasi::clocks::wall_clock::Datetime {
seconds: l7 as u64,
nanoseconds: l8 as u32,
}
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
data_modification_timestamp: match l9 { 0 => None, 1 => { let e = { let l10 = *ptr0.add(64).cast::<i64>(); let l11 = *ptr0.add(72).cast::<i32>(); super::super::super::wasi::clocks::wall_clock::Datetime {
seconds: l10 as u64,
nanoseconds: l11 as u32,
}
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
status_change_timestamp: match l12 { 0 => None, 1 => { let e = { let l13 = *ptr0.add(88).cast::<i64>(); let l14 = *ptr0.add(96).cast::<i32>(); super::super::super::wasi::clocks::wall_clock::Datetime {
seconds: l13 as u64,
nanoseconds: l14 as u32,
}
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
Ok(e)
} 1 => { let e = { let l15 = i32::from(*ptr0.add(8).cast::<u8>());
ErrorCode::_lift(l15 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result16
}
}
} impl Descriptor { #[allow(unused_unsafe, clippy::all)] /// Return the attributes of a file or directory. /// /// Note: This is similar to `fstatat` in POSIX, except that it does not /// return device and inode information. See the `stat` description for a /// discussion of alternatives. /// /// Note: This was called `path_filestat_get` in earlier versions of WASI. pub fn stat_at(
&self,
path_flags: PathFlags,
path: &str,
) -> Result<DescriptorStat, ErrorCode> { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit<u8>; 104]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 104],
); let flags0 = path_flags; let vec1 = path; let ptr1 = vec1.as_ptr().cast::<u8>(); let len1 = vec1.len(); let ptr2 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:filesystem/types@0.2.4")] extern"C" { #[link_name = "[method]descriptor.stat-at"]
fn wit_import3(
_: i32,
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import3(
_: i32,
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
) {
unreachable!()
}
wit_import3(
(self).handle() as i32,
(flags0.bits() >> 0) as i32,
ptr1.cast_mut(),
len1,
ptr2,
);
let l4 = i32::from(*ptr2.add(0).cast::<u8>());
let result18 = match l4 { 0 => {
let e = {
let l5 = i32::from(*ptr2.add(8).cast::<u8>());
let l6 = *ptr2.add(16).cast::<i64>();
let l7 = *ptr2.add(24).cast::<i64>();
let l8 = i32::from(*ptr2.add(32).cast::<u8>());
let l11 = i32::from(*ptr2.add(56).cast::<u8>());
let l14 = i32::from(*ptr2.add(80).cast::<u8>());
DescriptorStat {
type_: DescriptorType::_lift(l5 as u8),
link_count: l6 as u64,
size: l7 as u64,
data_access_timestamp: match l8 { 0 => None, 1 => {
let e = {
let l9 = *ptr2.add(40).cast::<i64>();
let l10 = *ptr2.add(48).cast::<i32>();
super::super::super::wasi::clocks::wall_clock::Datetime {
seconds: l9 as u64,
nanoseconds: l10 as u32,
}
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
data_modification_timestamp: match l11 { 0 => None, 1 => {
let e = {
let l12 = *ptr2.add(64).cast::<i64>();
let l13 = *ptr2.add(72).cast::<i32>();
super::super::super::wasi::clocks::wall_clock::Datetime {
seconds: l12 as u64,
nanoseconds: l13 as u32,
}
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
status_change_timestamp: match l14 { 0 => None, 1 => {
let e = {
let l15 = *ptr2.add(88).cast::<i64>();
let l16 = *ptr2.add(96).cast::<i32>();
super::super::super::wasi::clocks::wall_clock::Datetime {
seconds: l15 as u64,
nanoseconds: l16 as u32,
}
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
Ok(e)
} 1 => {
let e = {
let l17 = i32::from(*ptr2.add(8).cast::<u8>());
ErrorCode::_lift(l17 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result18
}
}
}
impl Descriptor {
#[allow(unused_unsafe, clippy::all)]
/// Adjust the timestamps of a file or directory.
///
/// Note: This is similar to `utimensat` in POSIX.
///
/// Note: This was called `path_filestat_set_times` in earlier versions of
/// WASI.
pub fn set_times_at(
&self,
path_flags: PathFlags,
path: &str,
data_access_timestamp: NewTimestamp,
data_modification_timestamp: NewTimestamp,
) -> Result<(), ErrorCode> {
unsafe {
#[repr(align(1))]
struct RetArea([::core::mem::MaybeUninit<u8>; 2]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 2],
);
let flags0 = path_flags;
let vec1 = path;
let ptr1 = vec1.as_ptr().cast::<u8>();
let len1 = vec1.len();
let (result3_0, result3_1, result3_2) = match data_access_timestamp {
NewTimestamp::NoChange => (0i32, 0i64, 0i32),
NewTimestamp::Now => (1i32, 0i64, 0i32),
NewTimestamp::Timestamp(e) => {
let super::super::super::wasi::clocks::wall_clock::Datetime {
seconds: seconds2,
nanoseconds: nanoseconds2,
} = e;
(2i32, _rt::as_i64(seconds2), _rt::as_i32(nanoseconds2))
}
};
let (result5_0, result5_1, result5_2) = match data_modification_timestamp {
NewTimestamp::NoChange => (0i32, 0i64, 0i32),
NewTimestamp::Now => (1i32, 0i64, 0i32),
NewTimestamp::Timestamp(e) => {
let super::super::super::wasi::clocks::wall_clock::Datetime {
seconds: seconds4,
nanoseconds: nanoseconds4,
} = e;
(2i32, _rt::as_i64(seconds4), _rt::as_i32(nanoseconds4))
}
};
let ptr6 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/types@0.2.4")]
extern "C" {
#[link_name = "[method]descriptor.set-times-at"]
fn wit_import7(
_: i32,
_: i32,
_: *mut u8,
_: usize,
_: i32,
_: i64,
_: i32,
_: i32,
_: i64,
_: i32,
_: *mut u8,
);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import7(
_: i32,
_: i32,
_: *mut u8,
_: usize,
_: i32,
_: i64,
_: i32,
_: i32,
_: i64,
_: i32,
_: *mut u8,
) {
unreachable!()
}
wit_import7(
(self).handle() as i32,
(flags0.bits() >> 0) as i32,
ptr1.cast_mut(),
len1,
result3_0,
result3_1,
result3_2,
result5_0,
result5_1,
result5_2,
ptr6,
);
let l8 = i32::from(*ptr6.add(0).cast::<u8>());
let result10 = match l8 { 0 => {
let e = ();
Ok(e)
} 1 => {
let e = {
let l9 = i32::from(*ptr6.add(1).cast::<u8>());
ErrorCode::_lift(l9 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result10
}
}
}
impl Descriptor {
#[allow(unused_unsafe, clippy::all)]
/// Create a hard link.
///
/// Fails with `error-code::no-entry` if the old path does not exist,
/// with `error-code::exist` if the new path already exists, and
/// `error-code::not-permitted` if the old path is not a file.
///
/// Note: This is similar to `linkat` in POSIX.
pub fn link_at(
&self,
old_path_flags: PathFlags,
old_path: &str,
new_descriptor: &Descriptor,
new_path: &str,
) -> Result<(), ErrorCode> {
unsafe {
#[repr(align(1))]
struct RetArea([::core::mem::MaybeUninit<u8>; 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::<u8>();
let len1 = vec1.len();
let vec2 = new_path;
let ptr2 = vec2.as_ptr().cast::<u8>();
let len2 = vec2.len();
let ptr3 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/types@0.2.4")]
extern "C" {
#[link_name = "[method]descriptor.link-at"]
fn wit_import4(
_: i32,
_: i32,
_: *mut u8,
_: usize,
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import4(
_: i32,
_: i32,
_: *mut u8,
_: usize,
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
) {
unreachable!()
}
wit_import4(
(self).handle() as i32,
(flags0.bits() >> 0) as i32,
ptr1.cast_mut(),
len1,
(new_descriptor).handle() as i32,
ptr2.cast_mut(),
len2,
ptr3,
);
let l5 = i32::from(*ptr3.add(0).cast::<u8>());
let result7 = match l5 { 0 => {
let e = ();
Ok(e)
} 1 => {
let e = {
let l6 = i32::from(*ptr3.add(1).cast::<u8>());
ErrorCode::_lift(l6 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result7
}
}
}
impl Descriptor {
#[allow(unused_unsafe, clippy::all)]
/// Open a file or directory.
///
/// If `flags` contains `descriptor-flags::mutate-directory`, and the base
/// descriptor doesn't have `descriptor-flags::mutate-directory` set,
/// `open-at` fails with `error-code::read-only`.
///
/// If `flags` contains `write` or `mutate-directory`, or `open-flags`
/// contains `truncate` or `create`, and the base descriptor doesn't have
/// `descriptor-flags::mutate-directory` set, `open-at` fails with
/// `error-code::read-only`.
///
/// Note: This is similar to `openat` in POSIX.
pub fn open_at(
&self,
path_flags: PathFlags,
path: &str,
open_flags: OpenFlags,
flags: DescriptorFlags,
) -> Result<Descriptor, ErrorCode> {
unsafe {
#[repr(align(4))]
struct RetArea([::core::mem::MaybeUninit<u8>; 8]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 8],
);
let flags0 = path_flags;
let vec1 = path;
let ptr1 = vec1.as_ptr().cast::<u8>();
let len1 = vec1.len();
let flags2 = open_flags;
let flags3 = flags;
let ptr4 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/types@0.2.4")]
extern "C" {
#[link_name = "[method]descriptor.open-at"]
fn wit_import5(
_: i32,
_: i32,
_: *mut u8,
_: usize,
_: i32,
_: i32,
_: *mut u8,
);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import5(
_: i32,
_: i32,
_: *mut u8,
_: usize,
_: i32,
_: i32,
_: *mut u8,
) {
unreachable!()
}
wit_import5(
(self).handle() as i32,
(flags0.bits() >> 0) as i32,
ptr1.cast_mut(),
len1,
(flags2.bits() >> 0) as i32,
(flags3.bits() >> 0) as i32,
ptr4,
);
let l6 = i32::from(*ptr4.add(0).cast::<u8>());
let result9 = match l6 { 0 => {
let e = {
let l7 = *ptr4.add(4).cast::<i32>();
Descriptor::from_handle(l7 as u32)
};
Ok(e)
} 1 => {
let e = {
let l8 = i32::from(*ptr4.add(4).cast::<u8>());
ErrorCode::_lift(l8 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result9
}
}
}
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<u8>; 12]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 12],
);
let vec0 = path;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/types@0.2.4")]
extern "C" {
#[link_name = "[method]descriptor.readlink-at"]
fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import2(
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
) {
unreachable!()
}
wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1);
let l3 = i32::from(*ptr1.add(0).cast::<u8>());
let result8 = match l3 { 0 => {
let e = {
let l4 = *ptr1.add(4).cast::<*mut u8>();
let l5 = *ptr1.add(8).cast::<usize>();
let len6 = l5;
let bytes6 = _rt::Vec::from_raw_parts(
l4.cast(),
len6,
len6,
);
_rt::string_lift(bytes6)
};
Ok(e)
} 1 => {
let e = {
let l7 = i32::from(*ptr1.add(4).cast::<u8>());
ErrorCode::_lift(l7 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result8
}
}
}
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<u8>; 2]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 2],
);
let vec0 = path;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/types@0.2.4")]
extern "C" {
#[link_name = "[method]descriptor.remove-directory-at"]
fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import2(
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
) {
unreachable!()
}
wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1);
let l3 = i32::from(*ptr1.add(0).cast::<u8>());
let result5 = match l3 { 0 => {
let e = ();
Ok(e)
} 1 => {
let e = {
let l4 = i32::from(*ptr1.add(1).cast::<u8>());
ErrorCode::_lift(l4 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result5
}
}
}
impl Descriptor {
#[allow(unused_unsafe, clippy::all)]
/// Rename a filesystem object.
///
/// Note: This is similar to `renameat` in POSIX.
pub fn rename_at(
&self,
old_path: &str,
new_descriptor: &Descriptor,
new_path: &str,
) -> Result<(), ErrorCode> {
unsafe {
#[repr(align(1))]
struct RetArea([::core::mem::MaybeUninit<u8>; 2]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 2],
);
let vec0 = old_path;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
let vec1 = new_path;
let ptr1 = vec1.as_ptr().cast::<u8>();
let len1 = vec1.len();
let ptr2 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/types@0.2.4")]
extern "C" {
#[link_name = "[method]descriptor.rename-at"]
fn wit_import3(
_: i32,
_: *mut u8,
_: usize,
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import3(
_: i32,
_: *mut u8,
_: usize,
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
) {
unreachable!()
}
wit_import3(
(self).handle() as i32,
ptr0.cast_mut(),
len0,
(new_descriptor).handle() as i32,
ptr1.cast_mut(),
len1,
ptr2,
);
let l4 = i32::from(*ptr2.add(0).cast::<u8>());
let result6 = match l4 { 0 => {
let e = ();
Ok(e)
} 1 => {
let e = {
let l5 = i32::from(*ptr2.add(1).cast::<u8>());
ErrorCode::_lift(l5 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result6
}
}
}
impl Descriptor {
#[allow(unused_unsafe, clippy::all)]
/// Create a symbolic link (also known as a "symlink").
///
/// If `old-path` starts with `/`, the function fails with
/// `error-code::not-permitted`.
///
/// Note: This is similar to `symlinkat` in POSIX.
pub fn symlink_at(
&self,
old_path: &str,
new_path: &str,
) -> Result<(), ErrorCode> {
unsafe {
#[repr(align(1))]
struct RetArea([::core::mem::MaybeUninit<u8>; 2]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 2],
);
let vec0 = old_path;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
let vec1 = new_path;
let ptr1 = vec1.as_ptr().cast::<u8>();
let len1 = vec1.len();
let ptr2 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/types@0.2.4")]
extern "C" {
#[link_name = "[method]descriptor.symlink-at"]
fn wit_import3(
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
_: usize,
_: *mut u8,
);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import3(
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
_: usize,
_: *mut u8,
) {
unreachable!()
}
wit_import3(
(self).handle() as i32,
ptr0.cast_mut(),
len0,
ptr1.cast_mut(),
len1,
ptr2,
);
let l4 = i32::from(*ptr2.add(0).cast::<u8>());
let result6 = match l4 { 0 => {
let e = ();
Ok(e)
} 1 => {
let e = {
let l5 = i32::from(*ptr2.add(1).cast::<u8>());
ErrorCode::_lift(l5 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result6
}
}
}
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<u8>; 2]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 2],
);
let vec0 = path;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/types@0.2.4")]
extern "C" {
#[link_name = "[method]descriptor.unlink-file-at"]
fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import2(
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
) {
unreachable!()
}
wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1);
let l3 = i32::from(*ptr1.add(0).cast::<u8>());
let result5 = match l3 { 0 => {
let e = ();
Ok(e)
} 1 => {
let e = {
let l4 = i32::from(*ptr1.add(1).cast::<u8>());
ErrorCode::_lift(l4 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result5
}
}
}
impl Descriptor {
#[allow(unused_unsafe, clippy::all)]
/// Test whether two descriptors refer to the same filesystem object.
///
/// In POSIX, this corresponds to testing whether the two descriptors have the
/// same device (`st_dev`) and inode (`st_ino` or `d_ino`) numbers.
/// wasi-filesystem does not expose device and inode numbers, so this function
/// may be used instead.
pub fn is_same_object(&self, other: &Descriptor) -> bool {
unsafe {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/types@0.2.4")]
extern "C" {
#[link_name = "[method]descriptor.is-same-object"]
fn wit_import0(_: i32, _: i32) -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import0(_: i32, _: i32) -> i32 {
unreachable!()
}
let ret = wit_import0(
(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 encouraged 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<MetadataHashValue, ErrorCode> {
unsafe {
#[repr(align(8))]
struct RetArea([::core::mem::MaybeUninit<u8>; 24]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 24],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/types@0.2.4")]
extern "C" {
#[link_name = "[method]descriptor.metadata-hash"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result6 = match l2 { 0 => {
let e = {
let l3 = *ptr0.add(8).cast::<i64>();
let l4 = *ptr0.add(16).cast::<i64>();
MetadataHashValue {
lower: l3 as u64,
upper: l4 as u64,
}
};
Ok(e)
} 1 => {
let e = {
let l5 = i32::from(*ptr0.add(8).cast::<u8>());
ErrorCode::_lift(l5 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result6
}
}
}
impl Descriptor {
#[allow(unused_unsafe, clippy::all)]
/// Return a hash of the metadata associated with a filesystem object referred
/// to by a directory descriptor and a relative path.
///
/// This performs the same hash computation as `metadata-hash`.
pub fn metadata_hash_at(
&self,
path_flags: PathFlags,
path: &str,
) -> Result<MetadataHashValue, ErrorCode> {
unsafe {
#[repr(align(8))]
struct RetArea([::core::mem::MaybeUninit<u8>; 24]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 24],
);
let flags0 = path_flags;
let vec1 = path;
let ptr1 = vec1.as_ptr().cast::<u8>();
let len1 = vec1.len();
let ptr2 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/types@0.2.4")]
extern "C" {
#[link_name = "[method]descriptor.metadata-hash-at"]
fn wit_import3(
_: i32,
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import3(
_: i32,
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
) {
unreachable!()
}
wit_import3(
(self).handle() as i32,
(flags0.bits() >> 0) as i32,
ptr1.cast_mut(),
len1,
ptr2,
);
let l4 = i32::from(*ptr2.add(0).cast::<u8>());
let result8 = match l4 { 0 => {
let e = {
let l5 = *ptr2.add(8).cast::<i64>();
let l6 = *ptr2.add(16).cast::<i64>();
MetadataHashValue {
lower: l5 as u64,
upper: l6 as u64,
}
};
Ok(e)
} 1 => {
let e = {
let l7 = i32::from(*ptr2.add(8).cast::<u8>());
ErrorCode::_lift(l7 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result8
}
}
}
impl DirectoryEntryStream {
#[allow(unused_unsafe, clippy::all)]
/// Read a single directory entry from a `directory-entry-stream`.
pub fn read_directory_entry(
&self,
) -> Result<Option<DirectoryEntry>, ErrorCode> {
unsafe {
#[repr(align(4))]
struct RetArea([::core::mem::MaybeUninit<u8>; 20]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 20],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/types@0.2.4")]
extern "C" {
#[link_name = "[method]directory-entry-stream.read-directory-entry"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result9 = match l2 { 0 => {
let e = {
let l3 = i32::from(*ptr0.add(4).cast::<u8>());
match l3 { 0 => None, 1 => {
let e = {
let l4 = i32::from(*ptr0.add(8).cast::<u8>());
let l5 = *ptr0.add(12).cast::<*mut u8>();
let l6 = *ptr0.add(16).cast::<usize>();
let len7 = l6;
let bytes7 = _rt::Vec::from_raw_parts(
l5.cast(),
len7,
len7,
);
DirectoryEntry {
type_: DescriptorType::_lift(l4 as u8),
name: _rt::string_lift(bytes7),
}
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
Ok(e)
} 1 => {
let e = {
let l8 = i32::from(*ptr0.add(4).cast::<u8>());
ErrorCode::_lift(l8 as u8)
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result9
}
}
}
#[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<ErrorCode> {
unsafe {
#[repr(align(1))]
struct RetArea([::core::mem::MaybeUninit<u8>; 2]);
let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 2]);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/types@0.2.4")]
extern "C" {
#[link_name = "filesystem-error-code"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((err).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result4 = match l2 { 0 => None, 1 => {
let e = {
let l3 = i32::from(*ptr0.add(1).cast::<u8>());
ErrorCode::_lift(l3 as u8)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
}
#[allow(dead_code, unused_imports, clippy::all)]
pub mod preopens {
#[used]
#[doc(hidden)]
static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports;
use super::super::super::_rt;
pub type Descriptor = super::super::super::wasi::filesystem::types::Descriptor;
#[allow(unused_unsafe, clippy::all)]
/// Return the set of preopened directories, and their paths.
pub fn get_directories() -> _rt::Vec<(Descriptor, _rt::String)> {
unsafe {
#[repr(align(4))]
struct RetArea([::core::mem::MaybeUninit<u8>; 8]);
let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 8]);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:filesystem/preopens@0.2.4")]
extern "C" {
#[link_name = "get-directories"]
fn wit_import1(_: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: *mut u8) {
unreachable!()
}
wit_import1(ptr0);
let l2 = *ptr0.add(0).cast::<*mut u8>();
let l3 = *ptr0.add(4).cast::<usize>();
let base8 = l2;
let len8 = l3;
let mut result8 = _rt::Vec::with_capacity(len8);
for i in 0..len8 {
let base = base8.add(i * 12);
let e8 = {
let l4 = *base.add(0).cast::<i32>();
let l5 = *base.add(4).cast::<*mut u8>();
let l6 = *base.add(8).cast::<usize>();
let len7 = l6;
let bytes7 = _rt::Vec::from_raw_parts(l5.cast(), len7, len7);
(
super::super::super::wasi::filesystem::types::Descriptor::from_handle(
l4 as u32,
),
_rt::string_lift(bytes7),
)
};
result8.push(e8);
}
_rt::cabi_dealloc(base8, len8 * 12, 4);
let result9 = result8;
result9
}
}
}
}
pub mod http {
/// This interface defines all of the types and methods for implementing
/// HTTP Requests and Responses, both incoming and outgoing, as well as
/// their headers, trailers, and bodies.
#[allow(dead_code, unused_imports, clippy::all)]
pub mod types {
#[used]
#[doc(hidden)]
static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports;
use super::super::super::_rt;
pub type Duration = super::super::super::wasi::clocks::monotonic_clock::Duration;
pub type InputStream = super::super::super::wasi::io::streams::InputStream;
pub type OutputStream = super::super::super::wasi::io::streams::OutputStream;
pub type IoError = super::super::super::wasi::io::error::Error;
pub type Pollable = super::super::super::wasi::io::poll::Pollable;
/// This type corresponds to HTTP standard Methods.
#[derive(Clone)]
pub enum Method {
Get,
Head,
Post,
Put,
Delete,
Connect,
Options,
Trace,
Patch,
Other(_rt::String),
}
impl ::core::fmt::Debug for Method {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
match self {
Method::Get => f.debug_tuple("Method::Get").finish(),
Method::Head => f.debug_tuple("Method::Head").finish(),
Method::Post => f.debug_tuple("Method::Post").finish(),
Method::Put => f.debug_tuple("Method::Put").finish(),
Method::Delete => f.debug_tuple("Method::Delete").finish(),
Method::Connect => f.debug_tuple("Method::Connect").finish(),
Method::Options => f.debug_tuple("Method::Options").finish(),
Method::Trace => f.debug_tuple("Method::Trace").finish(),
Method::Patch => f.debug_tuple("Method::Patch").finish(),
Method::Other(e) => {
f.debug_tuple("Method::Other").field(e).finish()
}
}
}
}
/// This type corresponds to HTTP standard Related Schemes.
#[derive(Clone)]
pub enum Scheme {
Http,
Https,
Other(_rt::String),
}
impl ::core::fmt::Debug for Scheme {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
match self {
Scheme::Http => f.debug_tuple("Scheme::Http").finish(),
Scheme::Https => f.debug_tuple("Scheme::Https").finish(),
Scheme::Other(e) => {
f.debug_tuple("Scheme::Other").field(e).finish()
}
}
}
}
/// Defines the case payload type for `DNS-error` above:
#[derive(Clone)]
pub struct DnsErrorPayload {
pub rcode: Option<_rt::String>,
pub info_code: Option<u16>,
}
impl ::core::fmt::Debug for DnsErrorPayload {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.debug_struct("DnsErrorPayload")
.field("rcode", &self.rcode)
.field("info-code", &self.info_code)
.finish()
}
}
/// Defines the case payload type for `TLS-alert-received` above:
#[derive(Clone)]
pub struct TlsAlertReceivedPayload {
pub alert_id: Option<u8>,
pub alert_message: Option<_rt::String>,
}
impl ::core::fmt::Debug for TlsAlertReceivedPayload {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.debug_struct("TlsAlertReceivedPayload")
.field("alert-id", &self.alert_id)
.field("alert-message", &self.alert_message)
.finish()
}
}
/// Defines the case payload type for `HTTP-response-{header,trailer}-size` above:
#[derive(Clone)]
pub struct FieldSizePayload {
pub field_name: Option<_rt::String>,
pub field_size: Option<u32>,
}
impl ::core::fmt::Debug for FieldSizePayload {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
f.debug_struct("FieldSizePayload")
.field("field-name", &self.field_name)
.field("field-size", &self.field_size)
.finish()
}
}
/// These cases are inspired by the IANA HTTP Proxy Error Types:
/// <https://www.iana.org/assignments/http-proxy-status/http-proxy-status.xhtml#table-http-proxy-error-types>
#[derive(Clone)]
pub enum ErrorCode {
DnsTimeout,
DnsError(DnsErrorPayload),
DestinationNotFound,
DestinationUnavailable,
DestinationIpProhibited,
DestinationIpUnroutable,
ConnectionRefused,
ConnectionTerminated,
ConnectionTimeout,
ConnectionReadTimeout,
ConnectionWriteTimeout,
ConnectionLimitReached,
TlsProtocolError,
TlsCertificateError,
TlsAlertReceived(TlsAlertReceivedPayload),
HttpRequestDenied,
HttpRequestLengthRequired,
HttpRequestBodySize(Option<u64>),
HttpRequestMethodInvalid,
HttpRequestUriInvalid,
HttpRequestUriTooLong,
HttpRequestHeaderSectionSize(Option<u32>),
HttpRequestHeaderSize(Option<FieldSizePayload>),
HttpRequestTrailerSectionSize(Option<u32>),
HttpRequestTrailerSize(FieldSizePayload),
HttpResponseIncomplete,
HttpResponseHeaderSectionSize(Option<u32>),
HttpResponseHeaderSize(FieldSizePayload),
HttpResponseBodySize(Option<u64>),
HttpResponseTrailerSectionSize(Option<u32>),
HttpResponseTrailerSize(FieldSizePayload),
HttpResponseTransferCoding(Option<_rt::String>),
HttpResponseContentCoding(Option<_rt::String>),
HttpResponseTimeout,
HttpUpgradeFailed,
HttpProtocolError,
LoopDetected,
ConfigurationError,
/// This is a catch-all error for anything that doesn't fit cleanly into a
/// more specific case. It also includes an optional string for an
/// unstructured description of the error. Users should not depend on the
/// string for diagnosing errors, as it's not required to be consistent
/// between implementations.
InternalError(Option<_rt::String>),
}
impl ::core::fmt::Debug for ErrorCode {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
match self {
ErrorCode::DnsTimeout => {
f.debug_tuple("ErrorCode::DnsTimeout").finish()
}
ErrorCode::DnsError(e) => {
f.debug_tuple("ErrorCode::DnsError").field(e).finish()
}
ErrorCode::DestinationNotFound => {
f.debug_tuple("ErrorCode::DestinationNotFound").finish()
}
ErrorCode::DestinationUnavailable => {
f.debug_tuple("ErrorCode::DestinationUnavailable").finish()
}
ErrorCode::DestinationIpProhibited => {
f.debug_tuple("ErrorCode::DestinationIpProhibited").finish()
}
ErrorCode::DestinationIpUnroutable => {
f.debug_tuple("ErrorCode::DestinationIpUnroutable").finish()
}
ErrorCode::ConnectionRefused => {
f.debug_tuple("ErrorCode::ConnectionRefused").finish()
}
ErrorCode::ConnectionTerminated => {
f.debug_tuple("ErrorCode::ConnectionTerminated").finish()
}
ErrorCode::ConnectionTimeout => {
f.debug_tuple("ErrorCode::ConnectionTimeout").finish()
}
ErrorCode::ConnectionReadTimeout => {
f.debug_tuple("ErrorCode::ConnectionReadTimeout").finish()
}
ErrorCode::ConnectionWriteTimeout => {
f.debug_tuple("ErrorCode::ConnectionWriteTimeout").finish()
}
ErrorCode::ConnectionLimitReached => {
f.debug_tuple("ErrorCode::ConnectionLimitReached").finish()
}
ErrorCode::TlsProtocolError => {
f.debug_tuple("ErrorCode::TlsProtocolError").finish()
}
ErrorCode::TlsCertificateError => {
f.debug_tuple("ErrorCode::TlsCertificateError").finish()
}
ErrorCode::TlsAlertReceived(e) => {
f.debug_tuple("ErrorCode::TlsAlertReceived")
.field(e)
.finish()
}
ErrorCode::HttpRequestDenied => {
f.debug_tuple("ErrorCode::HttpRequestDenied").finish()
}
ErrorCode::HttpRequestLengthRequired => {
f.debug_tuple("ErrorCode::HttpRequestLengthRequired")
.finish()
}
ErrorCode::HttpRequestBodySize(e) => {
f.debug_tuple("ErrorCode::HttpRequestBodySize")
.field(e)
.finish()
}
ErrorCode::HttpRequestMethodInvalid => {
f.debug_tuple("ErrorCode::HttpRequestMethodInvalid").finish()
}
ErrorCode::HttpRequestUriInvalid => {
f.debug_tuple("ErrorCode::HttpRequestUriInvalid").finish()
}
ErrorCode::HttpRequestUriTooLong => {
f.debug_tuple("ErrorCode::HttpRequestUriTooLong").finish()
}
ErrorCode::HttpRequestHeaderSectionSize(e) => {
f.debug_tuple("ErrorCode::HttpRequestHeaderSectionSize")
.field(e)
.finish()
}
ErrorCode::HttpRequestHeaderSize(e) => {
f.debug_tuple("ErrorCode::HttpRequestHeaderSize")
.field(e)
.finish()
}
ErrorCode::HttpRequestTrailerSectionSize(e) => {
f.debug_tuple("ErrorCode::HttpRequestTrailerSectionSize")
.field(e)
.finish()
}
ErrorCode::HttpRequestTrailerSize(e) => {
f.debug_tuple("ErrorCode::HttpRequestTrailerSize")
.field(e)
.finish()
}
ErrorCode::HttpResponseIncomplete => {
f.debug_tuple("ErrorCode::HttpResponseIncomplete").finish()
}
ErrorCode::HttpResponseHeaderSectionSize(e) => {
f.debug_tuple("ErrorCode::HttpResponseHeaderSectionSize")
.field(e)
.finish()
}
ErrorCode::HttpResponseHeaderSize(e) => {
f.debug_tuple("ErrorCode::HttpResponseHeaderSize")
.field(e)
.finish()
}
ErrorCode::HttpResponseBodySize(e) => {
f.debug_tuple("ErrorCode::HttpResponseBodySize")
.field(e)
.finish()
}
ErrorCode::HttpResponseTrailerSectionSize(e) => {
f.debug_tuple("ErrorCode::HttpResponseTrailerSectionSize")
.field(e)
.finish()
}
ErrorCode::HttpResponseTrailerSize(e) => {
f.debug_tuple("ErrorCode::HttpResponseTrailerSize")
.field(e)
.finish()
}
ErrorCode::HttpResponseTransferCoding(e) => {
f.debug_tuple("ErrorCode::HttpResponseTransferCoding")
.field(e)
.finish()
}
ErrorCode::HttpResponseContentCoding(e) => {
f.debug_tuple("ErrorCode::HttpResponseContentCoding")
.field(e)
.finish()
}
ErrorCode::HttpResponseTimeout => {
f.debug_tuple("ErrorCode::HttpResponseTimeout").finish()
}
ErrorCode::HttpUpgradeFailed => {
f.debug_tuple("ErrorCode::HttpUpgradeFailed").finish()
}
ErrorCode::HttpProtocolError => {
f.debug_tuple("ErrorCode::HttpProtocolError").finish()
}
ErrorCode::LoopDetected => {
f.debug_tuple("ErrorCode::LoopDetected").finish()
}
ErrorCode::ConfigurationError => {
f.debug_tuple("ErrorCode::ConfigurationError").finish()
}
ErrorCode::InternalError(e) => {
f.debug_tuple("ErrorCode::InternalError").field(e).finish()
}
}
}
}
impl ::core::fmt::Display for ErrorCode {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
write!(f, "{:?}", self)
}
}
#[cfg(feature = "std")]
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-name` 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-name` was used when trying
/// to set a header in a `fields`.
Forbidden,
/// This error indicates that the operation on the `fields` was not
/// permitted because the fields are immutable.
Immutable,
}
impl ::core::fmt::Debug for HeaderError {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
match self {
HeaderError::InvalidSyntax => {
f.debug_tuple("HeaderError::InvalidSyntax").finish()
}
HeaderError::Forbidden => {
f.debug_tuple("HeaderError::Forbidden").finish()
}
HeaderError::Immutable => {
f.debug_tuple("HeaderError::Immutable").finish()
}
}
}
}
impl ::core::fmt::Display for HeaderError {
fn fmt(
&self,
f: &mut ::core::fmt::Formatter<'_>,
) -> ::core::fmt::Result {
write!(f, "{:?}", self)
}
}
#[cfg(feature = "std")]
impl std::error::Error for HeaderError {}
/// Field keys are always strings.
///
/// Field keys should always be treated as case insensitive by the `fields`
/// resource for the purposes of equality checking.
///
/// # Deprecation
///
/// This type has been deprecated in favor of the `field-name` type.
pub type FieldKey = _rt::String;
/// Field names are always strings.
///
/// Field names should always be treated as case insensitive by the `fields`
/// resource for the purposes of equality checking.
pub type FieldName = FieldKey;
/// 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<u8>;
/// 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
/// 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<Fields>,
}
impl Fields {
#[doc(hidden)]
pub unsafe fn from_handle(handle: u32) -> Self {
Self {
handle: _rt::Resource::from_handle(handle),
}
}
#[doc(hidden)]
pub fn take_handle(&self) -> u32 {
_rt::Resource::take_handle(&self.handle)
}
#[doc(hidden)]
pub fn handle(&self) -> u32 {
_rt::Resource::handle(&self.handle)
}
}
unsafe impl _rt::WasmResource for Fields {
#[inline]
unsafe fn drop(_handle: u32) {
#[cfg(not(target_arch = "wasm32"))]
unreachable!();
#[cfg(target_arch = "wasm32")]
{
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[resource-drop]fields"]
fn drop(_: u32);
}
drop(_handle);
}
}
}
/// Headers is an alias for Fields.
pub type Headers = Fields;
/// Trailers is an alias for Fields.
pub type Trailers = Fields;
/// Represents an incoming HTTP Request.
#[derive(Debug)]
#[repr(transparent)]
pub struct IncomingRequest {
handle: _rt::Resource<IncomingRequest>,
}
impl IncomingRequest {
#[doc(hidden)]
pub unsafe fn from_handle(handle: u32) -> Self {
Self {
handle: _rt::Resource::from_handle(handle),
}
}
#[doc(hidden)]
pub fn take_handle(&self) -> u32 {
_rt::Resource::take_handle(&self.handle)
}
#[doc(hidden)]
pub fn handle(&self) -> u32 {
_rt::Resource::handle(&self.handle)
}
}
unsafe impl _rt::WasmResource for IncomingRequest {
#[inline]
unsafe fn drop(_handle: u32) {
#[cfg(not(target_arch = "wasm32"))]
unreachable!();
#[cfg(target_arch = "wasm32")]
{
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[resource-drop]incoming-request"]
fn drop(_: u32);
}
drop(_handle);
}
}
}
/// Represents an outgoing HTTP Request.
#[derive(Debug)]
#[repr(transparent)]
pub struct OutgoingRequest {
handle: _rt::Resource<OutgoingRequest>,
}
impl OutgoingRequest {
#[doc(hidden)]
pub unsafe fn from_handle(handle: u32) -> Self {
Self {
handle: _rt::Resource::from_handle(handle),
}
}
#[doc(hidden)]
pub fn take_handle(&self) -> u32 {
_rt::Resource::take_handle(&self.handle)
}
#[doc(hidden)]
pub fn handle(&self) -> u32 {
_rt::Resource::handle(&self.handle)
}
}
unsafe impl _rt::WasmResource for OutgoingRequest {
#[inline]
unsafe fn drop(_handle: u32) {
#[cfg(not(target_arch = "wasm32"))]
unreachable!();
#[cfg(target_arch = "wasm32")]
{
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[resource-drop]outgoing-request"]
fn drop(_: u32);
}
drop(_handle);
}
}
}
/// Parameters for making an HTTP Request. Each of these parameters is
/// currently an optional timeout applicable to the transport layer of the
/// HTTP protocol.
///
/// These timeouts are separate from any the user may use to bound a
/// blocking call to `wasi:io/poll.poll`.
#[derive(Debug)]
#[repr(transparent)]
pub struct RequestOptions {
handle: _rt::Resource<RequestOptions>,
}
impl RequestOptions {
#[doc(hidden)]
pub unsafe fn from_handle(handle: u32) -> Self {
Self {
handle: _rt::Resource::from_handle(handle),
}
}
#[doc(hidden)]
pub fn take_handle(&self) -> u32 {
_rt::Resource::take_handle(&self.handle)
}
#[doc(hidden)]
pub fn handle(&self) -> u32 {
_rt::Resource::handle(&self.handle)
}
}
unsafe impl _rt::WasmResource for RequestOptions {
#[inline]
unsafe fn drop(_handle: u32) {
#[cfg(not(target_arch = "wasm32"))]
unreachable!();
#[cfg(target_arch = "wasm32")]
{
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[resource-drop]request-options"]
fn drop(_: u32);
}
drop(_handle);
}
}
}
/// Represents the ability to send an HTTP Response.
///
/// This resource is used by the `wasi:http/incoming-handler` interface to
/// allow a Response to be sent corresponding to the Request provided as the
/// other argument to `incoming-handler.handle`.
#[derive(Debug)]
#[repr(transparent)]
pub struct ResponseOutparam {
handle: _rt::Resource<ResponseOutparam>,
}
impl ResponseOutparam {
#[doc(hidden)]
pub unsafe fn from_handle(handle: u32) -> Self {
Self {
handle: _rt::Resource::from_handle(handle),
}
}
#[doc(hidden)]
pub fn take_handle(&self) -> u32 {
_rt::Resource::take_handle(&self.handle)
}
#[doc(hidden)]
pub fn handle(&self) -> u32 {
_rt::Resource::handle(&self.handle)
}
}
unsafe impl _rt::WasmResource for ResponseOutparam {
#[inline]
unsafe fn drop(_handle: u32) {
#[cfg(not(target_arch = "wasm32"))]
unreachable!();
#[cfg(target_arch = "wasm32")]
{
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[resource-drop]response-outparam"]
fn drop(_: u32);
}
drop(_handle);
}
}
}
/// This type corresponds to the HTTP standard Status Code.
pub type StatusCode = u16;
/// Represents an incoming HTTP Response.
#[derive(Debug)]
#[repr(transparent)]
pub struct IncomingResponse {
handle: _rt::Resource<IncomingResponse>,
}
impl IncomingResponse {
#[doc(hidden)]
pub unsafe fn from_handle(handle: u32) -> Self {
Self {
handle: _rt::Resource::from_handle(handle),
}
}
#[doc(hidden)]
pub fn take_handle(&self) -> u32 {
_rt::Resource::take_handle(&self.handle)
}
#[doc(hidden)]
pub fn handle(&self) -> u32 {
_rt::Resource::handle(&self.handle)
}
}
unsafe impl _rt::WasmResource for IncomingResponse {
#[inline]
unsafe fn drop(_handle: u32) {
#[cfg(not(target_arch = "wasm32"))]
unreachable!();
#[cfg(target_arch = "wasm32")]
{
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[resource-drop]incoming-response"]
fn drop(_: u32);
}
drop(_handle);
}
}
}
/// Represents an incoming HTTP Request or Response's Body.
///
/// A body has both its contents - a stream of bytes - and a (possibly
/// empty) set of trailers, indicating that the full contents of the
/// body have been received. This resource represents the contents as
/// an `input-stream` and the delivery of trailers as a `future-trailers`,
/// and ensures that the user of this interface may only be consuming either
/// the body contents or waiting on trailers at any given time.
#[derive(Debug)]
#[repr(transparent)]
pub struct IncomingBody {
handle: _rt::Resource<IncomingBody>,
}
impl IncomingBody {
#[doc(hidden)]
pub unsafe fn from_handle(handle: u32) -> Self {
Self {
handle: _rt::Resource::from_handle(handle),
}
}
#[doc(hidden)]
pub fn take_handle(&self) -> u32 {
_rt::Resource::take_handle(&self.handle)
}
#[doc(hidden)]
pub fn handle(&self) -> u32 {
_rt::Resource::handle(&self.handle)
}
}
unsafe impl _rt::WasmResource for IncomingBody {
#[inline]
unsafe fn drop(_handle: u32) {
#[cfg(not(target_arch = "wasm32"))]
unreachable!();
#[cfg(target_arch = "wasm32")]
{
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[resource-drop]incoming-body"]
fn drop(_: u32);
}
drop(_handle);
}
}
}
/// Represents a future which may eventually 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<FutureTrailers>,
}
impl FutureTrailers {
#[doc(hidden)]
pub unsafe fn from_handle(handle: u32) -> Self {
Self {
handle: _rt::Resource::from_handle(handle),
}
}
#[doc(hidden)]
pub fn take_handle(&self) -> u32 {
_rt::Resource::take_handle(&self.handle)
}
#[doc(hidden)]
pub fn handle(&self) -> u32 {
_rt::Resource::handle(&self.handle)
}
}
unsafe impl _rt::WasmResource for FutureTrailers {
#[inline]
unsafe fn drop(_handle: u32) {
#[cfg(not(target_arch = "wasm32"))]
unreachable!();
#[cfg(target_arch = "wasm32")]
{
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[resource-drop]future-trailers"]
fn drop(_: u32);
}
drop(_handle);
}
}
}
/// Represents an outgoing HTTP Response.
#[derive(Debug)]
#[repr(transparent)]
pub struct OutgoingResponse {
handle: _rt::Resource<OutgoingResponse>,
}
impl OutgoingResponse {
#[doc(hidden)]
pub unsafe fn from_handle(handle: u32) -> Self {
Self {
handle: _rt::Resource::from_handle(handle),
}
}
#[doc(hidden)]
pub fn take_handle(&self) -> u32 {
_rt::Resource::take_handle(&self.handle)
}
#[doc(hidden)]
pub fn handle(&self) -> u32 {
_rt::Resource::handle(&self.handle)
}
}
unsafe impl _rt::WasmResource for OutgoingResponse {
#[inline]
unsafe fn drop(_handle: u32) {
#[cfg(not(target_arch = "wasm32"))]
unreachable!();
#[cfg(target_arch = "wasm32")]
{
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[resource-drop]outgoing-response"]
fn drop(_: u32);
}
drop(_handle);
}
}
}
/// Represents an outgoing HTTP Request or Response's Body.
///
/// A body has both its contents - a stream of bytes - and a (possibly
/// empty) set of trailers, inducating the full contents of the body
/// have been sent. This resource represents the contents as an
/// `output-stream` child resource, and the completion of the body (with
/// optional trailers) with a static function that consumes the
/// `outgoing-body` resource, and ensures that the user of this interface
/// may not write to the body contents after the body has been finished.
///
/// If the user code drops this resource, as opposed to calling the static
/// method `finish`, the implementation should treat the body as incomplete,
/// and that an error has occurred. The implementation should propagate 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<OutgoingBody>,
}
impl OutgoingBody {
#[doc(hidden)]
pub unsafe fn from_handle(handle: u32) -> Self {
Self {
handle: _rt::Resource::from_handle(handle),
}
}
#[doc(hidden)]
pub fn take_handle(&self) -> u32 {
_rt::Resource::take_handle(&self.handle)
}
#[doc(hidden)]
pub fn handle(&self) -> u32 {
_rt::Resource::handle(&self.handle)
}
}
unsafe impl _rt::WasmResource for OutgoingBody {
#[inline]
unsafe fn drop(_handle: u32) {
#[cfg(not(target_arch = "wasm32"))]
unreachable!();
#[cfg(target_arch = "wasm32")]
{
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[resource-drop]outgoing-body"]
fn drop(_: u32);
}
drop(_handle);
}
}
}
/// Represents a future which may eventually 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<FutureIncomingResponse>,
}
impl FutureIncomingResponse {
#[doc(hidden)]
pub unsafe fn from_handle(handle: u32) -> Self {
Self {
handle: _rt::Resource::from_handle(handle),
}
}
#[doc(hidden)]
pub fn take_handle(&self) -> u32 {
_rt::Resource::take_handle(&self.handle)
}
#[doc(hidden)]
pub fn handle(&self) -> u32 {
_rt::Resource::handle(&self.handle)
}
}
unsafe impl _rt::WasmResource for FutureIncomingResponse {
#[inline]
unsafe fn drop(_handle: u32) {
#[cfg(not(target_arch = "wasm32"))]
unreachable!();
#[cfg(target_arch = "wasm32")]
{
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[resource-drop]future-incoming-response"]
fn drop(_: u32);
}
drop(_handle);
}
}
}
#[allow(unused_unsafe, clippy::all)]
/// Attempts to extract a http-related `error` from the wasi:io `error`
/// provided.
///
/// Stream operations which return
/// `wasi:io/stream/stream-error::last-operation-failed` have a payload of
/// type `wasi:io/error/error` with more information about the operation
/// that failed. This payload can be passed through to this function to see
/// if there's http-related information about the error to return.
///
/// Note that this function is fallible because not all io-errors are
/// http-related errors.
pub fn http_error_code(err: &IoError) -> Option<ErrorCode> {
unsafe {
#[repr(align(8))]
struct RetArea([::core::mem::MaybeUninit<u8>; 40]);
let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "http-error-code"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((err).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result66 = match l2 { 0 => None, 1 => {
let e = {
let l3 = i32::from(*ptr0.add(8).cast::<u8>());
let v65 = match l3 { 0 => ErrorCode::DnsTimeout, 1 => {
let e65 = {
let l4 = i32::from(*ptr0.add(16).cast::<u8>());
let l8 = i32::from(*ptr0.add(28).cast::<u8>());
DnsErrorPayload {
rcode: match l4 { 0 => None, 1 => {
let e = {
let l5 = *ptr0.add(20).cast::<*mut u8>();
let l6 = *ptr0.add(24).cast::<usize>();
let len7 = l6;
let bytes7 = _rt::Vec::from_raw_parts(
l5.cast(),
len7,
len7,
);
_rt::string_lift(bytes7)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
info_code: match l8 { 0 => None, 1 => {
let e = {
let l9 = i32::from(*ptr0.add(30).cast::<u16>());
l9 as u16
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::DnsError(e65)
} 2 => ErrorCode::DestinationNotFound, 3 => ErrorCode::DestinationUnavailable, 4 => ErrorCode::DestinationIpProhibited, 5 => ErrorCode::DestinationIpUnroutable, 6 => ErrorCode::ConnectionRefused, 7 => ErrorCode::ConnectionTerminated, 8 => ErrorCode::ConnectionTimeout, 9 => ErrorCode::ConnectionReadTimeout, 10 => ErrorCode::ConnectionWriteTimeout, 11 => ErrorCode::ConnectionLimitReached, 12 => ErrorCode::TlsProtocolError, 13 => ErrorCode::TlsCertificateError, 14 => {
let e65 = {
let l10 = i32::from(*ptr0.add(16).cast::<u8>());
let l12 = i32::from(*ptr0.add(20).cast::<u8>());
TlsAlertReceivedPayload {
alert_id: match l10 { 0 => None, 1 => {
let e = {
let l11 = i32::from(*ptr0.add(17).cast::<u8>());
l11 as u8
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
alert_message: match l12 { 0 => None, 1 => {
let e = {
let l13 = *ptr0.add(24).cast::<*mut u8>();
let l14 = *ptr0.add(28).cast::<usize>();
let len15 = l14;
let bytes15 = _rt::Vec::from_raw_parts(
l13.cast(),
len15,
len15,
);
_rt::string_lift(bytes15)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::TlsAlertReceived(e65)
} 15 => ErrorCode::HttpRequestDenied, 16 => ErrorCode::HttpRequestLengthRequired, 17 => {
let e65 = {
let l16 = i32::from(*ptr0.add(16).cast::<u8>());
match l16 { 0 => None, 1 => {
let e = {
let l17 = *ptr0.add(24).cast::<i64>();
l17 as u64
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestBodySize(e65)
} 18 => ErrorCode::HttpRequestMethodInvalid, 19 => ErrorCode::HttpRequestUriInvalid, 20 => ErrorCode::HttpRequestUriTooLong, 21 => {
let e65 = {
let l18 = i32::from(*ptr0.add(16).cast::<u8>());
match l18 { 0 => None, 1 => {
let e = {
let l19 = *ptr0.add(20).cast::<i32>();
l19 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestHeaderSectionSize(e65)
} 22 => {
let e65 = {
let l20 = i32::from(*ptr0.add(16).cast::<u8>());
match l20 { 0 => None, 1 => {
let e = {
let l21 = i32::from(*ptr0.add(20).cast::<u8>());
let l25 = i32::from(*ptr0.add(32).cast::<u8>());
FieldSizePayload {
field_name: match l21 { 0 => None, 1 => {
let e = {
let l22 = *ptr0.add(24).cast::<*mut u8>();
let l23 = *ptr0.add(28).cast::<usize>();
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 = *ptr0.add(36).cast::<i32>();
l26 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestHeaderSize(e65)
} 23 => {
let e65 = {
let l27 = i32::from(*ptr0.add(16).cast::<u8>());
match l27 { 0 => None, 1 => {
let e = {
let l28 = *ptr0.add(20).cast::<i32>();
l28 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestTrailerSectionSize(e65)
} 24 => {
let e65 = {
let l29 = i32::from(*ptr0.add(16).cast::<u8>());
let l33 = i32::from(*ptr0.add(28).cast::<u8>());
FieldSizePayload {
field_name: match l29 { 0 => None, 1 => {
let e = {
let l30 = *ptr0.add(20).cast::<*mut u8>();
let l31 = *ptr0.add(24).cast::<usize>();
let len32 = l31;
let bytes32 = _rt::Vec::from_raw_parts(
l30.cast(),
len32,
len32,
);
_rt::string_lift(bytes32)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
field_size: match l33 { 0 => None, 1 => {
let e = {
let l34 = *ptr0.add(32).cast::<i32>();
l34 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::HttpRequestTrailerSize(e65)
} 25 => ErrorCode::HttpResponseIncomplete, 26 => {
let e65 = {
let l35 = i32::from(*ptr0.add(16).cast::<u8>());
match l35 { 0 => None, 1 => {
let e = {
let l36 = *ptr0.add(20).cast::<i32>();
l36 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseHeaderSectionSize(e65)
} 27 => {
let e65 = {
let l37 = i32::from(*ptr0.add(16).cast::<u8>());
let l41 = i32::from(*ptr0.add(28).cast::<u8>());
FieldSizePayload {
field_name: match l37 { 0 => None, 1 => {
let e = {
let l38 = *ptr0.add(20).cast::<*mut u8>();
let l39 = *ptr0.add(24).cast::<usize>();
let len40 = l39;
let bytes40 = _rt::Vec::from_raw_parts(
l38.cast(),
len40,
len40,
);
_rt::string_lift(bytes40)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
field_size: match l41 { 0 => None, 1 => {
let e = {
let l42 = *ptr0.add(32).cast::<i32>();
l42 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::HttpResponseHeaderSize(e65)
} 28 => {
let e65 = {
let l43 = i32::from(*ptr0.add(16).cast::<u8>());
match l43 { 0 => None, 1 => {
let e = {
let l44 = *ptr0.add(24).cast::<i64>();
l44 as u64
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseBodySize(e65)
} 29 => {
let e65 = {
let l45 = i32::from(*ptr0.add(16).cast::<u8>());
match l45 { 0 => None, 1 => {
let e = {
let l46 = *ptr0.add(20).cast::<i32>();
l46 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseTrailerSectionSize(e65)
} 30 => {
let e65 = {
let l47 = i32::from(*ptr0.add(16).cast::<u8>());
let l51 = i32::from(*ptr0.add(28).cast::<u8>());
FieldSizePayload {
field_name: match l47 { 0 => None, 1 => {
let e = {
let l48 = *ptr0.add(20).cast::<*mut u8>();
let l49 = *ptr0.add(24).cast::<usize>();
let len50 = l49;
let bytes50 = _rt::Vec::from_raw_parts(
l48.cast(),
len50,
len50,
);
_rt::string_lift(bytes50)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
field_size: match l51 { 0 => None, 1 => {
let e = {
let l52 = *ptr0.add(32).cast::<i32>();
l52 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::HttpResponseTrailerSize(e65)
} 31 => {
let e65 = {
let l53 = i32::from(*ptr0.add(16).cast::<u8>());
match l53 { 0 => None, 1 => {
let e = {
let l54 = *ptr0.add(20).cast::<*mut u8>();
let l55 = *ptr0.add(24).cast::<usize>();
let len56 = l55;
let bytes56 = _rt::Vec::from_raw_parts(
l54.cast(),
len56,
len56,
);
_rt::string_lift(bytes56)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseTransferCoding(e65)
} 32 => {
let e65 = {
let l57 = i32::from(*ptr0.add(16).cast::<u8>());
match l57 { 0 => None, 1 => {
let e = {
let l58 = *ptr0.add(20).cast::<*mut u8>();
let l59 = *ptr0.add(24).cast::<usize>();
let len60 = l59;
let bytes60 = _rt::Vec::from_raw_parts(
l58.cast(),
len60,
len60,
);
_rt::string_lift(bytes60)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseContentCoding(e65)
} 33 => ErrorCode::HttpResponseTimeout, 34 => ErrorCode::HttpUpgradeFailed, 35 => ErrorCode::HttpProtocolError, 36 => ErrorCode::LoopDetected, 37 => ErrorCode::ConfigurationError,
n => {
debug_assert_eq!(n, 38, "invalid enum discriminant");
let e65 = {
let l61 = i32::from(*ptr0.add(16).cast::<u8>());
match l61 { 0 => None, 1 => {
let e = {
let l62 = *ptr0.add(20).cast::<*mut u8>();
let l63 = *ptr0.add(24).cast::<usize>();
let len64 = l63;
let bytes64 = _rt::Vec::from_raw_parts(
l62.cast(),
len64,
len64,
);
_rt::string_lift(bytes64)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::InternalError(e65)
}
};
v65
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result66
}
}
impl Fields {
#[allow(unused_unsafe, clippy::all)]
/// Construct an empty HTTP Fields.
///
/// The resulting `fields` is mutable.
pub fn new() -> Self {
unsafe {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[constructor]fields"]
fn wit_import0() -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import0() -> i32 {
unreachable!()
}
let ret = wit_import0();
Fields::from_handle(ret as u32)
}
}
}
impl Fields {
#[allow(unused_unsafe, clippy::all)]
/// Construct an HTTP Fields.
///
/// The resulting `fields` is mutable.
///
/// The list represents each name-value pair in the Fields. Names
/// which have multiple values are represented by multiple entries in this
/// list with the same name.
///
/// The tuple is a pair of the field name, represented as a string, and
/// Value, represented as a list of bytes.
///
/// An error result will be returned if any `field-name` or `field-value` is
/// syntactically invalid, or if a field is forbidden.
pub fn from_list(
entries: &[(FieldName, FieldValue)],
) -> Result<Fields, HeaderError> {
unsafe {
#[repr(align(4))]
struct RetArea([::core::mem::MaybeUninit<u8>; 8]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 8],
);
let vec3 = entries;
let len3 = vec3.len();
let layout3 = _rt::alloc::Layout::from_size_align_unchecked(
vec3.len() * 16, 4,
);
let result3 = if layout3.size() != 0 {
let ptr = _rt::alloc::alloc(layout3).cast::<u8>();
if ptr.is_null() {
_rt::alloc::handle_alloc_error(layout3);
}
ptr
} else {
::core::ptr::null_mut()
};
for (i, e) in vec3.into_iter().enumerate() {
let base = result3.add(i * 16);
{
let (t0_0, t0_1) = e;
let vec1 = t0_0;
let ptr1 = vec1.as_ptr().cast::<u8>();
let len1 = vec1.len();
*base.add(4).cast::<usize>() = len1;
*base.add(0).cast::<*mut u8>() = ptr1.cast_mut();
let vec2 = t0_1;
let ptr2 = vec2.as_ptr().cast::<u8>();
let len2 = vec2.len();
*base.add(12).cast::<usize>() = len2;
*base.add(8).cast::<*mut u8>() = ptr2.cast_mut();
}
}
let ptr4 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[static]fields.from-list"]
fn wit_import5(_: *mut u8, _: usize, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import5(_: *mut u8, _: usize, _: *mut u8) {
unreachable!()
}
wit_import5(result3, len3, ptr4);
let l6 = i32::from(*ptr4.add(0).cast::<u8>());
let result10 = match l6 { 0 => {
let e = {
let l7 = *ptr4.add(4).cast::<i32>();
Fields::from_handle(l7 as u32)
};
Ok(e)
} 1 => {
let e = {
let l8 = i32::from(*ptr4.add(4).cast::<u8>());
let v9 = match l8 { 0 => HeaderError::InvalidSyntax, 1 => HeaderError::Forbidden,
n => {
debug_assert_eq!(n, 2, "invalid enum discriminant");
HeaderError::Immutable
}
};
v9
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
if layout3.size() != 0 {
_rt::alloc::dealloc(result3.cast(), layout3);
}
result10
}
}
}
impl Fields {
#[allow(unused_unsafe, clippy::all)]
/// Get all of the values corresponding to a name. If the name is not present
/// in this `fields` or is syntactically invalid, an empty list is returned.
/// However, if the name is present but empty, this is represented by a list
/// with one or more empty field-values present.
pub fn get(&self, name: &str) -> _rt::Vec<FieldValue> {
unsafe {
#[repr(align(4))]
struct RetArea([::core::mem::MaybeUninit<u8>; 8]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 8],
);
let vec0 = name;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]fields.get"]
fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import2(
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
) {
unreachable!()
}
wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1);
let l3 = *ptr1.add(0).cast::<*mut u8>();
let l4 = *ptr1.add(4).cast::<usize>();
let base8 = l3;
let len8 = l4;
let mut result8 = _rt::Vec::with_capacity(len8);
for i in 0..len8 {
let base = base8.add(i * 8);
let e8 = {
let l5 = *base.add(0).cast::<*mut u8>();
let l6 = *base.add(4).cast::<usize>();
let len7 = l6;
_rt::Vec::from_raw_parts(l5.cast(), len7, len7)
};
result8.push(e8);
}
_rt::cabi_dealloc(base8, len8 * 8, 4);
let result9 = result8;
result9
}
}
}
impl Fields {
#[allow(unused_unsafe, clippy::all)]
/// Returns `true` when the name is present in this `fields`. If the name is
/// syntactically invalid, `false` is returned.
pub fn has(&self, name: &str) -> bool {
unsafe {
let vec0 = name;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]fields.has"]
fn wit_import1(_: i32, _: *mut u8, _: usize) -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8, _: usize) -> i32 {
unreachable!()
}
let ret = wit_import1(
(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 name. Clears any existing values for that
/// name, if they have been set.
///
/// Fails with `header-error.immutable` if the `fields` are immutable.
///
/// Fails with `header-error.invalid-syntax` if the `field-name` or any of
/// the `field-value`s are syntactically invalid.
pub fn set(
&self,
name: &str,
value: &[FieldValue],
) -> Result<(), HeaderError> {
unsafe {
#[repr(align(1))]
struct RetArea([::core::mem::MaybeUninit<u8>; 2]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 2],
);
let vec0 = name;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
let vec2 = value;
let len2 = vec2.len();
let layout2 = _rt::alloc::Layout::from_size_align_unchecked(
vec2.len() * 8, 4,
);
let result2 = if layout2.size() != 0 {
let ptr = _rt::alloc::alloc(layout2).cast::<u8>();
if ptr.is_null() {
_rt::alloc::handle_alloc_error(layout2);
}
ptr
} else {
::core::ptr::null_mut()
};
for (i, e) in vec2.into_iter().enumerate() {
let base = result2.add(i * 8);
{
let vec1 = e;
let ptr1 = vec1.as_ptr().cast::<u8>();
let len1 = vec1.len();
*base.add(4).cast::<usize>() = len1;
*base.add(0).cast::<*mut u8>() = ptr1.cast_mut();
}
}
let ptr3 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]fields.set"]
fn wit_import4(
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
_: usize,
_: *mut u8,
);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import4(
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
_: usize,
_: *mut u8,
) {
unreachable!()
}
wit_import4(
(self).handle() as i32,
ptr0.cast_mut(),
len0,
result2,
len2,
ptr3,
);
let l5 = i32::from(*ptr3.add(0).cast::<u8>());
let result8 = match l5 { 0 => {
let e = ();
Ok(e)
} 1 => {
let e = {
let l6 = i32::from(*ptr3.add(1).cast::<u8>());
let v7 = match l6 { 0 => HeaderError::InvalidSyntax, 1 => HeaderError::Forbidden,
n => {
debug_assert_eq!(n, 2, "invalid enum discriminant");
HeaderError::Immutable
}
};
v7
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
if layout2.size() != 0 {
_rt::alloc::dealloc(result2.cast(), layout2);
}
result8
}
}
}
impl Fields {
#[allow(unused_unsafe, clippy::all)]
/// Delete all values for a name. Does nothing if no values for the name
/// exist.
///
/// Fails with `header-error.immutable` if the `fields` are immutable.
///
/// Fails with `header-error.invalid-syntax` if the `field-name` is
/// syntactically invalid.
pub fn delete(&self, name: &str) -> Result<(), HeaderError> {
unsafe {
#[repr(align(1))]
struct RetArea([::core::mem::MaybeUninit<u8>; 2]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 2],
);
let vec0 = name;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]fields.delete"]
fn wit_import2(_: i32, _: *mut u8, _: usize, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import2(
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
) {
unreachable!()
}
wit_import2((self).handle() as i32, ptr0.cast_mut(), len0, ptr1);
let l3 = i32::from(*ptr1.add(0).cast::<u8>());
let result6 = match l3 { 0 => {
let e = ();
Ok(e)
} 1 => {
let e = {
let l4 = i32::from(*ptr1.add(1).cast::<u8>());
let v5 = match l4 { 0 => HeaderError::InvalidSyntax, 1 => HeaderError::Forbidden,
n => {
debug_assert_eq!(n, 2, "invalid enum discriminant");
HeaderError::Immutable
}
};
v5
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result6
}
}
}
impl Fields {
#[allow(unused_unsafe, clippy::all)]
/// Append a value for a name. Does not change or delete any existing
/// values for that name.
///
/// Fails with `header-error.immutable` if the `fields` are immutable.
///
/// Fails with `header-error.invalid-syntax` if the `field-name` or
/// `field-value` are syntactically invalid.
pub fn append(
&self,
name: &str,
value: &[u8],
) -> Result<(), HeaderError> {
unsafe {
#[repr(align(1))]
struct RetArea([::core::mem::MaybeUninit<u8>; 2]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 2],
);
let vec0 = name;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
let vec1 = value;
let ptr1 = vec1.as_ptr().cast::<u8>();
let len1 = vec1.len();
let ptr2 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]fields.append"]
fn wit_import3(
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
_: usize,
_: *mut u8,
);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import3(
_: i32,
_: *mut u8,
_: usize,
_: *mut u8,
_: usize,
_: *mut u8,
) {
unreachable!()
}
wit_import3(
(self).handle() as i32,
ptr0.cast_mut(),
len0,
ptr1.cast_mut(),
len1,
ptr2,
);
let l4 = i32::from(*ptr2.add(0).cast::<u8>());
let result7 = match l4 { 0 => {
let e = ();
Ok(e)
} 1 => {
let e = {
let l5 = i32::from(*ptr2.add(1).cast::<u8>());
let v6 = match l5 { 0 => HeaderError::InvalidSyntax, 1 => HeaderError::Forbidden,
n => {
debug_assert_eq!(n, 2, "invalid enum discriminant");
HeaderError::Immutable
}
};
v6
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result7
}
}
}
impl Fields {
#[allow(unused_unsafe, clippy::all)]
/// Retrieve the full set of names and values in the Fields. Like the
/// constructor, the list represents each name-value pair.
///
/// The outer list represents each name-value pair in the Fields. Names
/// which have multiple values are represented by multiple entries in this
/// list with the same name.
///
/// The names and values are always returned in the original casing and in
/// the order in which they will be serialized for transport.
pub fn entries(&self) -> _rt::Vec<(FieldName, FieldValue)> {
unsafe {
#[repr(align(4))]
struct RetArea([::core::mem::MaybeUninit<u8>; 8]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 8],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]fields.entries"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = *ptr0.add(0).cast::<*mut u8>();
let l3 = *ptr0.add(4).cast::<usize>();
let base10 = l2;
let len10 = l3;
let mut result10 = _rt::Vec::with_capacity(len10);
for i in 0..len10 {
let base = base10.add(i * 16);
let e10 = {
let l4 = *base.add(0).cast::<*mut u8>();
let l5 = *base.add(4).cast::<usize>();
let len6 = l5;
let bytes6 = _rt::Vec::from_raw_parts(
l4.cast(),
len6,
len6,
);
let l7 = *base.add(8).cast::<*mut u8>();
let l8 = *base.add(12).cast::<usize>();
let len9 = l8;
(
_rt::string_lift(bytes6),
_rt::Vec::from_raw_parts(l7.cast(), len9, len9),
)
};
result10.push(e10);
}
_rt::cabi_dealloc(base10, len10 * 16, 4);
let result11 = result10;
result11
}
}
}
impl Fields {
#[allow(unused_unsafe, clippy::all)]
/// Make a deep copy of the Fields. Equivalent in behavior to calling the
/// `fields` constructor on the return value of `entries`. The resulting
/// `fields` is mutable.
pub fn clone(&self) -> Fields {
unsafe {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]fields.clone"]
fn wit_import0(_: i32) -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import0(_: i32) -> i32 {
unreachable!()
}
let ret = wit_import0((self).handle() as i32);
Fields::from_handle(ret as u32)
}
}
}
impl IncomingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Returns the method of the incoming request.
pub fn method(&self) -> Method {
unsafe {
#[repr(align(4))]
struct RetArea([::core::mem::MaybeUninit<u8>; 12]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 12],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]incoming-request.method"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let v6 = match l2 { 0 => Method::Get, 1 => Method::Head, 2 => Method::Post, 3 => Method::Put, 4 => Method::Delete, 5 => Method::Connect, 6 => Method::Options, 7 => Method::Trace, 8 => Method::Patch,
n => {
debug_assert_eq!(n, 9, "invalid enum discriminant");
let e6 = {
let l3 = *ptr0.add(4).cast::<*mut u8>();
let l4 = *ptr0.add(8).cast::<usize>();
let len5 = l4;
let bytes5 = _rt::Vec::from_raw_parts(
l3.cast(),
len5,
len5,
);
_rt::string_lift(bytes5)
};
Method::Other(e6)
}
};
let result7 = v6;
result7
}
}
}
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<u8>; 12]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 12],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]incoming-request.path-with-query"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result6 = match l2 { 0 => None, 1 => {
let e = {
let l3 = *ptr0.add(4).cast::<*mut u8>();
let l4 = *ptr0.add(8).cast::<usize>();
let len5 = l4;
let bytes5 = _rt::Vec::from_raw_parts(
l3.cast(),
len5,
len5,
);
_rt::string_lift(bytes5)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result6
}
}
}
impl IncomingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Returns the protocol scheme from the request.
pub fn scheme(&self) -> Option<Scheme> {
unsafe {
#[repr(align(4))]
struct RetArea([::core::mem::MaybeUninit<u8>; 16]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 16],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]incoming-request.scheme"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result8 = match l2 { 0 => None, 1 => {
let e = {
let l3 = i32::from(*ptr0.add(4).cast::<u8>());
let v7 = match l3 { 0 => Scheme::Http, 1 => Scheme::Https,
n => {
debug_assert_eq!(n, 2, "invalid enum discriminant");
let e7 = {
let l4 = *ptr0.add(8).cast::<*mut u8>();
let l5 = *ptr0.add(12).cast::<usize>();
let len6 = l5;
let bytes6 = _rt::Vec::from_raw_parts(
l4.cast(),
len6,
len6,
);
_rt::string_lift(bytes6)
};
Scheme::Other(e7)
}
};
v7
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result8
}
}
}
impl IncomingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Returns the authority of the Request's target URI, if present.
pub fn authority(&self) -> Option<_rt::String> {
unsafe {
#[repr(align(4))]
struct RetArea([::core::mem::MaybeUninit<u8>; 12]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 12],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]incoming-request.authority"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result6 = match l2 { 0 => None, 1 => {
let e = {
let l3 = *ptr0.add(4).cast::<*mut u8>();
let l4 = *ptr0.add(8).cast::<usize>();
let len5 = l4;
let bytes5 = _rt::Vec::from_raw_parts(
l3.cast(),
len5,
len5,
);
_rt::string_lift(bytes5)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result6
}
}
}
impl IncomingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Get the `headers` associated with the request.
///
/// The returned `headers` resource is immutable: `set`, `append`, and
/// `delete` operations will fail with `header-error.immutable`.
///
/// The `headers` returned are a child resource: it must be dropped before
/// the parent `incoming-request` is dropped. Dropping this
/// `incoming-request` before all children are dropped will trap.
pub fn headers(&self) -> Headers {
unsafe {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]incoming-request.headers"]
fn wit_import0(_: i32) -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import0(_: i32) -> i32 {
unreachable!()
}
let ret = wit_import0((self).handle() as i32);
Fields::from_handle(ret as u32)
}
}
}
impl IncomingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Gives the `incoming-body` associated with this request. Will only
/// return success at most once, and subsequent calls will return error.
pub fn consume(&self) -> Result<IncomingBody, ()> {
unsafe {
#[repr(align(4))]
struct RetArea([::core::mem::MaybeUninit<u8>; 8]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 8],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]incoming-request.consume"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result4 = match l2 { 0 => {
let e = {
let l3 = *ptr0.add(4).cast::<i32>();
IncomingBody::from_handle(l3 as u32)
};
Ok(e)
} 1 => {
let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
}
impl OutgoingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Construct a new `outgoing-request` with a default `method` of `GET`, and
/// `none` values for `path-with-query`, `scheme`, and `authority`.
///
/// * `headers` is the HTTP Headers for the Request.
///
/// It is possible to construct, or manipulate with the accessor functions
/// below, an `outgoing-request` with an invalid combination of `scheme`
/// and `authority`, or `headers` which are not permitted to be sent.
/// It is the obligation of the `outgoing-handler.handle` implementation
/// to reject invalid constructions of `outgoing-request`.
pub fn new(headers: Headers) -> Self {
unsafe {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[constructor]outgoing-request"]
fn wit_import0(_: i32) -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import0(_: i32) -> i32 {
unreachable!()
}
let ret = wit_import0((&headers).take_handle() as i32);
OutgoingRequest::from_handle(ret as u32)
}
}
}
impl OutgoingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Returns the resource corresponding to the outgoing Body for this
/// Request.
///
/// Returns success on the first call: the `outgoing-body` resource for
/// this `outgoing-request` can be retrieved at most once. Subsequent
/// calls will return error.
pub fn body(&self) -> Result<OutgoingBody, ()> {
unsafe {
#[repr(align(4))]
struct RetArea([::core::mem::MaybeUninit<u8>; 8]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 8],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]outgoing-request.body"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result4 = match l2 { 0 => {
let e = {
let l3 = *ptr0.add(4).cast::<i32>();
OutgoingBody::from_handle(l3 as u32)
};
Ok(e)
} 1 => {
let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
}
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<u8>; 12]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 12],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]outgoing-request.method"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let v6 = match l2 { 0 => Method::Get, 1 => Method::Head, 2 => Method::Post, 3 => Method::Put, 4 => Method::Delete, 5 => Method::Connect, 6 => Method::Options, 7 => Method::Trace, 8 => Method::Patch,
n => {
debug_assert_eq!(n, 9, "invalid enum discriminant");
let e6 = {
let l3 = *ptr0.add(4).cast::<*mut u8>();
let l4 = *ptr0.add(8).cast::<usize>();
let len5 = l4;
let bytes5 = _rt::Vec::from_raw_parts(
l3.cast(),
len5,
len5,
);
_rt::string_lift(bytes5)
};
Method::Other(e6)
}
};
let result7 = v6;
result7
}
}
}
impl OutgoingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Set the Method for the Request. Fails if the string present in a
/// `method.other` argument is not a syntactically valid method.
pub fn set_method(&self, method: &Method) -> Result<(), ()> {
unsafe {
let (result1_0, result1_1, result1_2) = match method {
Method::Get => (0i32, ::core::ptr::null_mut(), 0usize),
Method::Head => (1i32, ::core::ptr::null_mut(), 0usize),
Method::Post => (2i32, ::core::ptr::null_mut(), 0usize),
Method::Put => (3i32, ::core::ptr::null_mut(), 0usize),
Method::Delete => (4i32, ::core::ptr::null_mut(), 0usize),
Method::Connect => (5i32, ::core::ptr::null_mut(), 0usize),
Method::Options => (6i32, ::core::ptr::null_mut(), 0usize),
Method::Trace => (7i32, ::core::ptr::null_mut(), 0usize),
Method::Patch => (8i32, ::core::ptr::null_mut(), 0usize),
Method::Other(e) => {
let vec0 = e;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
(9i32, ptr0.cast_mut(), len0)
}
};
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]outgoing-request.set-method"]
fn wit_import2(_: i32, _: i32, _: *mut u8, _: usize) -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import2(
_: i32,
_: i32,
_: *mut u8,
_: usize,
) -> i32 {
unreachable!()
}
let ret = wit_import2(
(self).handle() as i32,
result1_0,
result1_1,
result1_2,
);
match ret { 0 => {
let e = ();
Ok(e)
} 1 => {
let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
}
}
}
}
impl OutgoingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Get the combination of the HTTP Path and Query for the Request.
/// When `none`, this represents an empty Path and empty Query.
pub fn path_with_query(&self) -> Option<_rt::String> {
unsafe {
#[repr(align(4))]
struct RetArea([::core::mem::MaybeUninit<u8>; 12]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 12],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]outgoing-request.path-with-query"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result6 = match l2 { 0 => None, 1 => {
let e = {
let l3 = *ptr0.add(4).cast::<*mut u8>();
let l4 = *ptr0.add(8).cast::<usize>();
let len5 = l4;
let bytes5 = _rt::Vec::from_raw_parts(
l3.cast(),
len5,
len5,
);
_rt::string_lift(bytes5)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result6
}
}
}
impl OutgoingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Set the combination of the HTTP Path and Query for the Request.
/// When `none`, this represents an empty Path and empty Query. Fails is the
/// string given is not a syntactically valid path and query uri component.
pub fn set_path_with_query(
&self,
path_with_query: Option<&str>,
) -> Result<(), ()> {
unsafe {
let (result1_0, result1_1, result1_2) = match path_with_query {
Some(e) => {
let vec0 = e;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
(1i32, ptr0.cast_mut(), len0)
}
None => (0i32, ::core::ptr::null_mut(), 0usize),
};
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]outgoing-request.set-path-with-query"]
fn wit_import2(_: i32, _: i32, _: *mut u8, _: usize) -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import2(
_: i32,
_: i32,
_: *mut u8,
_: usize,
) -> i32 {
unreachable!()
}
let ret = wit_import2(
(self).handle() as i32,
result1_0,
result1_1,
result1_2,
);
match ret { 0 => {
let e = ();
Ok(e)
} 1 => {
let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
}
}
}
}
impl OutgoingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Get the HTTP Related Scheme for the Request. When `none`, the
/// implementation may choose an appropriate default scheme.
pub fn scheme(&self) -> Option<Scheme> {
unsafe {
#[repr(align(4))]
struct RetArea([::core::mem::MaybeUninit<u8>; 16]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 16],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]outgoing-request.scheme"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result8 = match l2 { 0 => None, 1 => {
let e = {
let l3 = i32::from(*ptr0.add(4).cast::<u8>());
let v7 = match l3 { 0 => Scheme::Http, 1 => Scheme::Https,
n => {
debug_assert_eq!(n, 2, "invalid enum discriminant");
let e7 = {
let l4 = *ptr0.add(8).cast::<*mut u8>();
let l5 = *ptr0.add(12).cast::<usize>();
let len6 = l5;
let bytes6 = _rt::Vec::from_raw_parts(
l4.cast(),
len6,
len6,
);
_rt::string_lift(bytes6)
};
Scheme::Other(e7)
}
};
v7
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result8
}
}
}
impl OutgoingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Set the HTTP Related Scheme for the Request. When `none`, the
/// implementation may choose an appropriate default scheme. Fails if the
/// string given is not a syntactically valid uri scheme.
pub fn set_scheme(&self, scheme: Option<&Scheme>) -> Result<(), ()> {
unsafe {
let (result2_0, result2_1, result2_2, result2_3) = match scheme {
Some(e) => {
let (result1_0, result1_1, result1_2) = match e {
Scheme::Http => (0i32, ::core::ptr::null_mut(), 0usize),
Scheme::Https => (1i32, ::core::ptr::null_mut(), 0usize),
Scheme::Other(e) => {
let vec0 = e;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
(2i32, ptr0.cast_mut(), len0)
}
};
(1i32, result1_0, result1_1, result1_2)
}
None => (0i32, 0i32, ::core::ptr::null_mut(), 0usize),
};
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]outgoing-request.set-scheme"]
fn wit_import3(
_: i32,
_: i32,
_: i32,
_: *mut u8,
_: usize,
) -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import3(
_: i32,
_: i32,
_: i32,
_: *mut u8,
_: usize,
) -> i32 {
unreachable!()
}
let ret = wit_import3(
(self).handle() as i32,
result2_0,
result2_1,
result2_2,
result2_3,
);
match ret { 0 => {
let e = ();
Ok(e)
} 1 => {
let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
}
}
}
}
impl OutgoingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Get the authority of the Request's target URI. 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<u8>; 12]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 12],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]outgoing-request.authority"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result6 = match l2 { 0 => None, 1 => {
let e = {
let l3 = *ptr0.add(4).cast::<*mut u8>();
let l4 = *ptr0.add(8).cast::<usize>();
let len5 = l4;
let bytes5 = _rt::Vec::from_raw_parts(
l3.cast(),
len5,
len5,
);
_rt::string_lift(bytes5)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result6
}
}
}
impl OutgoingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Set the authority of the Request's target URI. A value of `none` may be used
/// with Related Schemes which do not require an authority. The HTTP and
/// HTTPS schemes always require an authority. Fails if the string given is
/// not a syntactically valid URI authority.
pub fn set_authority(&self, authority: Option<&str>) -> Result<(), ()> {
unsafe {
let (result1_0, result1_1, result1_2) = match authority {
Some(e) => {
let vec0 = e;
let ptr0 = vec0.as_ptr().cast::<u8>();
let len0 = vec0.len();
(1i32, ptr0.cast_mut(), len0)
}
None => (0i32, ::core::ptr::null_mut(), 0usize),
};
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]outgoing-request.set-authority"]
fn wit_import2(_: i32, _: i32, _: *mut u8, _: usize) -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import2(
_: i32,
_: i32,
_: *mut u8,
_: usize,
) -> i32 {
unreachable!()
}
let ret = wit_import2(
(self).handle() as i32,
result1_0,
result1_1,
result1_2,
);
match ret { 0 => {
let e = ();
Ok(e)
} 1 => {
let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
}
}
}
}
impl OutgoingRequest {
#[allow(unused_unsafe, clippy::all)]
/// Get the headers associated with the Request.
///
/// The returned `headers` resource is immutable: `set`, `append`, and
/// `delete` operations will fail with `header-error.immutable`.
///
/// This headers resource is a child: it must be dropped before the parent
/// `outgoing-request` is dropped, or its ownership is transferred to
/// another component by e.g. `outgoing-handler.handle`.
pub fn headers(&self) -> Headers {
unsafe {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]outgoing-request.headers"]
fn wit_import0(_: i32) -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import0(_: i32) -> i32 {
unreachable!()
}
let ret = wit_import0((self).handle() as i32);
Fields::from_handle(ret as u32)
}
}
}
impl RequestOptions {
#[allow(unused_unsafe, clippy::all)]
/// Construct a default `request-options` value.
pub fn new() -> Self {
unsafe {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[constructor]request-options"]
fn wit_import0() -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import0() -> i32 {
unreachable!()
}
let ret = wit_import0();
RequestOptions::from_handle(ret as u32)
}
}
}
impl RequestOptions {
#[allow(unused_unsafe, clippy::all)]
/// The timeout for the initial connect to the HTTP Server.
pub fn connect_timeout(&self) -> Option<Duration> {
unsafe {
#[repr(align(8))]
struct RetArea([::core::mem::MaybeUninit<u8>; 16]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 16],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]request-options.connect-timeout"]
fn wit_import1(_: i32, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result4 = match l2 { 0 => None, 1 => { let e = { let l3 = *ptr0.add(8).cast::<i64>();
l3 as u64
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
} impl RequestOptions { #[allow(unused_unsafe, clippy::all)] /// Set the timeout for the initial connect to the HTTP Server. An error /// return value indicates that this timeout is not supported. pub fn set_connect_timeout(
&self,
duration: Option<Duration>,
) -> Result<(), ()> { unsafe { let (result0_0, result0_1) = match duration {
Some(e) => (1i32, _rt::as_i64(e)),
None => (0i32, 0i64),
}; #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]request-options.set-connect-timeout"]
fn wit_import1(_: i32, _: i32, _: i64) -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: i32, _: i64) -> i32 {
unreachable!()
} let ret = wit_import1(
(self).handle() as i32,
result0_0,
result0_1,
); match ret { 0 => { let e = ();
Ok(e)
} 1 => { let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
}
}
}
} impl RequestOptions { #[allow(unused_unsafe, clippy::all)] /// The timeout for receiving the first byte of the Response body. pub fn first_byte_timeout(&self) -> Option<Duration> { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit<u8>; 16]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 16],
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]request-options.first-byte-timeout"]
fn wit_import1(_: i32, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result4 = match l2 { 0 => None, 1 => { let e = { let l3 = *ptr0.add(8).cast::<i64>();
l3 as u64
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
} impl RequestOptions { #[allow(unused_unsafe, clippy::all)] /// Set the timeout for receiving the first byte of the Response body. An /// error return value indicates that this timeout is not supported. pub fn set_first_byte_timeout(
&self,
duration: Option<Duration>,
) -> Result<(), ()> { unsafe { let (result0_0, result0_1) = match duration {
Some(e) => (1i32, _rt::as_i64(e)),
None => (0i32, 0i64),
}; #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]request-options.set-first-byte-timeout"]
fn wit_import1(_: i32, _: i32, _: i64) -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: i32, _: i64) -> i32 {
unreachable!()
} let ret = wit_import1(
(self).handle() as i32,
result0_0,
result0_1,
); match ret { 0 => { let e = ();
Ok(e)
} 1 => { let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
}
}
}
} impl RequestOptions { #[allow(unused_unsafe, clippy::all)] /// The timeout for receiving subsequent chunks of bytes in the Response /// body stream. pub fn between_bytes_timeout(&self) -> Option<Duration> { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit<u8>; 16]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 16],
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]request-options.between-bytes-timeout"]
fn wit_import1(_: i32, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result4 = match l2 { 0 => None, 1 => { let e = { let l3 = *ptr0.add(8).cast::<i64>();
l3 as u64
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
} 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<Duration>,
) -> Result<(), ()> { unsafe { let (result0_0, result0_1) = match duration {
Some(e) => (1i32, _rt::as_i64(e)),
None => (0i32, 0i64),
}; #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]request-options.set-between-bytes-timeout"]
fn wit_import1(_: i32, _: i32, _: i64) -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: i32, _: i64) -> i32 {
unreachable!()
} let ret = wit_import1(
(self).handle() as i32,
result0_0,
result0_1,
); match ret { 0 => { let e = ();
Ok(e)
} 1 => { let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
}
}
}
} impl ResponseOutparam { #[allow(unused_unsafe, clippy::all)] /// Set the value of the `response-outparam` to either send a response, /// or indicate an error. /// /// This method consumes the `response-outparam` to ensure that it is /// called at most once. If it is never called, the implementation /// will respond with an error. /// /// The user may provide an `error` to `response` to allow the /// implementation determine how to respond with an HTTP error response. pub fn set(
param: ResponseOutparam,
response: Result<OutgoingResponse, ErrorCode>,
) -> () { unsafe { let (
result38_0,
result38_1,
result38_2,
result38_3,
result38_4,
result38_5,
result38_6,
result38_7,
) = match &response {
Ok(e) => {
( 0i32,
(e).take_handle() as i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
Err(e) => { let (
result37_0,
result37_1,
result37_2,
result37_3,
result37_4,
result37_5,
result37_6,
) = match e {
ErrorCode::DnsTimeout => {
( 0i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::DnsError(e) => { let DnsErrorPayload {
rcode: rcode0,
info_code: info_code0,
} = e; let (result2_0, result2_1, result2_2) = match rcode0 {
Some(e) => { let vec1 = e; let ptr1 = vec1.as_ptr().cast::<u8>(); let len1 = vec1.len();
(1i32, ptr1.cast_mut(), len1)
}
None => (0i32, ::core::ptr::null_mut(), 0usize),
}; let (result3_0, result3_1) = match info_code0 {
Some(e) => (1i32, _rt::as_i32(e)),
None => (0i32, 0i32),
};
( 1i32,
result2_0,
{ letmut t = ::core::mem::MaybeUninit::<u64>::uninit();
t.as_mut_ptr().cast::<*mut u8>().write(result2_1);
t
},
result2_2 as *mut u8,
result3_0 as *mut u8,
result3_1 as usize, 0i32,
)
}
ErrorCode::DestinationNotFound => {
( 2i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::DestinationUnavailable => {
( 3i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::DestinationIpProhibited => {
( 4i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::DestinationIpUnroutable => {
( 5i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::ConnectionRefused => {
( 6i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::ConnectionTerminated => {
( 7i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::ConnectionTimeout => {
( 8i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::ConnectionReadTimeout => {
( 9i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::ConnectionWriteTimeout => {
( 10i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::ConnectionLimitReached => {
( 11i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::TlsProtocolError => {
( 12i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::TlsCertificateError => {
( 13i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::TlsAlertReceived(e) => { let TlsAlertReceivedPayload {
alert_id: alert_id4,
alert_message: alert_message4,
} = e; let (result5_0, result5_1) = match alert_id4 {
Some(e) => (1i32, _rt::as_i32(e)),
None => (0i32, 0i32),
}; let (result7_0, result7_1, result7_2) = match alert_message4 {
Some(e) => { let vec6 = e; let ptr6 = vec6.as_ptr().cast::<u8>(); let len6 = vec6.len();
(1i32, ptr6.cast_mut(), len6)
}
None => (0i32, ::core::ptr::null_mut(), 0usize),
};
( 14i32,
result5_0,
::core::mem::MaybeUninit::new(i64::from(result5_1) as u64),
result7_0 as *mut u8,
result7_1,
result7_2, 0i32,
)
}
ErrorCode::HttpRequestDenied => {
( 15i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpRequestLengthRequired => {
( 16i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpRequestBodySize(e) => { let (result8_0, result8_1) = match e {
Some(e) => (1i32, _rt::as_i64(e)),
None => (0i32, 0i64),
};
( 17i32,
result8_0,
::core::mem::MaybeUninit::new(result8_1 as u64),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpRequestMethodInvalid => {
( 18i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpRequestUriInvalid => {
( 19i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpRequestUriTooLong => {
( 20i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpRequestHeaderSectionSize(e) => { let (result9_0, result9_1) = match e {
Some(e) => (1i32, _rt::as_i32(e)),
None => (0i32, 0i32),
};
( 21i32,
result9_0,
::core::mem::MaybeUninit::new(i64::from(result9_1) as u64),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpRequestHeaderSize(e) => { let (
result14_0,
result14_1,
result14_2,
result14_3,
result14_4,
result14_5,
) = match e {
Some(e) => { let FieldSizePayload {
field_name: field_name10,
field_size: field_size10,
} = e; let (result12_0, result12_1, result12_2) = match field_name10 {
Some(e) => { let vec11 = e; let ptr11 = vec11.as_ptr().cast::<u8>(); let len11 = vec11.len();
(1i32, ptr11.cast_mut(), len11)
}
None => (0i32, ::core::ptr::null_mut(), 0usize),
}; let (result13_0, result13_1) = match field_size10 {
Some(e) => (1i32, _rt::as_i32(e)),
None => (0i32, 0i32),
};
( 1i32,
result12_0,
result12_1,
result12_2,
result13_0,
result13_1,
)
}
None => {
(0i32, 0i32, ::core::ptr::null_mut(), 0usize, 0i32, 0i32)
}
};
( 22i32,
result14_0,
::core::mem::MaybeUninit::new(i64::from(result14_1) as u64),
result14_2,
result14_3 as *mut u8,
result14_4 as usize,
result14_5,
)
}
ErrorCode::HttpRequestTrailerSectionSize(e) => { let (result15_0, result15_1) = match e {
Some(e) => (1i32, _rt::as_i32(e)),
None => (0i32, 0i32),
};
( 23i32,
result15_0,
::core::mem::MaybeUninit::new(i64::from(result15_1) as u64),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpRequestTrailerSize(e) => { let FieldSizePayload {
field_name: field_name16,
field_size: field_size16,
} = e; let (result18_0, result18_1, result18_2) = match field_name16 {
Some(e) => { let vec17 = e; let ptr17 = vec17.as_ptr().cast::<u8>(); let len17 = vec17.len();
(1i32, ptr17.cast_mut(), len17)
}
None => (0i32, ::core::ptr::null_mut(), 0usize),
}; let (result19_0, result19_1) = match field_size16 {
Some(e) => (1i32, _rt::as_i32(e)),
None => (0i32, 0i32),
};
( 24i32,
result18_0,
{ letmut t = ::core::mem::MaybeUninit::<u64>::uninit();
t.as_mut_ptr().cast::<*mut u8>().write(result18_1);
t
},
result18_2 as *mut u8,
result19_0 as *mut u8,
result19_1 as usize, 0i32,
)
}
ErrorCode::HttpResponseIncomplete => {
( 25i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpResponseHeaderSectionSize(e) => { let (result20_0, result20_1) = match e {
Some(e) => (1i32, _rt::as_i32(e)),
None => (0i32, 0i32),
};
( 26i32,
result20_0,
::core::mem::MaybeUninit::new(i64::from(result20_1) as u64),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpResponseHeaderSize(e) => { let FieldSizePayload {
field_name: field_name21,
field_size: field_size21,
} = e; let (result23_0, result23_1, result23_2) = match field_name21 {
Some(e) => { let vec22 = e; let ptr22 = vec22.as_ptr().cast::<u8>(); let len22 = vec22.len();
(1i32, ptr22.cast_mut(), len22)
}
None => (0i32, ::core::ptr::null_mut(), 0usize),
}; let (result24_0, result24_1) = match field_size21 {
Some(e) => (1i32, _rt::as_i32(e)),
None => (0i32, 0i32),
};
( 27i32,
result23_0,
{ letmut t = ::core::mem::MaybeUninit::<u64>::uninit();
t.as_mut_ptr().cast::<*mut u8>().write(result23_1);
t
},
result23_2 as *mut u8,
result24_0 as *mut u8,
result24_1 as usize, 0i32,
)
}
ErrorCode::HttpResponseBodySize(e) => { let (result25_0, result25_1) = match e {
Some(e) => (1i32, _rt::as_i64(e)),
None => (0i32, 0i64),
};
( 28i32,
result25_0,
::core::mem::MaybeUninit::new(result25_1 as u64),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpResponseTrailerSectionSize(e) => { let (result26_0, result26_1) = match e {
Some(e) => (1i32, _rt::as_i32(e)),
None => (0i32, 0i32),
};
( 29i32,
result26_0,
::core::mem::MaybeUninit::new(i64::from(result26_1) as u64),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpResponseTrailerSize(e) => { let FieldSizePayload {
field_name: field_name27,
field_size: field_size27,
} = e; let (result29_0, result29_1, result29_2) = match field_name27 {
Some(e) => { let vec28 = e; let ptr28 = vec28.as_ptr().cast::<u8>(); let len28 = vec28.len();
(1i32, ptr28.cast_mut(), len28)
}
None => (0i32, ::core::ptr::null_mut(), 0usize),
}; let (result30_0, result30_1) = match field_size27 {
Some(e) => (1i32, _rt::as_i32(e)),
None => (0i32, 0i32),
};
( 30i32,
result29_0,
{ letmut t = ::core::mem::MaybeUninit::<u64>::uninit();
t.as_mut_ptr().cast::<*mut u8>().write(result29_1);
t
},
result29_2 as *mut u8,
result30_0 as *mut u8,
result30_1 as usize, 0i32,
)
}
ErrorCode::HttpResponseTransferCoding(e) => { let (result32_0, result32_1, result32_2) = match e {
Some(e) => { let vec31 = e; let ptr31 = vec31.as_ptr().cast::<u8>(); let len31 = vec31.len();
(1i32, ptr31.cast_mut(), len31)
}
None => (0i32, ::core::ptr::null_mut(), 0usize),
};
( 31i32,
result32_0,
{ letmut t = ::core::mem::MaybeUninit::<u64>::uninit();
t.as_mut_ptr().cast::<*mut u8>().write(result32_1);
t
},
result32_2 as *mut u8,
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpResponseContentCoding(e) => { let (result34_0, result34_1, result34_2) = match e {
Some(e) => { let vec33 = e; let ptr33 = vec33.as_ptr().cast::<u8>(); let len33 = vec33.len();
(1i32, ptr33.cast_mut(), len33)
}
None => (0i32, ::core::ptr::null_mut(), 0usize),
};
( 32i32,
result34_0,
{ letmut t = ::core::mem::MaybeUninit::<u64>::uninit();
t.as_mut_ptr().cast::<*mut u8>().write(result34_1);
t
},
result34_2 as *mut u8,
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpResponseTimeout => {
( 33i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpUpgradeFailed => {
( 34i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::HttpProtocolError => {
( 35i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::LoopDetected => {
( 36i32, 0i32,
::core::mem::MaybeUninit::<u64>::zeroed(),
::core::ptr::null_mut(),
::core::ptr::null_mut(), 0usize, 0i32,
)
}
ErrorCode::ConfigurationError => {
( 37i32, 0i32,
::core::mem::MaybeUninit::<u64>::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::<u8>(); let len35 = vec35.len();
(1i32, ptr35.cast_mut(), len35)
}
None => (0i32, ::core::ptr::null_mut(), 0usize),
};
( 38i32,
result36_0,
{ letmut t = ::core::mem::MaybeUninit::<u64>::uninit();
t.as_mut_ptr().cast::<*mut u8>().write(result36_1);
t
},
result36_2 as *mut u8,
::core::ptr::null_mut(), 0usize, 0i32,
)
}
};
( 1i32,
result37_0,
result37_1,
result37_2,
result37_3,
result37_4,
result37_5,
result37_6,
)
}
}; #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[static]response-outparam.set"]
fn wit_import39(
_: i32,
_: i32,
_: i32,
_: i32,
_: ::core::mem::MaybeUninit<u64>,
_: *mut u8,
_: *mut u8,
_: usize,
_: i32,
);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import39(
_: i32,
_: i32,
_: i32,
_: i32,
_: ::core::mem::MaybeUninit<u64>,
_: *mut u8,
_: *mut u8,
_: usize,
_: i32,
) {
unreachable!()
}
wit_import39(
(¶m).take_handle() as i32,
result38_0,
result38_1,
result38_2,
result38_3,
result38_4,
result38_5,
result38_6,
result38_7,
);
}
}
} impl IncomingResponse { #[allow(unused_unsafe, clippy::all)] /// Returns the status code from the incoming response. pub fn status(&self) -> StatusCode { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]incoming-response.status"]
fn wit_import0(_: i32) -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0(_: i32) -> i32 {
unreachable!()
} let ret = wit_import0((self).handle() as i32);
ret as u16
}
}
} impl IncomingResponse { #[allow(unused_unsafe, clippy::all)] /// Returns the headers from the incoming response. /// /// The returned `headers` resource is immutable: `set`, `append`, and /// `delete` operations will fail with `header-error.immutable`. /// /// This headers resource is a child: it must be dropped before the parent /// `incoming-response` is dropped. pub fn headers(&self) -> Headers { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]incoming-response.headers"]
fn wit_import0(_: i32) -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0(_: i32) -> i32 {
unreachable!()
} let ret = wit_import0((self).handle() as i32);
Fields::from_handle(ret as u32)
}
}
} impl IncomingResponse { #[allow(unused_unsafe, clippy::all)] /// Returns the incoming body. May be called at most once. Returns error /// if called additional times. pub fn consume(&self) -> Result<IncomingBody, ()> { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit<u8>; 8]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 8],
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]incoming-response.consume"]
fn wit_import1(_: i32, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result4 = match l2 { 0 => { let e = { let l3 = *ptr0.add(4).cast::<i32>();
IncomingBody::from_handle(l3 as u32)
};
Ok(e)
} 1 => { let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
} 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<InputStream, ()> { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit<u8>; 8]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 8],
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" {
#[link_name = "[method]incoming-body.stream"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result4 = match l2 { 0 => {
let e = {
let l3 = *ptr0.add(4).cast::<i32>();
super::super::super::wasi::io::streams::InputStream::from_handle(
l3 as u32,
)
};
Ok(e)
} 1 => {
let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
}
impl IncomingBody {
#[allow(unused_unsafe, clippy::all)]
/// Takes ownership of `incoming-body`, and returns a `future-trailers`.
/// This function will trap if the `input-stream` child is still alive.
pub fn finish(this: IncomingBody) -> FutureTrailers {
unsafe {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[static]incoming-body.finish"]
fn wit_import0(_: i32) -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import0(_: i32) -> i32 {
unreachable!()
}
let ret = wit_import0((&this).take_handle() as i32);
FutureTrailers::from_handle(ret as u32)
}
}
}
impl FutureTrailers {
#[allow(unused_unsafe, clippy::all)]
/// Returns a pollable which becomes ready when either the trailers have
/// been received, or an error has occurred. When this pollable is ready,
/// the `get` method will return `some`.
pub fn subscribe(&self) -> Pollable {
unsafe {
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]future-trailers.subscribe"]
fn wit_import0(_: i32) -> i32;
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import0(_: i32) -> i32 {
unreachable!()
}
let ret = wit_import0((self).handle() as i32);
super::super::super::wasi::io::poll::Pollable::from_handle(
ret as u32,
)
}
}
}
impl FutureTrailers {
#[allow(unused_unsafe, clippy::all)]
/// Returns the contents of the trailers, or an error which occurred,
/// 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 occurred 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<Result<Result<Option<Trailers>, ErrorCode>, ()>> {
unsafe {
#[repr(align(8))]
struct RetArea([::core::mem::MaybeUninit<u8>; 56]);
let mut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 56],
);
let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/types@0.2.4")]
extern "C" {
#[link_name = "[method]future-trailers.get"]
fn wit_import1(_: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0);
let l2 = i32::from(*ptr0.add(0).cast::<u8>());
let result70 = match l2 { 0 => None, 1 => {
let e = {
let l3 = i32::from(*ptr0.add(8).cast::<u8>());
match l3 { 0 => {
let e = {
let l4 = i32::from(*ptr0.add(16).cast::<u8>());
match l4 { 0 => {
let e = {
let l5 = i32::from(*ptr0.add(24).cast::<u8>());
match l5 { 0 => None, 1 => {
let e = {
let l6 = *ptr0.add(28).cast::<i32>();
Fields::from_handle(l6 as u32)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
Ok(e)
} 1 => {
let e = {
let l7 = i32::from(*ptr0.add(24).cast::<u8>());
let v69 = match l7 { 0 => ErrorCode::DnsTimeout, 1 => {
let e69 = {
let l8 = i32::from(*ptr0.add(32).cast::<u8>());
let l12 = i32::from(*ptr0.add(44).cast::<u8>());
DnsErrorPayload {
rcode: match l8 { 0 => None, 1 => {
let e = {
let l9 = *ptr0.add(36).cast::<*mut u8>();
let l10 = *ptr0.add(40).cast::<usize>();
let len11 = l10;
let bytes11 = _rt::Vec::from_raw_parts(
l9.cast(),
len11,
len11,
);
_rt::string_lift(bytes11)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
info_code: match l12 { 0 => None, 1 => {
let e = {
let l13 = i32::from(*ptr0.add(46).cast::<u16>());
l13 as u16
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::DnsError(e69)
} 2 => ErrorCode::DestinationNotFound,
documentationand/ other provided withthe distribution. 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 e69 = {
let l14 = i32::from(*ptr0.add(32).cast::<u8>());
let l16 = i32::from(*ptr0.add(36).cast::<u8>());
TlsAlertReceivedPayload {
alert_id: match l14 { 0 => None, 1 => {
let e = {
let l15 = i32::from(*ptr0.add(33).cast::<u8>());
l15 as u8
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
alert_message: match l16 { 0 => None, 1 => {
let e = {
let l17 = *ptr0.add(40).cast::<*mut u8>();
let l18 = *ptr0.add(44).cast::<usize>();
let len19 = l18;
let bytes19 = _rt::Vec::from_raw_parts(
l17.cast(),
len19,
len19,
);
_rt::string_lift(bytes19)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::TlsAlertReceived(e69)
} 15 => ErrorCode::HttpRequestDenied, 16 => ErrorCode::HttpRequestLengthRequired, 17 => {
let e69 = {
let l20 = i32::from(*ptr0.add(32).cast::<u8>());
match l20 { 0 => None, 1 => {
let e = {
let l21 = *ptr0.add(40).cast::<i64>();
l21 as u64
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestBodySize(e69)
} 18 => ErrorCode::HttpRequestMethodInvalid, 19 => ErrorCode::HttpRequestUriInvalid, 20 => ErrorCode::HttpRequestUriTooLong, 21 => {
let e69 = {
let l22 = i32::from(*ptr0.add(32).cast::<u8>());
match l22 { 0 => None, 1 => {
let e = {
let l23 = *ptr0.add(36).cast::<i32>();
l23 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestHeaderSectionSize(e69)
} 22 => {
let e69 = {
let l24 = i32::from(*ptr0.add(32).cast::<u8>());
match l24 { 0 => None, 1 => {
let e = {
let l25 = i32::from(*ptr0.add(36).cast::<u8>());
let l29 = i32::from(*ptr0.add(48).cast::<u8>());
FieldSizePayload {
field_name: match l25 { 0 => None, 1 => {
let e = {
let l26 = *ptr0.add(40).cast::<*mut u8>();
let l27 = *ptr0.add(44).cast::<usize>();
let len28 = l27;
let bytes28 = _rt::Vec::from_raw_parts(
l26.cast(),
len28,
len28,
);
_rt::string_lift(bytes28)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
field_size: match l29 { 0 => None, 1 => {
let e = {
let l30 = *ptr0.add(52).cast::<i32>();
l30 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestHeaderSize(e69)
} 23 => {
let e69 = {
let l31 = i32::from(*ptr0.add(32).cast::<u8>());
match l31 { 0 => None, 1 => {
let e = {
let l32 = *ptr0.add(36).cast::<i32>();
l32 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestTrailerSectionSize(e69)
} 24 => {
let e69 = {
let l33 = i32::from(*ptr0.add(32).cast::<u8>());
let l37 = i32::from(*ptr0.add(44).cast::<u8>());
FieldSizePayload {
field_name: match l33 { 0 => None, 1 => {
let e = {
let l34 = *ptr0.add(36).cast::<*mut u8>();
let l35 = *ptr0.add(40).cast::<usize>();
let len36 = l35;
let bytes36 = _rt::Vec::from_raw_parts(
l34.cast(),
len36,
len36,
);
_rt::string_lift(bytes36)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
field_size: match l37 { 0 => None, 1 => {
let e = {
let l38 = *ptr0.add(48).cast::<i32>();
l38 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::HttpRequestTrailerSize(e69)
} 25 => ErrorCode::HttpResponseIncomplete, 26 => {
let e69 = {
let l39 = i32::from(*ptr0.add(32).cast::<u8>());
match l39 { 0 => None, 1 => {
let e = {
let l40 = *ptr0.add(36).cast::<i32>();
l40 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseHeaderSectionSize(e69)
} 27 => {
let e69 = {
let l41 = i32::from(*ptr0.add(32).cast::<u8>());
let l45 = i32::from(*ptr0.add(44).cast::<u8>());
FieldSizePayload {
field_name: match l41 { 0 => None, 1 => {
let e = {
let l42 = *ptr0.add(36).cast::<*mut u8>();
let l43 = *ptr0.add(40).cast::<usize>();
let len44 = l43;
let bytes44 = _rt::Vec::from_raw_parts(
l42.cast(),
len44,
len44,
);
_rt::string_lift(bytes44)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
field_size: match l45 { 0 => None, 1 => {
let e = {
let l46 = *ptr0.add(48).cast::<i32>();
l46 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::HttpResponseHeaderSize(e69)
} 28 => {
let e69 = {
let l47 = i32::from(*ptr0.add(32).cast::<u8>());
match l47 { 0 => None, 1 => {
let e = {
let l48 = *ptr0.add(40).cast::<i64>();
l48 as u64
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseBodySize(e69)
} 29 => {
let e69 = {
let l49 = i32::from(*ptr0.add(32).cast::<u8>());
match l49 { 0 => None, 1 => {
let e = {
let l50 = *ptr0.add(36).cast::<i32>();
l50 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseTrailerSectionSize(e69)
} 30 => {
let e69 = {
let l51 = i32::from(*ptr0.add(32).cast::<u8>());
let l55 = i32::from(*ptr0.add(44).cast::<u8>());
FieldSizePayload {
field_name: match l51 { 0 => None, 1 => {
let e = {
let l52 = *ptr0.add(36).cast::<*mut u8>();
let l53 = *ptr0.add(40).cast::<usize>(); let len54 = l53; let bytes54 = _rt::Vec::from_raw_parts(
l52.cast(),
len54,
len54,
);
_rt::string_lift(bytes54)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
field_size: match l55 { 0 => None, 1 => { let e = { let l56 = *ptr0.add(48).cast::<i32>();
l56 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::HttpResponseTrailerSize(e69)
} 31 => { let e69 = { let l57 = i32::from(*ptr0.add(32).cast::<u8>()); match l57 { 0 => None, 1 => { let e = { let l58 = *ptr0.add(36).cast::<*mut u8>(); let l59 = *ptr0.add(40).cast::<usize>(); let len60 = l59; let bytes60 = _rt::Vec::from_raw_parts(
l58.cast(),
len60,
len60,
);
_rt::string_lift(bytes60)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseTransferCoding(e69)
} 32 => { let e69 = { let l61 = i32::from(*ptr0.add(32).cast::<u8>()); match l61 { 0 => None, 1 => { let e = { let l62 = *ptr0.add(36).cast::<*mut u8>(); let l63 = *ptr0.add(40).cast::<usize>(); let len64 = l63; let bytes64 = _rt::Vec::from_raw_parts(
l62.cast(),
len64,
len64,
);
_rt::string_lift(bytes64)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseContentCoding(e69)
} 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 e69 = { let l65 = i32::from(*ptr0.add(32).cast::<u8>()); match l65 { 0 => None, 1 => { let e = { let l66 = *ptr0.add(36).cast::<*mut u8>(); let l67 = *ptr0.add(40).cast::<usize>(); let len68 = l67; let bytes68 = _rt::Vec::from_raw_parts(
l66.cast(),
len68,
len68,
);
_rt::string_lift(bytes68)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::InternalError(e69)
}
};
v69
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
Ok(e)
} 1 => { let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result70
}
}
} impl OutgoingResponse { #[allow(unused_unsafe, clippy::all)] /// Construct an `outgoing-response`, with a default `status-code` of `200`. /// If a different `status-code` is needed, it must be set via the /// `set-status-code` method. /// /// * `headers` is the HTTP Headers for the Response. pub fn new(headers: Headers) -> Self { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[constructor]outgoing-response"]
fn wit_import0(_: i32) -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0(_: i32) -> i32 {
unreachable!()
} let ret = wit_import0((&headers).take_handle() as i32);
OutgoingResponse::from_handle(ret as u32)
}
}
} impl OutgoingResponse { #[allow(unused_unsafe, clippy::all)] /// Get the HTTP Status Code for the Response. pub fn status_code(&self) -> StatusCode { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your #[link_name ]
fn wit_import0(_: i32) -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0(_: i32) -> i32 {
unreachable!()
} let ret = wit_import0((self).handle() as i32);
ret as u16
}
}
} impl OutgoingResponse { #[allow(unused_unsafe, clippy::all)] /// Set the HTTP Status Code for the Response. Fails if the status-code /// given is not a valid http status code. pub fn set_status_code(
&self,
status_code: StatusCode,
) -> Result<(), ()> { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]outgoing-response.set-status-code"]
fn wit_import0(_: i32, _: i32) -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0(_: i32, _: i32) -> i32 {
unreachable!()
} let ret = wit_import0(
(self).handle() as i32,
_rt::as_i32(status_code),
); match ret { 0 => { let e = ();
Ok(e)
} 1 => { let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
}
}
}
} impl OutgoingResponse { #[allow(unused_unsafe, clippy::all)] /// Get the headers associated with the Request. /// /// The returned `headers` resource is immutable: `set`, `append`, and /// `delete` operations will fail with `header-error.immutable`. /// /// This headers resource is a child: it must be dropped before the parent /// `outgoing-request` is dropped, or its ownership is transferred to /// another component by e.g. `outgoing-handler.handle`. pub fn headers(&self) -> Headers { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]outgoing-response.headers"]
fn wit_import0(_: i32) -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0(_: i32) -> i32 {
unreachable!()
} let ret = wit_import0((self).handle() as i32);
Fields::from_handle(ret as u32)
}
}
} impl OutgoingResponse { #[allow(unused_unsafe, clippy::all)] /// Returns the resource corresponding to the outgoing Body for this Response. /// /// Returns success on the first call: the `outgoing-body` resource for /// this `outgoing-response` can be retrieved at most once. Subsequent /// calls will return error. pub fn body(&self) -> Result<OutgoingBody, ()> { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit<u8>; 8]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 8],
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]outgoing-response.body"]
fn wit_import1(_: i32, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result4 = match l2 { 0 => { let e = { let l3 = *ptr0.add(4).cast::<i32>();
OutgoingBody::from_handle(l3 as u32)
};
Ok(e)
} 1 => { let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
} 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<OutputStream, ()> { unsafe { #[repr(align(4))] struct RetArea([::core::mem::MaybeUninit<u8>; 8]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 8],
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]outgoing-body.write"]
fn wit_import1(_: i32, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result4 = match l2 { 0 => { let e = { let l3 = *ptr0.add(4).cast::<i32>(); super::super::super::wasi::io::streams::OutputStream::from_handle(
l3 as u32,
)
};
Ok(e)
} 1 => { let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result4
}
}
} 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<Trailers>,
) -> Result<(), ErrorCode> { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit<u8>; 40]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 40],
); let (result0_0, result0_1) = match &trailers {
Some(e) => (1i32, (e).take_handle() as i32),
None => (0i32, 0i32),
}; let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[static]outgoing-body.finish"]
fn wit_import2(_: i32, _: i32, _: i32, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import2(_: i32, _: i32, _: i32, _: *mut u8) {
unreachable!()
}
wit_import2(
(&this).take_handle() as i32,
result0_0,
result0_1,
ptr1,
); let l3 = i32::from(*ptr1.add(0).cast::<u8>()); let result67 = match l3 { 0 => { let e = ();
Ok(e)
} 1 => { let e = { let l4 = i32::from(*ptr1.add(8).cast::<u8>()); let v66 = match l4 { 0 => ErrorCode::DnsTimeout, 1 => { let e66 = { let l5 = i32::from(*ptr1.add(16).cast::<u8>()); let l9 = i32::from(*ptr1.add(28).cast::<u8>());
DnsErrorPayload {
rcode: match l5 { 0 => None, 1 => { let e = { let l6 = *ptr1.add(20).cast::<*mut u8>(); let l7 = *ptr1.add(24).cast::<usize>(); let len8 = l7; let bytes8 = _rt::Vec::from_raw_parts(
l6.cast(),
len8,
len8,
);
_rt::string_lift(bytes8)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
info_code: match l9 { 0 => None, 1 => { let e = { let l10 = i32::from(*ptr1.add(30).cast::<u16>());
l10 as u16
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::DnsError(e66)
} 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 e66 = { let l11 = i32::from(*ptr1.add(16).cast::<u8>()); let l13 = i32::from(*ptr1.add(20).cast::<u8>());
TlsAlertReceivedPayload {
alert_id: match l11 { 0 => None, 1 => { let e = { let l12 = i32::from(*ptr1.add(17).cast::<u8>());
l12 as u8
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
alert_message: match l13 { 0 => None, 1 => { let e = { let l14 = *ptr1.add(24).cast::<*mut u8>(); let l15 = *ptr1.add(28).cast::<usize>(); let len16 = l15; let bytes16 = _rt::Vec::from_raw_parts(
l14.cast(),
len16,
len16,
);
_rt::string_lift(bytes16)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::TlsAlertReceived(e66)
} 15 => ErrorCode::HttpRequestDenied, 16 => ErrorCode::HttpRequestLengthRequired, 17 => { let e66 = { let l17 = i32::from(*ptr1.add(16).cast::<u8>()); match l17 { 0 => None, 1 => { let e = { let l18 = *ptr1.add(24).cast::<i64>();
l18 as u64
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestBodySize(e66)
} 18 => ErrorCode::HttpRequestMethodInvalid, 19 => ErrorCode::HttpRequestUriInvalid, 20 => ErrorCode::HttpRequestUriTooLong, 21 => { let e66 = { let l19 = i32::from(*ptr1.add(16).cast::<u8>()); match l19 { 0 => None, 1 => { let e = { let l20 = *ptr1.add(20).cast::<i32>();
l20 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestHeaderSectionSize(e66)
} 22 => { let e66 = { let l21 = i32::from(*ptr1.add(16).cast::<u8>()); match l21 { 0 => None, 1 => { let e = { let l22 = i32::from(*ptr1.add(20).cast::<u8>()); let l26 = i32::from(*ptr1.add(32).cast::<u8>());
FieldSizePayload {
field_name: match l22 { 0 => None, 1 => { let e = { let l23 = *ptr1.add(24).cast::<*mut u8>(); let l24 = *ptr1.add(28).cast::<usize>(); let len25 = l24; let bytes25 = _rt::Vec::from_raw_parts(
l23.cast(),
len25,
len25,
);
_rt::string_lift(bytes25)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
field_size: match l26 { 0 => None, 1 => { let e = { let l27 = *ptr1.add(36).cast::<i32>();
l27 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestHeaderSize(e66)
} 23 => { let e66 = { let l28 = i32::from(*ptr1.add(16).cast::<u8>()); match l28 { 0 => None, 1 => { let e = { let l29 = *ptr1.add(20).cast::<i32>();
l29 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestTrailerSectionSize(e66)
} 24 => { let e66 = { let l30 = i32::from(*ptr1.add(16).cast::<u8>()); let l34 = i32::from(*ptr1.add(28).cast::<u8>());
FieldSizePayload {
field_name: match l30 { 0 => None, 1 => { let e = { let l31 = *ptr1.add(20).cast::<*mut u8>(); let l32 = *ptr1.add(24).cast::<usize>(); let len33 = l32; let bytes33 = _rt::Vec::from_raw_parts(
l31.cast(),
len33,
len33,
);
_rt::string_lift(bytes33)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
field_size: match l34 { 0 => None, 1 => { let e = { let l35 = *ptr1.add(32).cast::<i32>();
l35 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::HttpRequestTrailerSize(e66)
} 25 => ErrorCode::HttpResponseIncomplete, 26 => { let e66 = { let l36 = i32::from(*ptr1.add(16).cast::<u8>()); match l36 { 0 => None, 1 => { let e = { let l37 = *ptr1.add(20).cast::<i32>();
l37 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseHeaderSectionSize(e66)
} 27 => { let e66 = { let l38 = i32::from(*ptr1.add(16).cast::<u8>()); let l42 = i32::from(*ptr1.add(28).cast::<u8>());
FieldSizePayload {
field_name: match l38 { 0 => None, 1 => { let e = { let l39 = *ptr1.add(20).cast::<*mut u8>(); let l40 = *ptr1.add(24).cast::<usize>(); let len41 = l40; let bytes41 = _rt::Vec::from_raw_parts(
l39.cast(),
len41,
len41,
);
_rt::string_lift(bytes41)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
field_size: match l42 { 0 => None, 1 => { let e = { let l43 = *ptr1.add(32).cast::<i32>();
l43 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::HttpResponseHeaderSize(e66)
} 28 => { let e66 = { let l44 = i32::from(*ptr1.add(16).cast::<u8>()); match l44 { 0 => None, 1 => { let e = { let l45 = *ptr1.add(24).cast::<i64>();
l45 as u64
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseBodySize(e66)
} 29 => { let e66 = { let l46 = i32::from(*ptr1.add(16).cast::<u8>()); match l46 { 0 => None, 1 => { let e = { let l47 = *ptr1.add(20).cast::<i32>();
l47 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseTrailerSectionSize(e66)
} 30 => { let e66 = { let l48 = i32::from(*ptr1.add(16).cast::<u8>()); let l52 = i32::from(*ptr1.add(28).cast::<u8>());
FieldSizePayload {
field_name: match l48 { 0 => None, 1 => { let e = { let l49 = *ptr1.add(20).cast::<*mut u8>(); let l50 = *ptr1.add(24).cast::<usize>(); let len51 = l50; let bytes51 = _rt::Vec::from_raw_parts(
l49.cast(),
len51,
len51,
);
_rt::string_lift(bytes51)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
field_size: match l52 { 0 => None, 1 => { let e = { let l53 = *ptr1.add(32).cast::<i32>();
l53 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::HttpResponseTrailerSize(e66)
} 31 => { let e66 = { let l54 = i32::from(*ptr1.add(16).cast::<u8>()); match l54 { 0 => None, 1 => { let e = { let l55 = *ptr1.add(20).cast::<*mut u8>(); let l56 = *ptr1.add(24).cast::<usize>(); let len57 = l56; let bytes57 = _rt::Vec::from_raw_parts(
l55.cast(),
len57,
len57,
);
_rt::string_lift(bytes57)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseTransferCoding(e66)
} 32 => { let e66 = { let l58 = i32::from(*ptr1.add(16).cast::<u8>()); match l58 { 0 => None, 1 => { let e = { let l59 = *ptr1.add(20).cast::<*mut u8>(); let l60 = *ptr1.add(24).cast::<usize>(); let len61 = l60; let bytes61 = _rt::Vec::from_raw_parts(
l59.cast(),
len61,
len61,
);
_rt::string_lift(bytes61)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseContentCoding(e66)
} 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 e66 = { let l62 = i32::from(*ptr1.add(16).cast::<u8>()); match l62 { 0 => None, 1 => { let e = { let l63 = *ptr1.add(20).cast::<*mut u8>(); let l64 = *ptr1.add(24).cast::<usize>(); let len65 = l64; let bytes65 = _rt::Vec::from_raw_parts(
l63.cast(),
len65,
len65,
);
_rt::string_lift(bytes65)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::InternalError(e66)
}
};
v66
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result67
}
}
} impl FutureIncomingResponse { #[allow(unused_unsafe, clippy::all)] /// Returns a pollable which becomes ready when either the Response has /// been received, or an error has occurred. When this pollable is ready, /// the `get` method will return `some`. pub fn subscribe(&self) -> Pollable { unsafe { #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]future-incoming-response.subscribe"]
fn wit_import0(_: i32) -> i32;
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import0(_: i32) -> i32 {
unreachable!()
} let ret = wit_import0((self).handle() as i32); super::super::super::wasi::io::poll::Pollable::from_handle(
ret as u32,
)
}
}
} impl FutureIncomingResponse { #[allow(unused_unsafe, clippy::all)] /// 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 received successfully, or that an error /// occurred. 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<Result<Result<IncomingResponse, ErrorCode>, ()>> { unsafe { #[repr(align(8))] struct RetArea([::core::mem::MaybeUninit<u8>; 56]); letmut ret_area = RetArea(
[::core::mem::MaybeUninit::uninit(); 56],
); let ptr0 = ret_area.0.as_mut_ptr().cast::<u8>(); #[cfg(target_arch = "wasm32")] #[link(wasm_import_module = "wasi:http/types@0.2.4")] extern"C" { #[link_name = "[method]future-incoming-response.get"]
fn wit_import1(_: i32, _: *mut u8);
} #[cfg(not(target_arch = "wasm32"))] extern"C" fn wit_import1(_: i32, _: *mut u8) {
unreachable!()
}
wit_import1((self).handle() as i32, ptr0); let l2 = i32::from(*ptr0.add(0).cast::<u8>()); let result69 = match l2 { 0 => None, 1 => { let e = { let l3 = i32::from(*ptr0.add(8).cast::<u8>()); match l3 { 0 => { let e = { let l4 = i32::from(*ptr0.add(16).cast::<u8>()); match l4 { 0 => { let e = { let l5 = *ptr0.add(24).cast::<i32>();
IncomingResponse::from_handle(l5 as u32)
};
Ok(e)
} 1 => { let e = { let l6 = i32::from(*ptr0.add(24).cast::<u8>()); let v68 = match l6 { 0 => ErrorCode::DnsTimeout, 1 => { let e68 = { let l7 = i32::from(*ptr0.add(32).cast::<u8>()); let l11 = i32::from(*ptr0.add(44).cast::<u8>());
DnsErrorPayload {
rcode: match l7 { 0 => None, 1 => { let e = { let l8 = *ptr0.add(36).cast::<*mut u8>(); let l9 = *ptr0.add(40).cast::<usize>(); 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::<u16>());
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::<u8>()); let l15 = i32::from(*ptr0.add(36).cast::<u8>());
TlsAlertReceivedPayload {
alert_id: match l13 { 0 => None, 1 => { let e = { let l14 = i32::from(*ptr0.add(33).cast::<u8>());
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::<usize>(); 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::<u8>()); match l19 { 0 => None, 1 => { let e = { let l20 = *ptr0.add(40).cast::<i64>();
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::<u8>()); match l21 { 0 => None, 1 => { let e = { let l22 = *ptr0.add(36).cast::<i32>();
l22 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestHeaderSectionSize(e68)
} 22 => { let e68 = { let l23 = i32::from(*ptr0.add(32).cast::<u8>()); match l23 { 0 => None, 1 => { let e = { let l24 = i32::from(*ptr0.add(36).cast::<u8>()); let l28 = i32::from(*ptr0.add(48).cast::<u8>());
FieldSizePayload {
field_name: match l24 { 0 => None, 1 => {
let e = {
let l25 = *ptr0.add(40).cast::<*mut u8>();
let l26 = *ptr0.add(44).cast::<usize>();
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::<i32>();
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::<u8>());
match l30 { 0 => None, 1 => {
let e = {
let l31 = *ptr0.add(36).cast::<i32>();
l31 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpRequestTrailerSectionSize(e68)
} 24 => {
let e68 = {
let l32 = i32::from(*ptr0.add(32).cast::<u8>());
let l36 = i32::from(*ptr0.add(44).cast::<u8>());
FieldSizePayload {
field_name: match l32 { 0 => None, 1 => {
let e = {
let l33 = *ptr0.add(36).cast::<*mut u8>();
let l34 = *ptr0.add(40).cast::<usize>();
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::<i32>();
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::<u8>());
match l38 { 0 => None, 1 => {
let e = {
let l39 = *ptr0.add(36).cast::<i32>();
l39 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseHeaderSectionSize(e68)
} 27 => {
let e68 = {
let l40 = i32::from(*ptr0.add(32).cast::<u8>());
let l44 = i32::from(*ptr0.add(44).cast::<u8>());
FieldSizePayload {
field_name: match l40 { 0 => None, 1 => {
let e = {
let l41 = *ptr0.add(36).cast::<*mut u8>();
let l42 = *ptr0.add(40).cast::<usize>();
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::<i32>();
l45 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::HttpResponseHeaderSize(e68)
} 28 => {
let e68 = {
let l46 = i32::from(*ptr0.add(32).cast::<u8>());
match l46 { 0 => None, 1 => {
let e = {
let l47 = *ptr0.add(40).cast::<i64>();
l47 as u64
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseBodySize(e68)
} 29 => {
let e68 = {
let l48 = i32::from(*ptr0.add(32).cast::<u8>());
match l48 { 0 => None, 1 => {
let e = {
let l49 = *ptr0.add(36).cast::<i32>();
l49 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::HttpResponseTrailerSectionSize(e68)
} 30 => {
let e68 = {
let l50 = i32::from(*ptr0.add(32).cast::<u8>());
let l54 = i32::from(*ptr0.add(44).cast::<u8>());
FieldSizePayload {
field_name: match l50 { 0 => None, 1 => {
let e = {
let l51 = *ptr0.add(36).cast::<*mut u8>();
let l52 = *ptr0.add(40).cast::<usize>();
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::<i32>();
l55 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
ErrorCode::HttpResponseTrailerSize(e68)
} 31 => {
let e68 = {
let l56 = i32::from(*ptr0.add(32).cast::<u8>());
match l56 { 0 => None, 1 => {
let e = {
let l57 = *ptr0.add(36).cast::<*mut u8>();
let l58 = *ptr0.add(40).cast::<usize>();
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::<u8>());
match l60 { 0 => None, 1 => {
let e = {
let l61 = *ptr0.add(36).cast::<*mut u8>();
let l62 = *ptr0.add(40).cast::<usize>();
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::<u8>());
match l64 { 0 => None, 1 => {
let e = {
let l65 = *ptr0.add(36).cast::<*mut u8>();
let l66 = *ptr0.add(40).cast::<usize>();
let len67 = l66;
let bytes67 = _rt::Vec::from_raw_parts(
l65.cast(),
len67,
len67,
);
_rt::string_lift(bytes67)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
ErrorCode::InternalError(e68)
}
};
v68
};
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
Ok(e)
} 1 => {
let e = ();
Err(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
};
result69
}
}
}
}
/// This interface defines a handler of outgoing HTTP Requests. It should be
/// imported by components which wish to make HTTP Requests.
#[allow(dead_code, unused_imports, clippy::all)]
pub mod outgoing_handler {
#[used]
#[doc(hidden)]
static __FORCE_SECTION_REF: fn() = super::super::super::__link_custom_section_describing_imports;
use super::super::super::_rt;
pub type OutgoingRequest = super::super::super::wasi::http::types::OutgoingRequest;
pub type RequestOptions = super::super::super::wasi::http::types::RequestOptions;
pub type FutureIncomingResponse = super::super::super::wasi::http::types::FutureIncomingResponse;
pub type ErrorCode = super::super::super::wasi::http::types::ErrorCode;
#[allow(unused_unsafe, clippy::all)]
/// This function is invoked with an outgoing HTTP Request, and it returns
/// a resource `future-incoming-response` which represents an HTTP Response
/// which may arrive in the future.
///
/// The `options` argument accepts optional parameters for the HTTP
/// protocol's transport layer.
///
/// This function may return an error if the `outgoing-request` is invalid
/// or not allowed to be made. Otherwise, protocol errors are reported
/// through the `future-incoming-response`.
pub fn handle(
request: OutgoingRequest,
options: Option<RequestOptions>,
) -> Result<FutureIncomingResponse, ErrorCode> {
unsafe {
#[repr(align(8))]
struct RetArea([::core::mem::MaybeUninit<u8>; 40]);
let mut ret_area = RetArea([::core::mem::MaybeUninit::uninit(); 40]);
let (result0_0, result0_1) = match &options {
Some(e) => (1i32, (e).take_handle() as i32),
None => (0i32, 0i32),
};
let ptr1 = ret_area.0.as_mut_ptr().cast::<u8>();
#[cfg(target_arch = "wasm32")]
#[link(wasm_import_module = "wasi:http/outgoing-handler@0.2.4")]
extern "C" {
#[link_name = "handle"]
fn wit_import2(_: i32, _: i32, _: i32, _: *mut u8);
}
#[cfg(not(target_arch = "wasm32"))]
extern "C" fn wit_import2(_: i32, _: i32, _: i32, _: *mut u8) {
unreachable!()
}
wit_import2(
(&request).take_handle() as i32,
result0_0,
result0_1,
ptr1,
);
let l3 = i32::from(*ptr1.add(0).cast::<u8>());
let result68 = match l3 { 0 => {
let e = {
let l4 = *ptr1.add(8).cast::<i32>();
super::super::super::wasi::http::types::FutureIncomingResponse::from_handle(
l4 as u32,
)
};
Ok(e)
} 1 => {
let e = {
let l5 = i32::from(*ptr1.add(8).cast::<u8>());
use super::super::super::wasi::http::types::ErrorCode as V67;
let v67 = match l5 { 0 => V67::DnsTimeout, 1 => {
let e67 = {
let l6 = i32::from(*ptr1.add(16).cast::<u8>());
let l10 = i32::from(*ptr1.add(28).cast::<u8>());
super::super::super::wasi::http::types::DnsErrorPayload {
rcode: match l6 { 0 => None, 1 => {
let e = {
let l7 = *ptr1.add(20).cast::<*mut u8>();
let l8 = *ptr1.add(24).cast::<usize>();
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(*ptr1.add(30).cast::<u16>());
l11 as u16
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
V67::DnsError(e67)
} 2 => V67::DestinationNotFound, 3 => V67::DestinationUnavailable, 4 => V67::DestinationIpProhibited, 5 => V67::DestinationIpUnroutable, 6 => V67::ConnectionRefused, 7 => V67::ConnectionTerminated, 8 => V67::ConnectionTimeout, 9 => V67::ConnectionReadTimeout, 10 => V67::ConnectionWriteTimeout, 11 => V67::ConnectionLimitReached, 12 => V67::TlsProtocolError, 13 => V67::TlsCertificateError, 14 => {
let e67 = {
let l12 = i32::from(*ptr1.add(16).cast::<u8>());
let l14 = i32::from(*ptr1.add(20).cast::<u8>());
super::super::super::wasi::http::types::TlsAlertReceivedPayload {
alert_id: match l12 { 0 => None, 1 => {
let e = {
let l13 = i32::from(*ptr1.add(17).cast::<u8>());
l13 as u8
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
alert_message: match l14 { 0 => None, 1 => { let e = { let l15 = *ptr1.add(24).cast::<*mut u8>(); let l16 = *ptr1.add(28).cast::<usize>(); let len17 = l16; let bytes17 = _rt::Vec::from_raw_parts(
l15.cast(),
len17,
len17,
);
_rt::string_lift(bytes17)
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
},
}
};
V67::TlsAlertReceived(e67)
} 15 => V67::HttpRequestDenied, 16 => V67::HttpRequestLengthRequired, 17 => { let e67 = { let l18 = i32::from(*ptr1.add(16).cast::<u8>()); match l18 { 0 => None, 1 => { let e = { let l19 = *ptr1.add(24).cast::<i64>();
l19 as u64
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
V67::HttpRequestBodySize(e67)
} 18 => V67::HttpRequestMethodInvalid, 19 => V67::HttpRequestUriInvalid, 20 => V67::HttpRequestUriTooLong, 21 => { let e67 = { let l20 = i32::from(*ptr1.add(16).cast::<u8>()); match l20 { 0 => None, 1 => { let e = { let l21 = *ptr1.add(20).cast::<i32>();
l21 as u32
};
Some(e)
}
_ => _rt::invalid_enum_discriminant(),
}
};
V67::HttpRequestHeaderSectionSize(e67)
} 22 => { let e67 = { let l22 = i32::from(*ptr1.add(16).cast::<u8>()); match l22 { 0 => None, 1 => { let e = { let l23 = i32::from(*ptr1.add(20).cast::<u8>()); let l27 = i32::from(*ptr1.add(32).cast::<u8>()); super::super::super::wasi::http::types::FieldSizePayload {
field_name: match l23 {
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.1.113Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.