From 0ec2ba99e9cdbc7f60651f7c1b39b57557ef64af Mon Sep 17 00:00:00 2001 From: Juniper Langenstein Date: Mon, 8 Aug 2022 05:00:25 +0000 Subject: [PATCH] Started with host-side serde --- Cargo.lock | 839 +- necsim/plugins/wasm/Cargo.toml | 1 + necsim/plugins/wasm/expanded.rs | 13292 ++++++++++------------------- necsim/plugins/wasm/src/error.rs | 2 +- necsim/plugins/wasm/src/guest.rs | 864 ++ necsim/plugins/wasm/src/host.rs | 450 + necsim/plugins/wasm/src/lib.rs | 847 +- 7 files changed, 6701 insertions(+), 9594 deletions(-) create mode 100644 necsim/plugins/wasm/src/guest.rs create mode 100644 necsim/plugins/wasm/src/host.rs diff --git a/Cargo.lock b/Cargo.lock index 45e822c03..2b53bfaaf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -40,6 +49,17 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" +[[package]] +name = "async-trait" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76464446b8bc32758d7e88ee1a804d9914cd9b1cb264c029899680b0be29826f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "atty" version = "0.2.14" @@ -57,6 +77,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" +[[package]] +name = "backtrace" +version = "0.3.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object 0.29.0", + "rustc-demangle", +] + [[package]] name = "base32" version = "0.4.0" @@ -107,6 +142,15 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "block-buffer" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" +dependencies = [ + "generic-array", +] + [[package]] name = "build-probe-mpi" version = "0.1.2" @@ -308,6 +352,120 @@ dependencies = [ "custom_derive", ] +[[package]] +name = "cpp_demangle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eeaa953eaad386a53111e47172c2fedba671e5684c8dd601a5f474f4f118710f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "cpufeatures" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" +dependencies = [ + "libc", +] + +[[package]] +name = "cranelift-bforest" +version = "0.85.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "749d0d6022c9038dccf480bdde2a38d435937335bf2bb0f14e815d94517cdce8" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.85.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e94370cc7b37bf652ccd8bb8f09bd900997f7ccf97520edfc75554bb5c4abbea" +dependencies = [ + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-entity", + "cranelift-isle", + "gimli", + "log", + "regalloc2", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.85.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a3cea8fdab90e44018c5b9a1dfd460d8ee265ac354337150222a354628bdb6" +dependencies = [ + "cranelift-codegen-shared", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.85.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ac72f76f2698598951ab26d8c96eaa854810e693e7dd52523958b5909fde6b2" + +[[package]] +name = "cranelift-entity" +version = "0.85.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09eaeacfcd2356fe0e66b295e8f9d59fdd1ac3ace53ba50de14d628ec902f72d" +dependencies = [ + "serde", +] + +[[package]] +name = "cranelift-frontend" +version = "0.85.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dba69c9980d5ffd62c18a2bde927855fcd7c8dc92f29feaf8636052662cbd99c" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.85.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2920dc1e05cac40304456ed3301fde2c09bd6a9b0210bcfa2f101398d628d5b" + +[[package]] +name = "cranelift-native" +version = "0.85.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f04dfa45f9b2a6f587c564d6b63388e00cd6589d2df6ea2758cf79e1a13285e6" +dependencies = [ + "cranelift-codegen", + "libc", + "target-lexicon", +] + +[[package]] +name = "cranelift-wasm" +version = "0.85.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31a46513ae6f26f3f267d8d75b5373d555fbbd1e68681f348d99df43f747ec54" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "itertools", + "log", + "smallvec", + "wasmparser", + "wasmtime-types", +] + [[package]] name = "crc32fast" version = "1.3.2" @@ -317,6 +475,51 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-channel" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "715e8152b692bba2d374b53d4875445368fdf21a94751410af607a5ac677d1fc" +dependencies = [ + "cfg-if", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" +dependencies = [ + "autocfg", + "cfg-if", + "crossbeam-utils", + "memoffset", + "once_cell", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc" +dependencies = [ + "cfg-if", + "once_cell", +] + [[package]] name = "crunchy" version = "0.2.2" @@ -413,6 +616,36 @@ dependencies = [ "syn", ] +[[package]] +name = "digest" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" +dependencies = [ + "generic-array", +] + +[[package]] +name = "directories-next" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339ee130d97a610ea5a5872d2bbb130fdf68884ff09d3028b81bec8a1ac23bbc" +dependencies = [ + "cfg-if", + "dirs-sys-next", +] + +[[package]] +name = "dirs-sys-next" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + [[package]] name = "displaydoc" version = "0.2.3" @@ -452,6 +685,27 @@ dependencies = [ "serde", ] +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "fallible-iterator" version = "0.2.0" @@ -464,6 +718,16 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" +[[package]] +name = "file-per-thread-logger" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21e16290574b39ee41c71aeb90ae960c504ebaf1e2a1c87bd52aa56ed6e1a02f" +dependencies = [ + "env_logger", + "log", +] + [[package]] name = "final" version = "0.1.1" @@ -498,6 +762,25 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "getrandom" version = "0.2.7" @@ -509,6 +792,17 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + [[package]] name = "git-version" version = "0.3.5" @@ -537,6 +831,15 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -552,7 +855,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa" dependencies = [ - "hashbrown", + "hashbrown 0.12.3", ] [[package]] @@ -614,7 +917,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", + "serde", +] + +[[package]] +name = "io-lifetimes" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec58677acfea8a15352d42fc87d11d63596ade9239e0a7c9352914417515dbe6" + +[[package]] +name = "itertools" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3" +dependencies = [ + "either", ] [[package]] @@ -623,6 +942,15 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +[[package]] +name = "ittapi-rs" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f712648a1ad72fbfb7adc2772c331e8d90f022f8cf30cbabefba2878dd3172b0" +dependencies = [ + "cc", +] + [[package]] name = "jobserver" version = "0.1.25" @@ -650,6 +978,12 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + [[package]] name = "libc" version = "0.2.133" @@ -683,6 +1017,12 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linux-raw-sys" +version = "0.0.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5284f00d480e1c39af34e72f8ad60b94f47007e3481cd3b731c1d67190ddc7b7" + [[package]] name = "log" version = "0.4.17" @@ -692,6 +1032,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "mach" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" +dependencies = [ + "libc", +] + [[package]] name = "mbox" version = "0.6.0" @@ -709,6 +1058,15 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +[[package]] +name = "memfd" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6627dc657574b49d6ad27105ed671822be56e0d2547d413bfbf3e8d8fa92e7a" +dependencies = [ + "libc", +] + [[package]] name = "memoffset" version = "0.6.5" @@ -733,6 +1091,12 @@ dependencies = [ "adler", ] +[[package]] +name = "more-asserts" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" + [[package]] name = "mpi" version = "0.6.0" @@ -812,7 +1176,7 @@ dependencies = [ "displaydoc", "final", "fnv", - "hashbrown", + "hashbrown 0.12.3", "libm", "log", "necsim-core", @@ -991,18 +1355,61 @@ dependencies = [ "autocfg", ] +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "object" +version = "0.28.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42c982f2d955fac81dd7e1d0e1426a7d702acd9c98d19ab01083a6a0328c424" +dependencies = [ + "crc32fast", + "hashbrown 0.11.2", + "indexmap", + "memchr", +] + +[[package]] +name = "object" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" +[[package]] +name = "opaque-debug" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" + [[package]] name = "os_str_bytes" version = "6.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" +[[package]] +name = "paste" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9423e2b32f7a043629287a536f21951e8c6a82482d0acb1eeebfc90bc2225b22" + [[package]] name = "pcg_rand" version = "0.13.0" @@ -1083,6 +1490,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "psm" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f446d0a6efba22928558c4fb4ce0b3fd6c89b0061343e390bf01a703742b8125" +dependencies = [ + "cc", +] + [[package]] name = "ptx-builder" version = "0.5.3" @@ -1148,6 +1564,62 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rayon" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall", + "thiserror", +] + +[[package]] +name = "regalloc2" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a8d23b35d7177df3b9d31ed8a9ab4bf625c668be77a319d4f5efd4a5257701c" +dependencies = [ + "fxhash", + "log", + "slice-group-by", + "smallvec", +] + [[package]] name = "regex" version = "1.6.0" @@ -1165,6 +1637,18 @@ version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" +[[package]] +name = "region" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" +dependencies = [ + "bitflags", + "libc", + "mach", + "winapi", +] + [[package]] name = "ron" version = "0.8.0" @@ -1262,6 +1746,12 @@ dependencies = [ "syn", ] +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "rustc-hash" version = "1.1.0" @@ -1428,12 +1918,32 @@ dependencies = [ "tiff", ] +[[package]] +name = "rustix" +version = "0.33.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "938a344304321a9da4973b9ff4f9f8db9caf4597dfd9dda6a60b523340a0fff0" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "winapi", +] + [[package]] name = "ryu" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + [[package]] name = "seahash" version = "4.1.0" @@ -1527,6 +2037,19 @@ dependencies = [ "serde", ] +[[package]] +name = "sha2" +version = "0.9.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" +dependencies = [ + "block-buffer", + "cfg-if", + "cpufeatures", + "digest", + "opaque-debug", +] + [[package]] name = "shlex" version = "1.1.0" @@ -1542,6 +2065,12 @@ dependencies = [ "autocfg", ] +[[package]] +name = "slice-group-by" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03b634d87b960ab1a38c4fe143b508576f075e7c978bfad18217645ebfdfa2ec" + [[package]] name = "smallvec" version = "1.9.0" @@ -1586,6 +2115,12 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "target-lexicon" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c02424087780c9b71cc96799eaeddff35af2bc513278cda5c99fc1f5d026d3c1" + [[package]] name = "termcolor" version = "1.1.3" @@ -1682,6 +2217,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "typenum" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" + [[package]] name = "ucd-trie" version = "0.1.5" @@ -1718,6 +2259,12 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99" +[[package]] +name = "unicode-width" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" + [[package]] name = "unicode-xid" version = "0.2.3" @@ -1777,6 +2324,230 @@ dependencies = [ "serde_derive", "serde_json", "wit-bindgen-rust", + "wit-bindgen-wasmtime", +] + +[[package]] +name = "wasm-encoder" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8905fd25fdadeb0e7e8bf43a9f46f9f972d6291ad0c7a32573b88dd13a6cfa6b" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasmparser" +version = "0.85.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "570460c58b21e9150d2df0eaaedbb7816c34bcec009ae0dcc976e40ba81463e7" +dependencies = [ + "indexmap", +] + +[[package]] +name = "wasmtime" +version = "0.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f50eadf868ab6a04b7b511460233377d0bfbb92e417b2f6a98b98fef2e098f5" +dependencies = [ + "anyhow", + "async-trait", + "backtrace", + "bincode", + "cfg-if", + "indexmap", + "lazy_static", + "libc", + "log", + "object 0.28.4", + "once_cell", + "paste", + "psm", + "rayon", + "region", + "serde", + "target-lexicon", + "wasmparser", + "wasmtime-cache", + "wasmtime-cranelift", + "wasmtime-environ", + "wasmtime-fiber", + "wasmtime-jit", + "wasmtime-runtime", + "wat", + "winapi", +] + +[[package]] +name = "wasmtime-cache" +version = "0.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1df23c642e1376892f3b72f311596976979cbf8b85469680cdd3a8a063d12a2" +dependencies = [ + "anyhow", + "base64", + "bincode", + "directories-next", + "file-per-thread-logger", + "log", + "rustix", + "serde", + "sha2", + "toml", + "winapi", + "zstd", +] + +[[package]] +name = "wasmtime-cranelift" +version = "0.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f264ff6b4df247d15584f2f53d009fbc90032cfdc2605b52b961bffc71b6eccd" +dependencies = [ + "anyhow", + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "cranelift-wasm", + "gimli", + "log", + "more-asserts", + "object 0.28.4", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-environ", +] + +[[package]] +name = "wasmtime-environ" +version = "0.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "839d2820e4b830f4b9e7aa08d4c0acabf4a5036105d639f6dfa1c6891c73bdc6" +dependencies = [ + "anyhow", + "cranelift-entity", + "gimli", + "indexmap", + "log", + "more-asserts", + "object 0.28.4", + "serde", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-fiber" +version = "0.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3248be3c4911233535356025f6562193614a40155ee9094bb6a2b43f0dc82803" +dependencies = [ + "cc", + "rustix", + "winapi", +] + +[[package]] +name = "wasmtime-jit" +version = "0.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef0a0bcbfa18b946d890078ba0e1bc76bcc53eccfb40806c0020ec29dcd1bd49" +dependencies = [ + "addr2line", + "anyhow", + "bincode", + "cfg-if", + "cpp_demangle", + "gimli", + "ittapi-rs", + "log", + "object 0.28.4", + "region", + "rustc-demangle", + "rustix", + "serde", + "target-lexicon", + "thiserror", + "wasmtime-environ", + "wasmtime-jit-debug", + "wasmtime-runtime", + "winapi", +] + +[[package]] +name = "wasmtime-jit-debug" +version = "0.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f4779d976206c458edd643d1ac622b6c37e4a0800a8b1d25dfbf245ac2f2cac" +dependencies = [ + "lazy_static", + "object 0.28.4", + "rustix", +] + +[[package]] +name = "wasmtime-runtime" +version = "0.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7eb6ffa169eb5dcd18ac9473c817358cd57bc62c244622210566d473397954a" +dependencies = [ + "anyhow", + "backtrace", + "cc", + "cfg-if", + "indexmap", + "libc", + "log", + "mach", + "memfd", + "memoffset", + "more-asserts", + "rand", + "region", + "rustix", + "thiserror", + "wasmtime-environ", + "wasmtime-fiber", + "wasmtime-jit-debug", + "winapi", +] + +[[package]] +name = "wasmtime-types" +version = "0.38.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d932b0ac5336f7308d869703dd225610a6a3aeaa8e968c52b43eed96cefb1c2" +dependencies = [ + "cranelift-entity", + "serde", + "thiserror", + "wasmparser", +] + +[[package]] +name = "wast" +version = "45.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186c474c4f9bb92756b566d592a16591b4526b1a4841171caa3f31d7fe330d96" +dependencies = [ + "leb128", + "memchr", + "unicode-width", + "wasm-encoder", +] + +[[package]] +name = "wat" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2d4bc4724b4f02a482c8cab053dac5ef26410f264c06ce914958f9a42813556" +dependencies = [ + "wast", ] [[package]] @@ -1855,6 +2626,16 @@ dependencies = [ "wit-bindgen-gen-rust", ] +[[package]] +name = "wit-bindgen-gen-wasmtime" +version = "0.1.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=005a9e6d#005a9e6d5befe4652c0e6e05578b245ab96b3cea" +dependencies = [ + "heck 0.3.3", + "wit-bindgen-gen-core", + "wit-bindgen-gen-rust", +] + [[package]] name = "wit-bindgen-rust" version = "0.1.0" @@ -1875,6 +2656,29 @@ dependencies = [ "wit-bindgen-gen-rust-wasm", ] +[[package]] +name = "wit-bindgen-wasmtime" +version = "0.1.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=005a9e6d#005a9e6d5befe4652c0e6e05578b245ab96b3cea" +dependencies = [ + "anyhow", + "bitflags", + "thiserror", + "wasmtime", + "wit-bindgen-wasmtime-impl", +] + +[[package]] +name = "wit-bindgen-wasmtime-impl" +version = "0.1.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=005a9e6d#005a9e6d5befe4652c0e6e05578b245ab96b3cea" +dependencies = [ + "proc-macro2", + "syn", + "wit-bindgen-gen-core", + "wit-bindgen-gen-wasmtime", +] + [[package]] name = "wit-parser" version = "0.1.0" @@ -1886,3 +2690,32 @@ dependencies = [ "unicode-normalization", "unicode-xid", ] + +[[package]] +name = "zstd" +version = "0.11.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20cc960326ece64f010d2d2107537f26dc589a6573a316bd5b1dba685fa5fde4" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "5.0.2+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d2a5585e04f9eea4b2a3d1eca508c4dee9592a89ef6f450c11719da0726f4db" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.0.1+zstd.1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fd07cbbc53846d9145dbffdf6dd09a7a0aa52be46741825f5c97bdd4f73f12b" +dependencies = [ + "cc", + "libc", +] diff --git a/necsim/plugins/wasm/Cargo.toml b/necsim/plugins/wasm/Cargo.toml index d9a6b751b..2b28b9b79 100644 --- a/necsim/plugins/wasm/Cargo.toml +++ b/necsim/plugins/wasm/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" [dependencies] wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", default-features = false, features = ["macros"], rev = "005a9e6d" } +wit-bindgen-wasmtime = { git = "https://github.com/bytecodealliance/wit-bindgen", default-features = false, features = [], rev = "005a9e6d" } serde = "1.0" [dev-dependencies] diff --git a/necsim/plugins/wasm/expanded.rs b/necsim/plugins/wasm/expanded.rs index 42fc82cad..9703300b4 100644 --- a/necsim/plugins/wasm/expanded.rs +++ b/necsim/plugins/wasm/expanded.rs @@ -3,8890 +3,4692 @@ use std::prelude::rust_2021::*; #[macro_use] extern crate std; -use std::{ - cell::RefCell, - fmt::{self, Write}, -}; -mod any { - use core::{any, mem, mem::MaybeUninit, ptr}; - pub struct Any { - value: Value, - drop: unsafe fn(&mut Value), - fingerprint: Fingerprint, - } - union Value { - ptr: *mut (), - inline: [MaybeUninit; 2], - } - fn is_small() -> bool { - true && mem::size_of::() <= mem::size_of::() - && mem::align_of::() <= mem::align_of::() - } - impl Any { - pub(crate) unsafe fn new(t: T) -> Self { - let value: Value; - let drop: unsafe fn(&mut Value); - let fingerprint = Fingerprint::of::(); - if is_small::() { - let mut inline = [MaybeUninit::uninit(); 2]; - unsafe { ptr::write(inline.as_mut_ptr() as *mut T, t) }; - value = Value { inline }; - unsafe fn inline_drop(value: &mut Value) { - unsafe { ptr::drop_in_place(value.inline.as_mut_ptr() as *mut T) } - } - drop = inline_drop::; - } else { - let ptr = Box::into_raw(Box::new(t)) as *mut (); - value = Value { ptr }; - unsafe fn ptr_drop(value: &mut Value) { - mem::drop(unsafe { Box::from_raw(value.ptr as *mut T) }); - } - drop = ptr_drop::; - }; - Any { - value, - drop, - fingerprint, - } - } - pub(crate) unsafe fn view(&mut self) -> &mut T { - if true && self.fingerprint != Fingerprint::of::() { - self.invalid_cast_to::(); - } - let ptr = if is_small::() { - unsafe { self.value.inline.as_mut_ptr() as *mut T } - } else { - unsafe { self.value.ptr as *mut T } - }; - unsafe { &mut *ptr } - } - pub(crate) unsafe fn take(mut self) -> T { - if true && self.fingerprint != Fingerprint::of::() { - self.invalid_cast_to::(); - } - if is_small::() { - let ptr = unsafe { self.value.inline.as_mut_ptr() as *mut T }; - let value = unsafe { ptr::read(ptr) }; - mem::forget(self); - value - } else { - let ptr = unsafe { self.value.ptr as *mut T }; - let box_t = unsafe { Box::from_raw(ptr) }; - mem::forget(self); - *box_t - } - } - fn invalid_cast_to(&self) -> ! { - let from = self.fingerprint.type_name; - let to = any::type_name::(); - ::core::panicking::panic_fmt(::core::fmt::Arguments::new_v1( - &["invalid cast: ", " to "], - &[ - ::core::fmt::ArgumentV1::new_display(&from), - ::core::fmt::ArgumentV1::new_display(&to), - ], - )); - } - } - impl Drop for Any { - fn drop(&mut self) { - unsafe { (self.drop)(&mut self.value) } - } - } - struct Fingerprint { - size: usize, - align: usize, - type_name: &'static str, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for Fingerprint { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match *self { - Fingerprint { - size: ref __self_0_0, - align: ref __self_0_1, - type_name: ref __self_0_2, - } => { - let debug_trait_builder = - &mut ::core::fmt::Formatter::debug_struct(f, "Fingerprint"); - let _ = ::core::fmt::DebugStruct::field( - debug_trait_builder, - "size", - &&(*__self_0_0), - ); - let _ = ::core::fmt::DebugStruct::field( - debug_trait_builder, - "align", - &&(*__self_0_1), - ); - let _ = ::core::fmt::DebugStruct::field( - debug_trait_builder, - "type_name", - &&(*__self_0_2), - ); - ::core::fmt::DebugStruct::finish(debug_trait_builder) - } - } - } - } - impl ::core::marker::StructuralEq for Fingerprint {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::Eq for Fingerprint { - #[inline] - #[doc(hidden)] - #[no_coverage] - fn assert_receiver_is_total_eq(&self) -> () { - { - let _: ::core::cmp::AssertParamIsEq; - let _: ::core::cmp::AssertParamIsEq; - let _: ::core::cmp::AssertParamIsEq<&'static str>; - } - } - } - impl ::core::marker::StructuralPartialEq for Fingerprint {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::cmp::PartialEq for Fingerprint { - #[inline] - fn eq(&self, other: &Fingerprint) -> bool { - match *other { - Fingerprint { - size: ref __self_1_0, - align: ref __self_1_1, - type_name: ref __self_1_2, - } => match *self { - Fingerprint { - size: ref __self_0_0, - align: ref __self_0_1, - type_name: ref __self_0_2, - } => { - (*__self_0_0) == (*__self_1_0) - && (*__self_0_1) == (*__self_1_1) - && (*__self_0_2) == (*__self_1_2) - } - }, - } - } - #[inline] - fn ne(&self, other: &Fingerprint) -> bool { - match *other { - Fingerprint { - size: ref __self_1_0, - align: ref __self_1_1, - type_name: ref __self_1_2, - } => match *self { - Fingerprint { - size: ref __self_0_0, - align: ref __self_0_1, - type_name: ref __self_0_2, - } => { - (*__self_0_0) != (*__self_1_0) - || (*__self_0_1) != (*__self_1_1) - || (*__self_0_2) != (*__self_1_2) - } - }, - } - } - } - impl Fingerprint { - fn of() -> Fingerprint { - Fingerprint { - size: mem::size_of::(), - align: mem::align_of::(), - type_name: any::type_name::(), - } - } - } -} -mod de { - use crate::{ - any::Any, - error::Error, - map::{OptionExt, ResultExt}, - }; - use core::fmt::{self, Display}; - use serde::serde_if_integer128; - /// Deserialize a value of type `T` from the given trait object. - /// - /// ```rust - /// use erased_serde::Deserializer; - /// use std::collections::BTreeMap as Map; - /// - /// fn main() { - /// static JSON: &'static [u8] = br#"{"A": 65, "B": 66}"#; - /// static CBOR: &'static [u8] = &[162, 97, 65, 24, 65, 97, 66, 24, 66]; - /// - /// // Construct some deserializers. - /// let json = &mut serde_json::Deserializer::from_slice(JSON); - /// let cbor = &mut serde_cbor::Deserializer::from_slice(CBOR); - /// - /// // The values in this map are boxed trait objects, which is not possible - /// // with the normal serde::Deserializer because of object safety. - /// let mut formats: Map<&str, Box> = Map::new(); - /// formats.insert("json", Box::new(::erase(json))); - /// formats.insert("cbor", Box::new(::erase(cbor))); - /// - /// // Pick a Deserializer out of the formats map. - /// let format = formats.get_mut("json").unwrap(); - /// - /// let data: Map = erased_serde::deserialize(format).unwrap(); - /// - /// println!("{}", data["A"] + data["B"]); - /// } - /// ``` - pub fn deserialize<'de, T>(deserializer: &mut dyn Deserializer<'de>) -> Result - where - T: serde::Deserialize<'de>, - { - serde::Deserialize::deserialize(deserializer) - } - pub trait DeserializeSeed<'de> { - fn erased_deserialize_seed(&mut self, d: &mut dyn Deserializer<'de>) -> Result; - } - /// An object-safe equivalent of Serde's `Deserializer` trait. - /// - /// Any implementation of Serde's `Deserializer` can be converted to an - /// `&erased_serde::Deserializer` or `Box` trait - /// object using `erased_serde::Deserializer::erase`. - /// - /// ```rust - /// use erased_serde::Deserializer; - /// use std::collections::BTreeMap as Map; - /// - /// fn main() { - /// static JSON: &'static [u8] = br#"{"A": 65, "B": 66}"#; - /// static CBOR: &'static [u8] = &[162, 97, 65, 24, 65, 97, 66, 24, 66]; - /// - /// // Construct some deserializers. - /// let json = &mut serde_json::Deserializer::from_slice(JSON); - /// let cbor = &mut serde_cbor::Deserializer::from_slice(CBOR); - /// - /// // The values in this map are boxed trait objects, which is not possible - /// // with the normal serde::Deserializer because of object safety. - /// let mut formats: Map<&str, Box> = Map::new(); - /// formats.insert("json", Box::new(::erase(json))); - /// formats.insert("cbor", Box::new(::erase(cbor))); - /// - /// // Pick a Deserializer out of the formats map. - /// let format = formats.get_mut("json").unwrap(); - /// - /// let data: Map = erased_serde::deserialize(format).unwrap(); - /// - /// println!("{}", data["A"] + data["B"]); - /// } - /// ``` - pub trait Deserializer<'de> { - fn erased_deserialize_any(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_bool(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_u8(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_u16(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_u32(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_u64(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_i8(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_i16(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_i32(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_i64(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_i128(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_u128(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_f32(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_f64(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_char(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_str(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_string(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_bytes(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_byte_buf(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_option(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_unit(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_unit_struct( - &mut self, - name: &'static str, - v: &mut dyn Visitor<'de>, - ) -> Result; - fn erased_deserialize_newtype_struct( - &mut self, - name: &'static str, - v: &mut dyn Visitor<'de>, - ) -> Result; - fn erased_deserialize_seq(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_tuple( - &mut self, - len: usize, - v: &mut dyn Visitor<'de>, - ) -> Result; - fn erased_deserialize_tuple_struct( - &mut self, - name: &'static str, - len: usize, - v: &mut dyn Visitor<'de>, - ) -> Result; - fn erased_deserialize_map(&mut self, v: &mut dyn Visitor<'de>) -> Result; - fn erased_deserialize_struct( - &mut self, - name: &'static str, - fields: &'static [&'static str], - v: &mut dyn Visitor<'de>, - ) -> Result; - fn erased_deserialize_identifier(&mut self, v: &mut dyn Visitor<'de>) - -> Result; - fn erased_deserialize_enum( - &mut self, - name: &'static str, - variants: &'static [&'static str], - v: &mut dyn Visitor<'de>, - ) -> Result; - fn erased_deserialize_ignored_any( - &mut self, - v: &mut dyn Visitor<'de>, - ) -> Result; - fn erased_is_human_readable(&self) -> bool; - } - pub trait Visitor<'de> { - fn erased_expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result; - fn erased_visit_bool(&mut self, v: bool) -> Result; - fn erased_visit_i8(&mut self, v: i8) -> Result; - fn erased_visit_i16(&mut self, v: i16) -> Result; - fn erased_visit_i32(&mut self, v: i32) -> Result; - fn erased_visit_i64(&mut self, v: i64) -> Result; - fn erased_visit_u8(&mut self, v: u8) -> Result; - fn erased_visit_u16(&mut self, v: u16) -> Result; - fn erased_visit_u32(&mut self, v: u32) -> Result; - fn erased_visit_u64(&mut self, v: u64) -> Result; - fn erased_visit_i128(&mut self, v: i128) -> Result; - fn erased_visit_u128(&mut self, v: u128) -> Result; - fn erased_visit_f32(&mut self, v: f32) -> Result; - fn erased_visit_f64(&mut self, v: f64) -> Result; - fn erased_visit_char(&mut self, v: char) -> Result; - fn erased_visit_str(&mut self, v: &str) -> Result; - fn erased_visit_borrowed_str(&mut self, v: &'de str) -> Result; - fn erased_visit_string(&mut self, v: String) -> Result; - fn erased_visit_bytes(&mut self, v: &[u8]) -> Result; - fn erased_visit_borrowed_bytes(&mut self, v: &'de [u8]) -> Result; - fn erased_visit_byte_buf(&mut self, v: Vec) -> Result; - fn erased_visit_none(&mut self) -> Result; - fn erased_visit_some(&mut self, d: &mut dyn Deserializer<'de>) -> Result; - fn erased_visit_unit(&mut self) -> Result; - fn erased_visit_newtype_struct( - &mut self, - d: &mut dyn Deserializer<'de>, - ) -> Result; - fn erased_visit_seq(&mut self, s: &mut dyn SeqAccess<'de>) -> Result; - fn erased_visit_map(&mut self, m: &mut dyn MapAccess<'de>) -> Result; - fn erased_visit_enum(&mut self, e: &mut dyn EnumAccess<'de>) -> Result; - } - pub trait SeqAccess<'de> { - fn erased_next_element( - &mut self, - d: &mut dyn DeserializeSeed<'de>, - ) -> Result, Error>; - fn erased_size_hint(&self) -> Option; - } - pub trait MapAccess<'de> { - fn erased_next_key( - &mut self, - d: &mut dyn DeserializeSeed<'de>, - ) -> Result, Error>; - fn erased_next_value(&mut self, d: &mut dyn DeserializeSeed<'de>) -> Result; - fn erased_next_entry( - &mut self, - key: &mut dyn DeserializeSeed<'de>, - value: &mut dyn DeserializeSeed<'de>, - ) -> Result, Error>; - fn erased_size_hint(&self) -> Option; - } - pub trait EnumAccess<'de> { - fn erased_variant_seed( - &mut self, - d: &mut dyn DeserializeSeed<'de>, - ) -> Result<(Out, Variant<'de>), Error>; - } - impl<'de> dyn Deserializer<'de> { - /// Convert any Serde `Deserializer` to a trait object. - /// - /// ```rust - /// use erased_serde::Deserializer; - /// use std::collections::BTreeMap as Map; - /// - /// fn main() { - /// static JSON: &'static [u8] = br#"{"A": 65, "B": 66}"#; - /// static CBOR: &'static [u8] = &[162, 97, 65, 24, 65, 97, 66, 24, 66]; - /// - /// // Construct some deserializers. - /// let json = &mut serde_json::Deserializer::from_slice(JSON); - /// let cbor = &mut serde_cbor::Deserializer::from_slice(CBOR); - /// - /// // The values in this map are boxed trait objects, which is not possible - /// // with the normal serde::Deserializer because of object safety. - /// let mut formats: Map<&str, Box> = Map::new(); - /// formats.insert("json", Box::new(::erase(json))); - /// formats.insert("cbor", Box::new(::erase(cbor))); - /// - /// // Pick a Deserializer out of the formats map. - /// let format = formats.get_mut("json").unwrap(); - /// - /// let data: Map = erased_serde::deserialize(format).unwrap(); - /// - /// println!("{}", data["A"] + data["B"]); - /// } - /// ``` - pub fn erase(deserializer: D) -> erase::Deserializer - where - D: serde::Deserializer<'de>, - { - erase::Deserializer { - state: Some(deserializer), - } - } - } - pub struct Out(Any); - impl Out { - unsafe fn new(t: T) -> Self { - Out(unsafe { Any::new(t) }) - } - unsafe fn take(self) -> T { - unsafe { self.0.take() } - } - } - mod erase { - pub struct DeserializeSeed { - pub(crate) state: Option, - } - impl DeserializeSeed { - pub(crate) fn take(&mut self) -> D { - self.state.take().unwrap() - } - } - pub struct Deserializer { - pub(crate) state: Option, - } - impl Deserializer { - pub(crate) fn take(&mut self) -> D { - self.state.take().unwrap() - } - pub(crate) fn as_ref(&self) -> &D { - self.state.as_ref().unwrap() - } - } - pub struct Visitor { - pub(crate) state: Option, - } - impl Visitor { - pub(crate) fn take(&mut self) -> D { - self.state.take().unwrap() - } - pub(crate) fn as_ref(&self) -> &D { - self.state.as_ref().unwrap() - } - } - pub struct SeqAccess { - pub(crate) state: D, - } - impl SeqAccess { - pub(crate) fn as_ref(&self) -> &D { - &self.state - } - pub(crate) fn as_mut(&mut self) -> &mut D { - &mut self.state - } - } - pub struct MapAccess { - pub(crate) state: D, - } - impl MapAccess { - pub(crate) fn as_ref(&self) -> &D { - &self.state - } - pub(crate) fn as_mut(&mut self) -> &mut D { - &mut self.state - } - } - pub struct EnumAccess { - pub(crate) state: Option, - } - impl EnumAccess { - pub(crate) fn take(&mut self) -> D { - self.state.take().unwrap() - } - } - } - impl<'de, T> DeserializeSeed<'de> for erase::DeserializeSeed - where - T: serde::de::DeserializeSeed<'de>, - { - fn erased_deserialize_seed( - &mut self, - deserializer: &mut dyn Deserializer<'de>, - ) -> Result { - unsafe { self.take().deserialize(deserializer).unsafe_map(Out::new) } - } - } - impl<'de, T> Deserializer<'de> for erase::Deserializer - where - T: serde::Deserializer<'de>, - { - fn erased_deserialize_i128( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take().deserialize_i128(visitor).map_err(erase) - } - fn erased_deserialize_u128( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take().deserialize_u128(visitor).map_err(erase) - } - fn erased_deserialize_any(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_any(visitor).map_err(erase) - } - fn erased_deserialize_bool( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take().deserialize_bool(visitor).map_err(erase) - } - fn erased_deserialize_u8(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_u8(visitor).map_err(erase) - } - fn erased_deserialize_u16(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_u16(visitor).map_err(erase) - } - fn erased_deserialize_u32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_u32(visitor).map_err(erase) - } - fn erased_deserialize_u64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_u64(visitor).map_err(erase) - } - fn erased_deserialize_i8(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_i8(visitor).map_err(erase) - } - fn erased_deserialize_i16(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_i16(visitor).map_err(erase) - } - fn erased_deserialize_i32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_i32(visitor).map_err(erase) - } - fn erased_deserialize_i64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_i64(visitor).map_err(erase) - } - fn erased_deserialize_f32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_f32(visitor).map_err(erase) - } - fn erased_deserialize_f64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_f64(visitor).map_err(erase) - } - fn erased_deserialize_char( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take().deserialize_char(visitor).map_err(erase) - } - fn erased_deserialize_str(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_str(visitor).map_err(erase) - } - fn erased_deserialize_string( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take().deserialize_string(visitor).map_err(erase) - } - fn erased_deserialize_bytes( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take().deserialize_bytes(visitor).map_err(erase) - } - fn erased_deserialize_byte_buf( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take().deserialize_byte_buf(visitor).map_err(erase) - } - fn erased_deserialize_option( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take().deserialize_option(visitor).map_err(erase) - } - fn erased_deserialize_unit( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take().deserialize_unit(visitor).map_err(erase) - } - fn erased_deserialize_unit_struct( - &mut self, - name: &'static str, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take() - .deserialize_unit_struct(name, visitor) - .map_err(erase) - } - fn erased_deserialize_newtype_struct( - &mut self, - name: &'static str, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take() - .deserialize_newtype_struct(name, visitor) - .map_err(erase) - } - fn erased_deserialize_seq(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_seq(visitor).map_err(erase) - } - fn erased_deserialize_tuple( - &mut self, - len: usize, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take().deserialize_tuple(len, visitor).map_err(erase) - } - fn erased_deserialize_tuple_struct( - &mut self, - name: &'static str, - len: usize, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take() - .deserialize_tuple_struct(name, len, visitor) - .map_err(erase) - } - fn erased_deserialize_map(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - self.take().deserialize_map(visitor).map_err(erase) - } - fn erased_deserialize_struct( - &mut self, - name: &'static str, - fields: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take() - .deserialize_struct(name, fields, visitor) - .map_err(erase) - } - fn erased_deserialize_identifier( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take().deserialize_identifier(visitor).map_err(erase) - } - fn erased_deserialize_enum( - &mut self, - name: &'static str, - variants: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take() - .deserialize_enum(name, variants, visitor) - .map_err(erase) - } - fn erased_deserialize_ignored_any( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - self.take().deserialize_ignored_any(visitor).map_err(erase) - } - fn erased_is_human_readable(&self) -> bool { - self.as_ref().is_human_readable() - } - } - impl<'de, T> Visitor<'de> for erase::Visitor - where - T: serde::de::Visitor<'de>, - { - fn erased_visit_i128(&mut self, v: i128) -> Result { - unsafe { self.take().visit_i128(v).unsafe_map(Out::new) } - } - fn erased_visit_u128(&mut self, v: u128) -> Result { - unsafe { self.take().visit_u128(v).unsafe_map(Out::new) } - } - fn erased_expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - self.as_ref().expecting(formatter) - } - fn erased_visit_bool(&mut self, v: bool) -> Result { - unsafe { self.take().visit_bool(v).unsafe_map(Out::new) } - } - fn erased_visit_i8(&mut self, v: i8) -> Result { - unsafe { self.take().visit_i8(v).unsafe_map(Out::new) } - } - fn erased_visit_i16(&mut self, v: i16) -> Result { - unsafe { self.take().visit_i16(v).unsafe_map(Out::new) } - } - fn erased_visit_i32(&mut self, v: i32) -> Result { - unsafe { self.take().visit_i32(v).unsafe_map(Out::new) } - } - fn erased_visit_i64(&mut self, v: i64) -> Result { - unsafe { self.take().visit_i64(v).unsafe_map(Out::new) } - } - fn erased_visit_u8(&mut self, v: u8) -> Result { - unsafe { self.take().visit_u8(v).unsafe_map(Out::new) } - } - fn erased_visit_u16(&mut self, v: u16) -> Result { - unsafe { self.take().visit_u16(v).unsafe_map(Out::new) } - } - fn erased_visit_u32(&mut self, v: u32) -> Result { - unsafe { self.take().visit_u32(v).unsafe_map(Out::new) } - } - fn erased_visit_u64(&mut self, v: u64) -> Result { - unsafe { self.take().visit_u64(v).unsafe_map(Out::new) } - } - fn erased_visit_f32(&mut self, v: f32) -> Result { - unsafe { self.take().visit_f32(v).unsafe_map(Out::new) } - } - fn erased_visit_f64(&mut self, v: f64) -> Result { - unsafe { self.take().visit_f64(v).unsafe_map(Out::new) } - } - fn erased_visit_char(&mut self, v: char) -> Result { - unsafe { self.take().visit_char(v).unsafe_map(Out::new) } - } - fn erased_visit_str(&mut self, v: &str) -> Result { - unsafe { self.take().visit_str(v).unsafe_map(Out::new) } - } - fn erased_visit_borrowed_str(&mut self, v: &'de str) -> Result { - unsafe { self.take().visit_borrowed_str(v).unsafe_map(Out::new) } - } - fn erased_visit_string(&mut self, v: String) -> Result { - unsafe { self.take().visit_string(v).unsafe_map(Out::new) } - } - fn erased_visit_bytes(&mut self, v: &[u8]) -> Result { - unsafe { self.take().visit_bytes(v).unsafe_map(Out::new) } - } - fn erased_visit_borrowed_bytes(&mut self, v: &'de [u8]) -> Result { - unsafe { self.take().visit_borrowed_bytes(v).unsafe_map(Out::new) } - } - fn erased_visit_byte_buf(&mut self, v: Vec) -> Result { - unsafe { self.take().visit_byte_buf(v).unsafe_map(Out::new) } - } - fn erased_visit_none(&mut self) -> Result { - unsafe { self.take().visit_none().unsafe_map(Out::new) } - } - fn erased_visit_some( - &mut self, - deserializer: &mut dyn Deserializer<'de>, - ) -> Result { - unsafe { self.take().visit_some(deserializer).unsafe_map(Out::new) } - } - fn erased_visit_unit(&mut self) -> Result { - unsafe { self.take().visit_unit().unsafe_map(Out::new) } - } - fn erased_visit_newtype_struct( - &mut self, - deserializer: &mut dyn Deserializer<'de>, - ) -> Result { - unsafe { - self.take() - .visit_newtype_struct(deserializer) - .unsafe_map(Out::new) - } - } - fn erased_visit_seq(&mut self, seq: &mut dyn SeqAccess<'de>) -> Result { - unsafe { self.take().visit_seq(seq).unsafe_map(Out::new) } - } - fn erased_visit_map(&mut self, map: &mut dyn MapAccess<'de>) -> Result { - unsafe { self.take().visit_map(map).unsafe_map(Out::new) } - } - fn erased_visit_enum(&mut self, data: &mut dyn EnumAccess<'de>) -> Result { - unsafe { self.take().visit_enum(data).unsafe_map(Out::new) } - } - } - impl<'de, T> SeqAccess<'de> for erase::SeqAccess - where - T: serde::de::SeqAccess<'de>, - { - fn erased_next_element( - &mut self, - seed: &mut dyn DeserializeSeed<'de>, - ) -> Result, Error> { - self.as_mut().next_element_seed(seed).map_err(erase) - } - fn erased_size_hint(&self) -> Option { - self.as_ref().size_hint() - } - } - impl<'de, T> MapAccess<'de> for erase::MapAccess - where - T: serde::de::MapAccess<'de>, - { - fn erased_next_key( - &mut self, - seed: &mut dyn DeserializeSeed<'de>, - ) -> Result, Error> { - self.as_mut().next_key_seed(seed).map_err(erase) - } - fn erased_next_value(&mut self, seed: &mut dyn DeserializeSeed<'de>) -> Result { - self.as_mut().next_value_seed(seed).map_err(erase) - } - fn erased_next_entry( - &mut self, - k: &mut dyn DeserializeSeed<'de>, - v: &mut dyn DeserializeSeed<'de>, - ) -> Result, Error> { - self.as_mut().next_entry_seed(k, v).map_err(erase) - } - fn erased_size_hint(&self) -> Option { - self.as_ref().size_hint() - } - } - impl<'de, T> EnumAccess<'de> for erase::EnumAccess - where - T: serde::de::EnumAccess<'de>, - { - fn erased_variant_seed( - &mut self, - seed: &mut dyn DeserializeSeed<'de>, - ) -> Result<(Out, Variant<'de>), Error> { - self.take() - .variant_seed(seed) - .map(|(out, variant)| { - use serde::de::VariantAccess; - let erased = Variant { - data: unsafe { Any::new(variant) }, - unit_variant: { - unsafe fn unit_variant<'de, T>(a: Any) -> Result<(), Error> - where - T: serde::de::EnumAccess<'de>, - { - unsafe { a.take::().unit_variant().map_err(erase) } - } - unit_variant:: - }, - visit_newtype: { - unsafe fn visit_newtype<'de, T>( - a: Any, - seed: &mut dyn DeserializeSeed<'de>, - ) -> Result - where - T: serde::de::EnumAccess<'de>, - { - unsafe { - a.take::() - .newtype_variant_seed(seed) - .map_err(erase) - } - } - visit_newtype:: - }, - tuple_variant: { - unsafe fn tuple_variant<'de, T>( - a: Any, - len: usize, - visitor: &mut dyn Visitor<'de>, - ) -> Result - where - T: serde::de::EnumAccess<'de>, - { - unsafe { - a.take::() - .tuple_variant(len, visitor) - .map_err(erase) - } - } - tuple_variant:: - }, - struct_variant: { - unsafe fn struct_variant<'de, T>( - a: Any, - fields: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result - where - T: serde::de::EnumAccess<'de>, - { - unsafe { - a.take::() - .struct_variant(fields, visitor) - .map_err(erase) - } - } - struct_variant:: - }, - }; - (out, erased) - }) - .map_err(erase) - } - } - impl<'de, 'a> serde::de::DeserializeSeed<'de> for &'a mut dyn DeserializeSeed<'de> { - type Value = Out; - fn deserialize(self, deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let mut erased = erase::Deserializer { - state: Some(deserializer), - }; - self.erased_deserialize_seed(&mut erased).map_err(unerase) - } - } - impl<'de, 'a> serde::Deserializer<'de> for &'a mut dyn Deserializer<'de> { - type Error = Error; - fn deserialize_any(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bool(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bool(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u8(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u16(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u32(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u64(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i8(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i16(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i32(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i64(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i128(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u128(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f32(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f64(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_char(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_char(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_str(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_str(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_string(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_string(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bytes(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bytes(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_byte_buf(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_byte_buf(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_option(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_option(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit_struct( - self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_newtype_struct( - self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_newtype_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_seq(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_seq(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple(self, len: usize, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple(len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple_struct( - self, - name: &'static str, - len: usize, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple_struct(name, len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_map(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_map(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_struct( - self, - name: &'static str, - fields: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_struct(name, fields, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_identifier(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_identifier(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_enum( - self, - name: &'static str, - variants: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_enum(name, variants, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_ignored_any(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_ignored_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn is_human_readable(&self) -> bool { - self.erased_is_human_readable() - } - } - impl<'de, 'a> serde::Deserializer<'de> for &'a mut (dyn Deserializer<'de> + Send) { - type Error = Error; - fn deserialize_any(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bool(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bool(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u8(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u16(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u32(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u64(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i8(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i16(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i32(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i64(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i128(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u128(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f32(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f64(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_char(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_char(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_str(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_str(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_string(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_string(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bytes(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bytes(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_byte_buf(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_byte_buf(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_option(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_option(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit_struct( - self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_newtype_struct( - self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_newtype_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_seq(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_seq(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple(self, len: usize, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple(len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple_struct( - self, - name: &'static str, - len: usize, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple_struct(name, len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_map(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_map(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_struct( - self, - name: &'static str, - fields: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_struct(name, fields, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_identifier(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_identifier(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_enum( - self, - name: &'static str, - variants: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_enum(name, variants, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_ignored_any(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_ignored_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn is_human_readable(&self) -> bool { - self.erased_is_human_readable() - } - } - impl<'de, 'a> serde::Deserializer<'de> for &'a mut (dyn Deserializer<'de> + Sync) { - type Error = Error; - fn deserialize_any(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bool(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bool(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u8(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u16(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u32(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u64(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i8(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i16(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i32(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i64(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i128(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u128(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f32(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f64(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_char(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_char(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_str(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_str(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_string(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_string(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bytes(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bytes(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_byte_buf(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_byte_buf(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_option(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_option(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit_struct( - self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_newtype_struct( - self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_newtype_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_seq(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_seq(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple(self, len: usize, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple(len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple_struct( - self, - name: &'static str, - len: usize, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple_struct(name, len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_map(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_map(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_struct( - self, - name: &'static str, - fields: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_struct(name, fields, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_identifier(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_identifier(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_enum( - self, - name: &'static str, - variants: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_enum(name, variants, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_ignored_any(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_ignored_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn is_human_readable(&self) -> bool { - self.erased_is_human_readable() - } - } - impl<'de, 'a> serde::Deserializer<'de> for &'a mut (dyn Deserializer<'de> + Send + Sync) { - type Error = Error; - fn deserialize_any(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bool(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bool(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u8(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u16(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u32(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u64(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i8(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i16(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i32(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i64(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i128(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u128(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f32(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f64(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_char(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_char(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_str(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_str(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_string(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_string(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bytes(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bytes(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_byte_buf(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_byte_buf(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_option(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_option(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit_struct( - self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_newtype_struct( - self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_newtype_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_seq(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_seq(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple(self, len: usize, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple(len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple_struct( - self, - name: &'static str, - len: usize, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple_struct(name, len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_map(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_map(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_struct( - self, - name: &'static str, - fields: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_struct(name, fields, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_identifier(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_identifier(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_enum( - self, - name: &'static str, - variants: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_enum(name, variants, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_ignored_any(self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_ignored_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn is_human_readable(&self) -> bool { - self.erased_is_human_readable() - } - } - impl<'de> serde::Deserializer<'de> for Box> { - type Error = Error; - fn deserialize_any(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bool(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bool(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u8(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u16(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u32(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u64(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i8(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i16(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i32(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i64(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i128(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u128(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f32(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f64(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_char(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_char(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_str(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_str(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_string(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_string(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bytes(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bytes(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_byte_buf(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_byte_buf(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_option(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_option(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit_struct( - mut self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_newtype_struct( - mut self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_newtype_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_seq(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_seq(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple(mut self, len: usize, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple(len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple_struct( - mut self, - name: &'static str, - len: usize, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple_struct(name, len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_map(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_map(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_struct( - mut self, - name: &'static str, - fields: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_struct(name, fields, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_identifier(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_identifier(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_enum( - mut self, - name: &'static str, - variants: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_enum(name, variants, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_ignored_any(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_ignored_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn is_human_readable(&self) -> bool { - self.erased_is_human_readable() - } - } - impl<'de> serde::Deserializer<'de> for Box + Send> { - type Error = Error; - fn deserialize_any(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bool(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bool(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u8(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u16(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u32(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u64(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i8(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i16(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i32(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i64(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i128(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u128(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f32(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f64(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_char(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_char(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_str(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_str(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_string(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_string(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bytes(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bytes(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_byte_buf(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_byte_buf(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_option(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_option(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit_struct( - mut self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_newtype_struct( - mut self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_newtype_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_seq(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_seq(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple(mut self, len: usize, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple(len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple_struct( - mut self, - name: &'static str, - len: usize, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple_struct(name, len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_map(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_map(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_struct( - mut self, - name: &'static str, - fields: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_struct(name, fields, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_identifier(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_identifier(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_enum( - mut self, - name: &'static str, - variants: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_enum(name, variants, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_ignored_any(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_ignored_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn is_human_readable(&self) -> bool { - self.erased_is_human_readable() - } - } - impl<'de> serde::Deserializer<'de> for Box + Sync> { - type Error = Error; - fn deserialize_any(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bool(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bool(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u8(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u16(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u32(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u64(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i8(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i16(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i32(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i64(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i128(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u128(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f32(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f64(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_char(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_char(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_str(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_str(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_string(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_string(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bytes(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bytes(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_byte_buf(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_byte_buf(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_option(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_option(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit_struct( - mut self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_newtype_struct( - mut self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_newtype_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_seq(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_seq(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple(mut self, len: usize, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple(len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple_struct( - mut self, - name: &'static str, - len: usize, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple_struct(name, len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_map(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_map(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_struct( - mut self, - name: &'static str, - fields: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_struct(name, fields, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_identifier(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_identifier(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_enum( - mut self, - name: &'static str, - variants: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_enum(name, variants, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_ignored_any(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_ignored_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn is_human_readable(&self) -> bool { - self.erased_is_human_readable() - } - } - impl<'de> serde::Deserializer<'de> for Box + Send + Sync> { - type Error = Error; - fn deserialize_any(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bool(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bool(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u8(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u16(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u32(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u64(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i8(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i8(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i16(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i16(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i32(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i64(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_i128(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_i128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_u128(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_u128(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f32(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f32(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_f64(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_f64(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_char(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_char(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_str(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_str(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_string(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_string(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_bytes(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_bytes(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_byte_buf(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_byte_buf(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_option(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_option(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_unit_struct( - mut self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_unit_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_newtype_struct( - mut self, - name: &'static str, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_newtype_struct(name, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_seq(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_seq(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple(mut self, len: usize, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple(len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_tuple_struct( - mut self, - name: &'static str, - len: usize, - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_tuple_struct(name, len, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_map(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_map(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_struct( - mut self, - name: &'static str, - fields: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_struct(name, fields, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_identifier(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_identifier(&mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_enum( - mut self, - name: &'static str, - variants: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_enum(name, variants, &mut erased) - .unsafe_map(Out::take) - } - } - fn deserialize_ignored_any(mut self, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { - self.erased_deserialize_ignored_any(&mut erased) - .unsafe_map(Out::take) - } - } - fn is_human_readable(&self) -> bool { - self.erased_is_human_readable() - } - } - impl<'de, 'a> serde::de::Visitor<'de> for &'a mut dyn Visitor<'de> { - type Value = Out; - fn visit_i128(self, v: i128) -> Result - where - E: serde::de::Error, - { - self.erased_visit_i128(v).map_err(unerase) - } - fn visit_u128(self, v: u128) -> Result - where - E: serde::de::Error, - { - self.erased_visit_u128(v).map_err(unerase) - } - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - (**self).erased_expecting(formatter) - } - fn visit_bool(self, v: bool) -> Result - where - E: serde::de::Error, - { - self.erased_visit_bool(v).map_err(unerase) - } - fn visit_i8(self, v: i8) -> Result - where - E: serde::de::Error, - { - self.erased_visit_i8(v).map_err(unerase) - } - fn visit_i16(self, v: i16) -> Result - where - E: serde::de::Error, - { - self.erased_visit_i16(v).map_err(unerase) - } - fn visit_i32(self, v: i32) -> Result - where - E: serde::de::Error, - { - self.erased_visit_i32(v).map_err(unerase) - } - fn visit_i64(self, v: i64) -> Result - where - E: serde::de::Error, - { - self.erased_visit_i64(v).map_err(unerase) - } - fn visit_u8(self, v: u8) -> Result - where - E: serde::de::Error, - { - self.erased_visit_u8(v).map_err(unerase) - } - fn visit_u16(self, v: u16) -> Result - where - E: serde::de::Error, - { - self.erased_visit_u16(v).map_err(unerase) - } - fn visit_u32(self, v: u32) -> Result - where - E: serde::de::Error, - { - self.erased_visit_u32(v).map_err(unerase) - } - fn visit_u64(self, v: u64) -> Result - where - E: serde::de::Error, - { - self.erased_visit_u64(v).map_err(unerase) - } - fn visit_f32(self, v: f32) -> Result - where - E: serde::de::Error, - { - self.erased_visit_f32(v).map_err(unerase) - } - fn visit_f64(self, v: f64) -> Result - where - E: serde::de::Error, - { - self.erased_visit_f64(v).map_err(unerase) - } - fn visit_char(self, v: char) -> Result - where - E: serde::de::Error, - { - self.erased_visit_char(v).map_err(unerase) - } - fn visit_str(self, v: &str) -> Result - where - E: serde::de::Error, - { - self.erased_visit_str(v).map_err(unerase) - } - fn visit_borrowed_str(self, v: &'de str) -> Result - where - E: serde::de::Error, - { - self.erased_visit_borrowed_str(v).map_err(unerase) - } - fn visit_string(self, v: String) -> Result - where - E: serde::de::Error, - { - self.erased_visit_string(v).map_err(unerase) - } - fn visit_bytes(self, v: &[u8]) -> Result - where - E: serde::de::Error, - { - self.erased_visit_bytes(v).map_err(unerase) - } - fn visit_borrowed_bytes(self, v: &'de [u8]) -> Result - where - E: serde::de::Error, - { - self.erased_visit_borrowed_bytes(v).map_err(unerase) - } - fn visit_byte_buf(self, v: Vec) -> Result - where - E: serde::de::Error, - { - self.erased_visit_byte_buf(v).map_err(unerase) - } - fn visit_none(self) -> Result - where - E: serde::de::Error, - { - self.erased_visit_none().map_err(unerase) - } - fn visit_some(self, deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let mut erased = erase::Deserializer { - state: Some(deserializer), - }; - self.erased_visit_some(&mut erased).map_err(unerase) - } - fn visit_unit(self) -> Result - where - E: serde::de::Error, - { - self.erased_visit_unit().map_err(unerase) - } - fn visit_newtype_struct(self, deserializer: D) -> Result - where - D: serde::Deserializer<'de>, - { - let mut erased = erase::Deserializer { - state: Some(deserializer), - }; - self.erased_visit_newtype_struct(&mut erased) - .map_err(unerase) - } - fn visit_seq(self, seq: V) -> Result - where - V: serde::de::SeqAccess<'de>, - { - let mut erased = erase::SeqAccess { state: seq }; - self.erased_visit_seq(&mut erased).map_err(unerase) - } - fn visit_map(self, map: V) -> Result - where - V: serde::de::MapAccess<'de>, - { - let mut erased = erase::MapAccess { state: map }; - self.erased_visit_map(&mut erased).map_err(unerase) - } - fn visit_enum(self, data: V) -> Result - where - V: serde::de::EnumAccess<'de>, - { - let mut erased = erase::EnumAccess { state: Some(data) }; - self.erased_visit_enum(&mut erased).map_err(unerase) - } - } - impl<'de, 'a> serde::de::SeqAccess<'de> for &'a mut dyn SeqAccess<'de> { - type Error = Error; - fn next_element_seed(&mut self, seed: T) -> Result, Error> - where - T: serde::de::DeserializeSeed<'de>, - { - let mut seed = erase::DeserializeSeed { state: Some(seed) }; - unsafe { - (**self) - .erased_next_element(&mut seed) - .map(|opt| opt.unsafe_map(Out::take)) - } - } - fn size_hint(&self) -> Option { - (**self).erased_size_hint() - } - } - impl<'de, 'a> serde::de::MapAccess<'de> for &'a mut dyn MapAccess<'de> { - type Error = Error; - fn next_key_seed(&mut self, seed: K) -> Result, Error> - where - K: serde::de::DeserializeSeed<'de>, - { - let mut erased = erase::DeserializeSeed { state: Some(seed) }; - unsafe { - (**self) - .erased_next_key(&mut erased) - .map(|opt| opt.unsafe_map(Out::take)) - } - } - fn next_value_seed(&mut self, seed: V) -> Result - where - V: serde::de::DeserializeSeed<'de>, - { - let mut erased = erase::DeserializeSeed { state: Some(seed) }; - unsafe { - (**self) - .erased_next_value(&mut erased) - .unsafe_map(Out::take) - } - } - fn size_hint(&self) -> Option { - (**self).erased_size_hint() - } - } - impl<'de, 'a> serde::de::EnumAccess<'de> for &'a mut dyn EnumAccess<'de> { - type Error = Error; - type Variant = Variant<'de>; - fn variant_seed(self, seed: V) -> Result<(V::Value, Self::Variant), Self::Error> - where - V: serde::de::DeserializeSeed<'de>, - { - let mut erased = erase::DeserializeSeed { state: Some(seed) }; - match self.erased_variant_seed(&mut erased) { - Ok((out, variant)) => Ok((unsafe { out.take() }, variant)), - Err(err) => Err(err), - } - } - } - pub struct Variant<'de> { - data: Any, - unit_variant: unsafe fn(Any) -> Result<(), Error>, - visit_newtype: unsafe fn(Any, seed: &mut dyn DeserializeSeed<'de>) -> Result, - tuple_variant: - unsafe fn(Any, len: usize, visitor: &mut dyn Visitor<'de>) -> Result, - struct_variant: unsafe fn( - Any, - fields: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result, - } - impl<'de> serde::de::VariantAccess<'de> for Variant<'de> { - type Error = Error; - fn unit_variant(self) -> Result<(), Error> { - unsafe { (self.unit_variant)(self.data) } - } - fn newtype_variant_seed(self, seed: T) -> Result - where - T: serde::de::DeserializeSeed<'de>, - { - let mut erased = erase::DeserializeSeed { state: Some(seed) }; - unsafe { (self.visit_newtype)(self.data, &mut erased).unsafe_map(Out::take) } - } - fn tuple_variant(self, len: usize, visitor: V) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { (self.tuple_variant)(self.data, len, &mut erased).unsafe_map(Out::take) } - } - fn struct_variant( - self, - fields: &'static [&'static str], - visitor: V, - ) -> Result - where - V: serde::de::Visitor<'de>, - { - let mut erased = erase::Visitor { - state: Some(visitor), - }; - unsafe { (self.struct_variant)(self.data, fields, &mut erased).unsafe_map(Out::take) } - } - } - impl<'de, 'a> Deserializer<'de> for Box + 'a> { - fn erased_deserialize_any(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_any(visitor) - } - fn erased_deserialize_bool( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_bool(visitor) - } - fn erased_deserialize_u8(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u8(visitor) - } - fn erased_deserialize_u16(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u16(visitor) - } - fn erased_deserialize_u32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u32(visitor) - } - fn erased_deserialize_u64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u64(visitor) - } - fn erased_deserialize_i8(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i8(visitor) - } - fn erased_deserialize_i16(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i16(visitor) - } - fn erased_deserialize_i32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i32(visitor) - } - fn erased_deserialize_i64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i64(visitor) - } - fn erased_deserialize_i128( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_i128(visitor) - } - fn erased_deserialize_u128( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_u128(visitor) - } - fn erased_deserialize_f32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_f32(visitor) - } - fn erased_deserialize_f64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_f64(visitor) - } - fn erased_deserialize_char( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_char(visitor) - } - fn erased_deserialize_str(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_str(visitor) - } - fn erased_deserialize_string( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_string(visitor) - } - fn erased_deserialize_bytes( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_bytes(visitor) - } - fn erased_deserialize_byte_buf( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_byte_buf(visitor) - } - fn erased_deserialize_option( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_option(visitor) - } - fn erased_deserialize_unit( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_unit(visitor) - } - fn erased_deserialize_unit_struct( - &mut self, - name: &'static str, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_unit_struct(name, visitor) - } - fn erased_deserialize_newtype_struct( - &mut self, - name: &'static str, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_newtype_struct(name, visitor) - } - fn erased_deserialize_seq(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_seq(visitor) - } - fn erased_deserialize_tuple( - &mut self, - len: usize, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_tuple(len, visitor) - } - fn erased_deserialize_tuple_struct( - &mut self, - name: &'static str, - len: usize, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_tuple_struct(name, len, visitor) - } - fn erased_deserialize_map(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_map(visitor) - } - fn erased_deserialize_struct( - &mut self, - name: &'static str, - fields: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_struct(name, fields, visitor) - } - fn erased_deserialize_identifier( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_identifier(visitor) - } - fn erased_deserialize_enum( - &mut self, - name: &'static str, - variants: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_enum(name, variants, visitor) - } - fn erased_deserialize_ignored_any( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_ignored_any(visitor) - } - fn erased_is_human_readable(&self) -> bool { - (**self).erased_is_human_readable() - } - } - impl<'de, 'a> Deserializer<'de> for Box + Send + 'a> { - fn erased_deserialize_any(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_any(visitor) - } - fn erased_deserialize_bool( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_bool(visitor) - } - fn erased_deserialize_u8(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u8(visitor) - } - fn erased_deserialize_u16(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u16(visitor) - } - fn erased_deserialize_u32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u32(visitor) - } - fn erased_deserialize_u64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u64(visitor) - } - fn erased_deserialize_i8(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i8(visitor) - } - fn erased_deserialize_i16(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i16(visitor) - } - fn erased_deserialize_i32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i32(visitor) - } - fn erased_deserialize_i64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i64(visitor) - } - fn erased_deserialize_i128( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_i128(visitor) - } - fn erased_deserialize_u128( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_u128(visitor) - } - fn erased_deserialize_f32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_f32(visitor) - } - fn erased_deserialize_f64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_f64(visitor) - } - fn erased_deserialize_char( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_char(visitor) - } - fn erased_deserialize_str(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_str(visitor) - } - fn erased_deserialize_string( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_string(visitor) - } - fn erased_deserialize_bytes( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_bytes(visitor) - } - fn erased_deserialize_byte_buf( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_byte_buf(visitor) - } - fn erased_deserialize_option( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_option(visitor) - } - fn erased_deserialize_unit( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_unit(visitor) - } - fn erased_deserialize_unit_struct( - &mut self, - name: &'static str, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_unit_struct(name, visitor) - } - fn erased_deserialize_newtype_struct( - &mut self, - name: &'static str, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_newtype_struct(name, visitor) - } - fn erased_deserialize_seq(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_seq(visitor) - } - fn erased_deserialize_tuple( - &mut self, - len: usize, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_tuple(len, visitor) - } - fn erased_deserialize_tuple_struct( - &mut self, - name: &'static str, - len: usize, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_tuple_struct(name, len, visitor) - } - fn erased_deserialize_map(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_map(visitor) - } - fn erased_deserialize_struct( - &mut self, - name: &'static str, - fields: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_struct(name, fields, visitor) - } - fn erased_deserialize_identifier( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_identifier(visitor) - } - fn erased_deserialize_enum( - &mut self, - name: &'static str, - variants: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_enum(name, variants, visitor) - } - fn erased_deserialize_ignored_any( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_ignored_any(visitor) - } - fn erased_is_human_readable(&self) -> bool { - (**self).erased_is_human_readable() - } - } - impl<'de, 'a> Deserializer<'de> for Box + Sync + 'a> { - fn erased_deserialize_any(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_any(visitor) - } - fn erased_deserialize_bool( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_bool(visitor) - } - fn erased_deserialize_u8(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u8(visitor) - } - fn erased_deserialize_u16(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u16(visitor) - } - fn erased_deserialize_u32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u32(visitor) - } - fn erased_deserialize_u64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u64(visitor) - } - fn erased_deserialize_i8(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i8(visitor) - } - fn erased_deserialize_i16(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i16(visitor) - } - fn erased_deserialize_i32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i32(visitor) - } - fn erased_deserialize_i64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i64(visitor) - } - fn erased_deserialize_i128( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_i128(visitor) - } - fn erased_deserialize_u128( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_u128(visitor) - } - fn erased_deserialize_f32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_f32(visitor) - } - fn erased_deserialize_f64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_f64(visitor) - } - fn erased_deserialize_char( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_char(visitor) - } - fn erased_deserialize_str(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_str(visitor) - } - fn erased_deserialize_string( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_string(visitor) - } - fn erased_deserialize_bytes( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_bytes(visitor) - } - fn erased_deserialize_byte_buf( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_byte_buf(visitor) - } - fn erased_deserialize_option( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_option(visitor) - } - fn erased_deserialize_unit( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_unit(visitor) - } - fn erased_deserialize_unit_struct( - &mut self, - name: &'static str, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_unit_struct(name, visitor) - } - fn erased_deserialize_newtype_struct( - &mut self, - name: &'static str, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_newtype_struct(name, visitor) - } - fn erased_deserialize_seq(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_seq(visitor) - } - fn erased_deserialize_tuple( - &mut self, - len: usize, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_tuple(len, visitor) - } - fn erased_deserialize_tuple_struct( - &mut self, - name: &'static str, - len: usize, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_tuple_struct(name, len, visitor) - } - fn erased_deserialize_map(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_map(visitor) - } - fn erased_deserialize_struct( - &mut self, - name: &'static str, - fields: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_struct(name, fields, visitor) - } - fn erased_deserialize_identifier( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_identifier(visitor) - } - fn erased_deserialize_enum( - &mut self, - name: &'static str, - variants: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_enum(name, variants, visitor) - } - fn erased_deserialize_ignored_any( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_ignored_any(visitor) - } - fn erased_is_human_readable(&self) -> bool { - (**self).erased_is_human_readable() - } - } - impl<'de, 'a> Deserializer<'de> for Box + Send + Sync + 'a> { - fn erased_deserialize_any(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_any(visitor) - } - fn erased_deserialize_bool( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_bool(visitor) - } - fn erased_deserialize_u8(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u8(visitor) - } - fn erased_deserialize_u16(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u16(visitor) - } - fn erased_deserialize_u32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u32(visitor) - } - fn erased_deserialize_u64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u64(visitor) - } - fn erased_deserialize_i8(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i8(visitor) - } - fn erased_deserialize_i16(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i16(visitor) - } - fn erased_deserialize_i32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i32(visitor) - } - fn erased_deserialize_i64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i64(visitor) - } - fn erased_deserialize_i128( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_i128(visitor) - } - fn erased_deserialize_u128( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_u128(visitor) - } - fn erased_deserialize_f32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_f32(visitor) - } - fn erased_deserialize_f64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_f64(visitor) - } - fn erased_deserialize_char( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_char(visitor) - } - fn erased_deserialize_str(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_str(visitor) - } - fn erased_deserialize_string( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_string(visitor) - } - fn erased_deserialize_bytes( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_bytes(visitor) - } - fn erased_deserialize_byte_buf( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_byte_buf(visitor) - } - fn erased_deserialize_option( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_option(visitor) - } - fn erased_deserialize_unit( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_unit(visitor) - } - fn erased_deserialize_unit_struct( - &mut self, - name: &'static str, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_unit_struct(name, visitor) - } - fn erased_deserialize_newtype_struct( - &mut self, - name: &'static str, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_newtype_struct(name, visitor) - } - fn erased_deserialize_seq(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_seq(visitor) - } - fn erased_deserialize_tuple( - &mut self, - len: usize, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_tuple(len, visitor) - } - fn erased_deserialize_tuple_struct( - &mut self, - name: &'static str, - len: usize, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_tuple_struct(name, len, visitor) - } - fn erased_deserialize_map(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_map(visitor) - } - fn erased_deserialize_struct( - &mut self, - name: &'static str, - fields: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_struct(name, fields, visitor) - } - fn erased_deserialize_identifier( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_identifier(visitor) - } - fn erased_deserialize_enum( - &mut self, - name: &'static str, - variants: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_enum(name, variants, visitor) - } - fn erased_deserialize_ignored_any( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_ignored_any(visitor) - } - fn erased_is_human_readable(&self) -> bool { - (**self).erased_is_human_readable() - } - } - impl<'de, 'a, T: ?Sized + Deserializer<'de>> Deserializer<'de> for &'a mut T { - fn erased_deserialize_any(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_any(visitor) - } - fn erased_deserialize_bool( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_bool(visitor) - } - fn erased_deserialize_u8(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u8(visitor) - } - fn erased_deserialize_u16(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u16(visitor) - } - fn erased_deserialize_u32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u32(visitor) - } - fn erased_deserialize_u64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_u64(visitor) - } - fn erased_deserialize_i8(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i8(visitor) - } - fn erased_deserialize_i16(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i16(visitor) - } - fn erased_deserialize_i32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i32(visitor) - } - fn erased_deserialize_i64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_i64(visitor) - } - fn erased_deserialize_i128( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_i128(visitor) - } - fn erased_deserialize_u128( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_u128(visitor) - } - fn erased_deserialize_f32(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_f32(visitor) - } - fn erased_deserialize_f64(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_f64(visitor) - } - fn erased_deserialize_char( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_char(visitor) - } - fn erased_deserialize_str(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_str(visitor) - } - fn erased_deserialize_string( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_string(visitor) - } - fn erased_deserialize_bytes( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_bytes(visitor) - } - fn erased_deserialize_byte_buf( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_byte_buf(visitor) - } - fn erased_deserialize_option( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_option(visitor) - } - fn erased_deserialize_unit( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_unit(visitor) - } - fn erased_deserialize_unit_struct( - &mut self, - name: &'static str, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_unit_struct(name, visitor) - } - fn erased_deserialize_newtype_struct( - &mut self, - name: &'static str, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_newtype_struct(name, visitor) - } - fn erased_deserialize_seq(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_seq(visitor) - } - fn erased_deserialize_tuple( - &mut self, - len: usize, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_tuple(len, visitor) - } - fn erased_deserialize_tuple_struct( - &mut self, - name: &'static str, - len: usize, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_tuple_struct(name, len, visitor) - } - fn erased_deserialize_map(&mut self, visitor: &mut dyn Visitor<'de>) -> Result { - (**self).erased_deserialize_map(visitor) - } - fn erased_deserialize_struct( - &mut self, - name: &'static str, - fields: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_struct(name, fields, visitor) - } - fn erased_deserialize_identifier( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_identifier(visitor) - } - fn erased_deserialize_enum( - &mut self, - name: &'static str, - variants: &'static [&'static str], - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_enum(name, variants, visitor) - } - fn erased_deserialize_ignored_any( - &mut self, - visitor: &mut dyn Visitor<'de>, - ) -> Result { - (**self).erased_deserialize_ignored_any(visitor) - } - fn erased_is_human_readable(&self) -> bool { - (**self).erased_is_human_readable() - } - } - fn erase(e: E) -> Error - where - E: Display, - { - serde::de::Error::custom(e) - } - fn unerase(e: Error) -> E - where - E: serde::de::Error, - { - E::custom(e) - } -} -mod error { - pub(crate) use crate::Error; -} -mod map { - pub(crate) trait ResultExt { - unsafe fn unsafe_map(self, op: unsafe fn(T) -> U) -> Result; - } - impl ResultExt for Result { - unsafe fn unsafe_map(self, op: unsafe fn(T) -> U) -> Result { - match self { - Ok(t) => Ok(unsafe { op(t) }), - Err(e) => Err(e), - } - } - } - pub(crate) trait OptionExt { - unsafe fn unsafe_map(self, op: unsafe fn(T) -> U) -> Option; - } - impl OptionExt for Option { - unsafe fn unsafe_map(self, op: unsafe fn(T) -> U) -> Option { - match self { - Some(t) => Some(unsafe { op(t) }), - None => None, - } - } - } -} -#[allow(clippy::all)] -mod serde_wasm_host { - #[repr(C)] - pub struct Usize { - pub size: u32, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for Usize {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for Usize { - #[inline] - fn clone(&self) -> Usize { - { - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - impl core::fmt::Debug for Usize { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("Usize").field("size", &self.size).finish() - } - } - pub enum Unexpected<'a> { - Bool(bool), - Unsigned(u64), - Signed(i64), - Float(f64), - Char(char), - Str(&'a str), - Bytes(&'a [u8]), - Unit, - Option, - NewtypeStruct, - Seq, - Map, - Enum, - UnitVariant, - NewtypeVariant, - TupleVariant, - StructVariant, - Other(&'a str), - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl<'a> ::core::clone::Clone for Unexpected<'a> { - #[inline] - fn clone(&self) -> Unexpected<'a> { - match (&*self,) { - (&Unexpected::Bool(ref __self_0),) => { - Unexpected::Bool(::core::clone::Clone::clone(&(*__self_0))) - } - (&Unexpected::Unsigned(ref __self_0),) => { - Unexpected::Unsigned(::core::clone::Clone::clone(&(*__self_0))) - } - (&Unexpected::Signed(ref __self_0),) => { - Unexpected::Signed(::core::clone::Clone::clone(&(*__self_0))) - } - (&Unexpected::Float(ref __self_0),) => { - Unexpected::Float(::core::clone::Clone::clone(&(*__self_0))) - } - (&Unexpected::Char(ref __self_0),) => { - Unexpected::Char(::core::clone::Clone::clone(&(*__self_0))) - } - (&Unexpected::Str(ref __self_0),) => { - Unexpected::Str(::core::clone::Clone::clone(&(*__self_0))) - } - (&Unexpected::Bytes(ref __self_0),) => { - Unexpected::Bytes(::core::clone::Clone::clone(&(*__self_0))) - } - (&Unexpected::Unit,) => Unexpected::Unit, - (&Unexpected::Option,) => Unexpected::Option, - (&Unexpected::NewtypeStruct,) => Unexpected::NewtypeStruct, - (&Unexpected::Seq,) => Unexpected::Seq, - (&Unexpected::Map,) => Unexpected::Map, - (&Unexpected::Enum,) => Unexpected::Enum, - (&Unexpected::UnitVariant,) => Unexpected::UnitVariant, - (&Unexpected::NewtypeVariant,) => Unexpected::NewtypeVariant, - (&Unexpected::TupleVariant,) => Unexpected::TupleVariant, - (&Unexpected::StructVariant,) => Unexpected::StructVariant, - (&Unexpected::Other(ref __self_0),) => { - Unexpected::Other(::core::clone::Clone::clone(&(*__self_0))) - } - } - } - } - impl<'a> core::fmt::Debug for Unexpected<'a> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - match self { - Unexpected::Bool(e) => f.debug_tuple("Unexpected::Bool").field(e).finish(), - Unexpected::Unsigned(e) => f.debug_tuple("Unexpected::Unsigned").field(e).finish(), - Unexpected::Signed(e) => f.debug_tuple("Unexpected::Signed").field(e).finish(), - Unexpected::Float(e) => f.debug_tuple("Unexpected::Float").field(e).finish(), - Unexpected::Char(e) => f.debug_tuple("Unexpected::Char").field(e).finish(), - Unexpected::Str(e) => f.debug_tuple("Unexpected::Str").field(e).finish(), - Unexpected::Bytes(e) => f.debug_tuple("Unexpected::Bytes").field(e).finish(), - Unexpected::Unit => f.debug_tuple("Unexpected::Unit").finish(), - Unexpected::Option => f.debug_tuple("Unexpected::Option").finish(), - Unexpected::NewtypeStruct => f.debug_tuple("Unexpected::NewtypeStruct").finish(), - Unexpected::Seq => f.debug_tuple("Unexpected::Seq").finish(), - Unexpected::Map => f.debug_tuple("Unexpected::Map").finish(), - Unexpected::Enum => f.debug_tuple("Unexpected::Enum").finish(), - Unexpected::UnitVariant => f.debug_tuple("Unexpected::UnitVariant").finish(), - Unexpected::NewtypeVariant => f.debug_tuple("Unexpected::NewtypeVariant").finish(), - Unexpected::TupleVariant => f.debug_tuple("Unexpected::TupleVariant").finish(), - Unexpected::StructVariant => f.debug_tuple("Unexpected::StructVariant").finish(), - Unexpected::Other(e) => f.debug_tuple("Unexpected::Other").field(e).finish(), - } - } - } - #[repr(C)] - pub struct VisitorHandle { - pub handle: i32, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for VisitorHandle {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for VisitorHandle { - #[inline] - fn clone(&self) -> VisitorHandle { - { - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - impl core::fmt::Debug for VisitorHandle { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("VisitorHandle") - .field("handle", &self.handle) - .finish() - } - } - #[repr(C)] - pub struct DeValueHandle { - pub handle: i32, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for DeValueHandle {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for DeValueHandle { - #[inline] - fn clone(&self) -> DeValueHandle { - { - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - impl core::fmt::Debug for DeValueHandle { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("DeValueHandle") - .field("handle", &self.handle) - .finish() - } - } - #[repr(C)] - pub struct DeserializeSeedHandle { - pub handle: i32, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for DeserializeSeedHandle {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for DeserializeSeedHandle { - #[inline] - fn clone(&self) -> DeserializeSeedHandle { - { - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - impl core::fmt::Debug for DeserializeSeedHandle { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("DeserializeSeedHandle") - .field("handle", &self.handle) - .finish() - } - } - #[repr(transparent)] - pub struct DeError(i32); - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for DeError { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match *self { - DeError(ref __self_0_0) => { - let debug_trait_builder = - &mut ::core::fmt::Formatter::debug_tuple(f, "DeError"); - let _ = ::core::fmt::DebugTuple::field(debug_trait_builder, &&(*__self_0_0)); - ::core::fmt::DebugTuple::finish(debug_trait_builder) - } - } - } - } - impl DeError { - pub unsafe fn from_raw(raw: i32) -> Self { - Self(raw) - } - pub fn into_raw(self) -> i32 { - let ret = self.0; - core::mem::forget(self); - return ret; - } - pub fn as_raw(&self) -> i32 { - self.0 - } - } - impl Drop for DeError { - fn drop(&mut self) { - #[link(wasm_import_module = "canonical_abi")] - extern "C" { - #[link_name = "resource_drop_de-error"] - fn close(fd: i32); - } - unsafe { - close(self.0); - } - } - } - impl Clone for DeError { - fn clone(&self) -> Self { - #[link(wasm_import_module = "canonical_abi")] - extern "C" { - #[link_name = "resource_clone_de-error"] - fn clone(val: i32) -> i32; - } - unsafe { Self(clone(self.0)) } - } - } - #[repr(transparent)] - pub struct Deserializer(i32); - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for Deserializer { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match *self { - Deserializer(ref __self_0_0) => { - let debug_trait_builder = - &mut ::core::fmt::Formatter::debug_tuple(f, "Deserializer"); - let _ = ::core::fmt::DebugTuple::field(debug_trait_builder, &&(*__self_0_0)); - ::core::fmt::DebugTuple::finish(debug_trait_builder) - } - } - } - } - impl Deserializer { - pub unsafe fn from_raw(raw: i32) -> Self { - Self(raw) - } - pub fn into_raw(self) -> i32 { - let ret = self.0; - core::mem::forget(self); - return ret; - } - pub fn as_raw(&self) -> i32 { - self.0 - } - } - impl Drop for Deserializer { - fn drop(&mut self) { - #[link(wasm_import_module = "canonical_abi")] - extern "C" { - #[link_name = "resource_drop_deserializer"] - fn close(fd: i32); - } - unsafe { - close(self.0); - } - } - } - impl Clone for Deserializer { - fn clone(&self) -> Self { - #[link(wasm_import_module = "canonical_abi")] - extern "C" { - #[link_name = "resource_clone_deserializer"] - fn clone(val: i32) -> i32; - } - unsafe { Self(clone(self.0)) } - } - } - #[repr(transparent)] - pub struct SeqAccess(i32); - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for SeqAccess { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match *self { - SeqAccess(ref __self_0_0) => { - let debug_trait_builder = - &mut ::core::fmt::Formatter::debug_tuple(f, "SeqAccess"); - let _ = ::core::fmt::DebugTuple::field(debug_trait_builder, &&(*__self_0_0)); - ::core::fmt::DebugTuple::finish(debug_trait_builder) - } - } - } - } - impl SeqAccess { - pub unsafe fn from_raw(raw: i32) -> Self { - Self(raw) - } - pub fn into_raw(self) -> i32 { - let ret = self.0; - core::mem::forget(self); - return ret; - } - pub fn as_raw(&self) -> i32 { - self.0 - } - } - impl Drop for SeqAccess { - fn drop(&mut self) { - #[link(wasm_import_module = "canonical_abi")] - extern "C" { - #[link_name = "resource_drop_seq-access"] - fn close(fd: i32); - } - unsafe { - close(self.0); - } - } - } - impl Clone for SeqAccess { - fn clone(&self) -> Self { - #[link(wasm_import_module = "canonical_abi")] - extern "C" { - #[link_name = "resource_clone_seq-access"] - fn clone(val: i32) -> i32; - } - unsafe { Self(clone(self.0)) } - } - } - #[repr(transparent)] - pub struct MapAccess(i32); - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for MapAccess { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match *self { - MapAccess(ref __self_0_0) => { - let debug_trait_builder = - &mut ::core::fmt::Formatter::debug_tuple(f, "MapAccess"); - let _ = ::core::fmt::DebugTuple::field(debug_trait_builder, &&(*__self_0_0)); - ::core::fmt::DebugTuple::finish(debug_trait_builder) - } - } - } - } - impl MapAccess { - pub unsafe fn from_raw(raw: i32) -> Self { - Self(raw) - } - pub fn into_raw(self) -> i32 { - let ret = self.0; - core::mem::forget(self); - return ret; - } - pub fn as_raw(&self) -> i32 { - self.0 - } - } - impl Drop for MapAccess { - fn drop(&mut self) { - #[link(wasm_import_module = "canonical_abi")] - extern "C" { - #[link_name = "resource_drop_map-access"] - fn close(fd: i32); - } - unsafe { - close(self.0); - } - } - } - impl Clone for MapAccess { - fn clone(&self) -> Self { - #[link(wasm_import_module = "canonical_abi")] - extern "C" { - #[link_name = "resource_clone_map-access"] - fn clone(val: i32) -> i32; - } - unsafe { Self(clone(self.0)) } - } - } - #[repr(transparent)] - pub struct EnumAccess(i32); - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for EnumAccess { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match *self { - EnumAccess(ref __self_0_0) => { - let debug_trait_builder = - &mut ::core::fmt::Formatter::debug_tuple(f, "EnumAccess"); - let _ = ::core::fmt::DebugTuple::field(debug_trait_builder, &&(*__self_0_0)); - ::core::fmt::DebugTuple::finish(debug_trait_builder) - } - } - } - } - impl EnumAccess { - pub unsafe fn from_raw(raw: i32) -> Self { - Self(raw) - } - pub fn into_raw(self) -> i32 { - let ret = self.0; - core::mem::forget(self); - return ret; - } - pub fn as_raw(&self) -> i32 { - self.0 - } - } - impl Drop for EnumAccess { - fn drop(&mut self) { - #[link(wasm_import_module = "canonical_abi")] - extern "C" { - #[link_name = "resource_drop_enum-access"] - fn close(fd: i32); - } - unsafe { - close(self.0); - } - } - } - impl Clone for EnumAccess { - fn clone(&self) -> Self { - #[link(wasm_import_module = "canonical_abi")] - extern "C" { - #[link_name = "resource_clone_enum-access"] - fn clone(val: i32) -> i32; - } - unsafe { Self(clone(self.0)) } - } - } - #[repr(transparent)] - pub struct VariantAccess(i32); - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::fmt::Debug for VariantAccess { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - match *self { - VariantAccess(ref __self_0_0) => { - let debug_trait_builder = - &mut ::core::fmt::Formatter::debug_tuple(f, "VariantAccess"); - let _ = ::core::fmt::DebugTuple::field(debug_trait_builder, &&(*__self_0_0)); - ::core::fmt::DebugTuple::finish(debug_trait_builder) - } - } - } - } - impl VariantAccess { - pub unsafe fn from_raw(raw: i32) -> Self { - Self(raw) - } - pub fn into_raw(self) -> i32 { - let ret = self.0; - core::mem::forget(self); - return ret; - } - pub fn as_raw(&self) -> i32 { - self.0 - } - } - impl Drop for VariantAccess { - fn drop(&mut self) { - #[link(wasm_import_module = "canonical_abi")] - extern "C" { - #[link_name = "resource_drop_variant-access"] - fn close(fd: i32); - } - unsafe { - close(self.0); - } - } - } - impl Clone for VariantAccess { - fn clone(&self) -> Self { - #[link(wasm_import_module = "canonical_abi")] - extern "C" { - #[link_name = "resource_clone_variant-access"] - fn clone(val: i32) -> i32; - } - unsafe { Self(clone(self.0)) } - } - } - impl DeError { - pub fn custom(msg: &str) -> DeError { - unsafe { - let vec0 = msg; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_de-error::custom"] - fn wit_import(_: i32, _: i32) -> i32; - } - let ret = wit_import(ptr0, len0); - DeError(ret) - } - } - } - impl DeError { - pub fn invalid_type(unexp: Unexpected<'_>, exp: &str) -> DeError { - unsafe { - let (result3_0, result3_1, result3_2) = match unexp { - Unexpected::Bool(e) => ( - 0i32, - i64::from(match e { - true => 1, - false => 0, - }), - 0i32, - ), - Unexpected::Unsigned(e) => (1i32, wit_bindgen_rust::rt::as_i64(e), 0i32), - Unexpected::Signed(e) => (2i32, wit_bindgen_rust::rt::as_i64(e), 0i32), - Unexpected::Float(e) => ( - 3i32, - (wit_bindgen_rust::rt::as_f64(e)).to_bits() as i64, - 0i32, - ), - Unexpected::Char(e) => (4i32, i64::from(wit_bindgen_rust::rt::as_i32(e)), 0i32), - Unexpected::Str(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - (5i32, i64::from(ptr0), len0) - } - Unexpected::Bytes(e) => { - let vec1 = e; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - (6i32, i64::from(ptr1), len1) - } - Unexpected::Unit => { - let e = (); - { - let () = e; - (7i32, 0i64, 0i32) - } - } - Unexpected::Option => { - let e = (); - { - let () = e; - (8i32, 0i64, 0i32) - } - } - Unexpected::NewtypeStruct => { - let e = (); - { - let () = e; - (9i32, 0i64, 0i32) - } - } - Unexpected::Seq => { - let e = (); - { - let () = e; - (10i32, 0i64, 0i32) - } - } - Unexpected::Map => { - let e = (); - { - let () = e; - (11i32, 0i64, 0i32) - } - } - Unexpected::Enum => { - let e = (); - { - let () = e; - (12i32, 0i64, 0i32) - } - } - Unexpected::UnitVariant => { - let e = (); - { - let () = e; - (13i32, 0i64, 0i32) - } - } - Unexpected::NewtypeVariant => { - let e = (); - { - let () = e; - (14i32, 0i64, 0i32) - } - } - Unexpected::TupleVariant => { - let e = (); - { - let () = e; - (15i32, 0i64, 0i32) - } - } - Unexpected::StructVariant => { - let e = (); - { - let () = e; - (16i32, 0i64, 0i32) - } - } - Unexpected::Other(e) => { - let vec2 = e; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - (17i32, i64::from(ptr2), len2) - } - }; - let vec4 = exp; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_de-error::invalid-type"] - fn wit_import(_: i32, _: i64, _: i32, _: i32, _: i32) -> i32; - } - let ret = wit_import(result3_0, result3_1, result3_2, ptr4, len4); - DeError(ret) - } - } - } - impl DeError { - pub fn invalid_value(unexp: Unexpected<'_>, exp: &str) -> DeError { - unsafe { - let (result3_0, result3_1, result3_2) = match unexp { - Unexpected::Bool(e) => ( - 0i32, - i64::from(match e { - true => 1, - false => 0, - }), - 0i32, - ), - Unexpected::Unsigned(e) => (1i32, wit_bindgen_rust::rt::as_i64(e), 0i32), - Unexpected::Signed(e) => (2i32, wit_bindgen_rust::rt::as_i64(e), 0i32), - Unexpected::Float(e) => ( - 3i32, - (wit_bindgen_rust::rt::as_f64(e)).to_bits() as i64, - 0i32, - ), - Unexpected::Char(e) => (4i32, i64::from(wit_bindgen_rust::rt::as_i32(e)), 0i32), - Unexpected::Str(e) => { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - (5i32, i64::from(ptr0), len0) - } - Unexpected::Bytes(e) => { - let vec1 = e; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - (6i32, i64::from(ptr1), len1) - } - Unexpected::Unit => { - let e = (); - { - let () = e; - (7i32, 0i64, 0i32) - } - } - Unexpected::Option => { - let e = (); - { - let () = e; - (8i32, 0i64, 0i32) - } - } - Unexpected::NewtypeStruct => { - let e = (); - { - let () = e; - (9i32, 0i64, 0i32) - } - } - Unexpected::Seq => { - let e = (); - { - let () = e; - (10i32, 0i64, 0i32) - } - } - Unexpected::Map => { - let e = (); - { - let () = e; - (11i32, 0i64, 0i32) - } - } - Unexpected::Enum => { - let e = (); - { - let () = e; - (12i32, 0i64, 0i32) - } - } - Unexpected::UnitVariant => { - let e = (); - { - let () = e; - (13i32, 0i64, 0i32) - } - } - Unexpected::NewtypeVariant => { - let e = (); - { - let () = e; - (14i32, 0i64, 0i32) - } - } - Unexpected::TupleVariant => { - let e = (); - { - let () = e; - (15i32, 0i64, 0i32) - } - } - Unexpected::StructVariant => { - let e = (); - { - let () = e; - (16i32, 0i64, 0i32) - } - } - Unexpected::Other(e) => { - let vec2 = e; - let ptr2 = vec2.as_ptr() as i32; - let len2 = vec2.len() as i32; - (17i32, i64::from(ptr2), len2) - } - }; - let vec4 = exp; - let ptr4 = vec4.as_ptr() as i32; - let len4 = vec4.len() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_de-error::invalid-value"] - fn wit_import(_: i32, _: i64, _: i32, _: i32, _: i32) -> i32; - } - let ret = wit_import(result3_0, result3_1, result3_2, ptr4, len4); - DeError(ret) - } - } - } - impl DeError { - pub fn invalid_length(len: Usize, exp: &str) -> DeError { - unsafe { - let Usize { size: size0 } = len; - let vec1 = exp; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_de-error::invalid-length"] - fn wit_import(_: i32, _: i32, _: i32) -> i32; - } - let ret = wit_import(wit_bindgen_rust::rt::as_i32(size0), ptr1, len1); - DeError(ret) - } - } - } - impl DeError { - pub fn unknown_variant(variant: &str, expected: &[&str]) -> DeError { - unsafe { - let vec0 = variant; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec2 = expected; - let len2 = vec2.len() as i32; - let layout2 = core::alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); - let result2 = std::alloc::alloc(layout2); - if result2.is_null() { - std::alloc::handle_alloc_error(layout2); - } - for (i, e) in vec2.into_iter().enumerate() { - let base = result2 as i32 + (i as i32) * 8; - { - let vec1 = e; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - *((base + 4) as *mut i32) = len1; - *((base + 0) as *mut i32) = ptr1; - } - } - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_de-error::unknown-variant"] - fn wit_import(_: i32, _: i32, _: i32, _: i32) -> i32; - } - let ret = wit_import(ptr0, len0, result2 as i32, len2); - std::alloc::dealloc(result2, layout2); - DeError(ret) - } - } - } - impl DeError { - pub fn unknown_field(field: &str, expected: &[&str]) -> DeError { - unsafe { - let vec0 = field; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec2 = expected; - let len2 = vec2.len() as i32; - let layout2 = core::alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); - let result2 = std::alloc::alloc(layout2); - if result2.is_null() { - std::alloc::handle_alloc_error(layout2); - } - for (i, e) in vec2.into_iter().enumerate() { - let base = result2 as i32 + (i as i32) * 8; - { - let vec1 = e; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - *((base + 4) as *mut i32) = len1; - *((base + 0) as *mut i32) = ptr1; - } - } - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_de-error::unknown-field"] - fn wit_import(_: i32, _: i32, _: i32, _: i32) -> i32; - } - let ret = wit_import(ptr0, len0, result2 as i32, len2); - std::alloc::dealloc(result2, layout2); - DeError(ret) - } - } - } - impl DeError { - pub fn missing_field(field: &str) -> DeError { - unsafe { - let vec0 = field; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_de-error::missing-field"] - fn wit_import(_: i32, _: i32) -> i32; - } - let ret = wit_import(ptr0, len0); - DeError(ret) - } - } - } - impl DeError { - pub fn duplicate_field(field: &str) -> DeError { - unsafe { - let vec0 = field; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_de-error::duplicate-field"] - fn wit_import(_: i32, _: i32) -> i32; - } - let ret = wit_import(ptr0, len0); - DeError(ret) - } - } - } - impl Deserializer { - pub fn erased_deserialize_any( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-any"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } - } - } - } - impl Deserializer { - pub fn erased_deserialize_bool( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-bool"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } - } - } - } - impl Deserializer { - pub fn erased_deserialize_u8( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-u8"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } - } - } - } - impl Deserializer { - pub fn erased_deserialize_u16( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-u16"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } - } - } - } - impl Deserializer { - pub fn erased_deserialize_u32( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-u32"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } - } - } - } - impl Deserializer { - pub fn erased_deserialize_u64( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-u64"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } - } - } - } - impl Deserializer { - pub fn erased_deserialize_i8( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-i8"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), +mod host { + #[allow(clippy::all)] + pub mod serde_wasm_host { + #[allow(unused_imports)] + use wit_bindgen_wasmtime::{wasmtime, anyhow}; + #[repr(C)] + pub struct Usize { + pub size: u32, + } + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::marker::Copy for Usize {} + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::clone::Clone for Usize { + #[inline] + fn clone(&self) -> Usize { + { + let _: ::core::clone::AssertParamIsClone; + *self } } } - } - impl Deserializer { - pub fn erased_deserialize_i16( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-i16"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } + impl core::fmt::Debug for Usize { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("Usize").field("size", &self.size).finish() } } - } - impl Deserializer { - pub fn erased_deserialize_i32( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-i32"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + impl wit_bindgen_wasmtime::Endian for Usize { + fn into_le(self) -> Self { + Self { + size: self.size.into_le(), } } - } - } - impl Deserializer { - pub fn erased_deserialize_i64( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-i64"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + fn from_le(self) -> Self { + Self { + size: self.size.from_le(), } } } - } - impl Deserializer { - pub fn erased_deserialize_i128( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-i128"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + unsafe impl wit_bindgen_wasmtime::AllBytesValid for Usize {} + pub enum Unexpected<'a> { + Bool(bool), + Unsigned(u64), + Signed(i64), + Float(f64), + Char(char), + Str(&'a str), + Bytes(&'a [u8]), + Unit, + Option, + NewtypeStruct, + Seq, + Map, + Enum, + UnitVariant, + NewtypeVariant, + TupleVariant, + StructVariant, + Other(&'a str), + } + #[automatically_derived] + #[allow(unused_qualifications)] + impl<'a> ::core::clone::Clone for Unexpected<'a> { + #[inline] + fn clone(&self) -> Unexpected<'a> { + match (&*self,) { + (&Unexpected::Bool(ref __self_0),) => { + Unexpected::Bool(::core::clone::Clone::clone(&(*__self_0))) + } + (&Unexpected::Unsigned(ref __self_0),) => { + Unexpected::Unsigned(::core::clone::Clone::clone(&(*__self_0))) + } + (&Unexpected::Signed(ref __self_0),) => { + Unexpected::Signed(::core::clone::Clone::clone(&(*__self_0))) + } + (&Unexpected::Float(ref __self_0),) => { + Unexpected::Float(::core::clone::Clone::clone(&(*__self_0))) + } + (&Unexpected::Char(ref __self_0),) => { + Unexpected::Char(::core::clone::Clone::clone(&(*__self_0))) + } + (&Unexpected::Str(ref __self_0),) => { + Unexpected::Str(::core::clone::Clone::clone(&(*__self_0))) + } + (&Unexpected::Bytes(ref __self_0),) => { + Unexpected::Bytes(::core::clone::Clone::clone(&(*__self_0))) + } + (&Unexpected::Unit,) => Unexpected::Unit, + (&Unexpected::Option,) => Unexpected::Option, + (&Unexpected::NewtypeStruct,) => Unexpected::NewtypeStruct, + (&Unexpected::Seq,) => Unexpected::Seq, + (&Unexpected::Map,) => Unexpected::Map, + (&Unexpected::Enum,) => Unexpected::Enum, + (&Unexpected::UnitVariant,) => Unexpected::UnitVariant, + (&Unexpected::NewtypeVariant,) => Unexpected::NewtypeVariant, + (&Unexpected::TupleVariant,) => Unexpected::TupleVariant, + (&Unexpected::StructVariant,) => Unexpected::StructVariant, + (&Unexpected::Other(ref __self_0),) => { + Unexpected::Other(::core::clone::Clone::clone(&(*__self_0))) + } } } } - } - impl Deserializer { - pub fn erased_deserialize_u128( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-u128"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + impl<'a> core::fmt::Debug for Unexpected<'a> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + Unexpected::Bool(e) => f.debug_tuple("Unexpected::Bool").field(e).finish(), + Unexpected::Unsigned(e) => { + f.debug_tuple("Unexpected::Unsigned").field(e).finish() + } + Unexpected::Signed(e) => f.debug_tuple("Unexpected::Signed").field(e).finish(), + Unexpected::Float(e) => f.debug_tuple("Unexpected::Float").field(e).finish(), + Unexpected::Char(e) => f.debug_tuple("Unexpected::Char").field(e).finish(), + Unexpected::Str(e) => f.debug_tuple("Unexpected::Str").field(e).finish(), + Unexpected::Bytes(e) => f.debug_tuple("Unexpected::Bytes").field(e).finish(), + Unexpected::Unit => f.debug_tuple("Unexpected::Unit").finish(), + Unexpected::Option => f.debug_tuple("Unexpected::Option").finish(), + Unexpected::NewtypeStruct => { + f.debug_tuple("Unexpected::NewtypeStruct").finish() + } + Unexpected::Seq => f.debug_tuple("Unexpected::Seq").finish(), + Unexpected::Map => f.debug_tuple("Unexpected::Map").finish(), + Unexpected::Enum => f.debug_tuple("Unexpected::Enum").finish(), + Unexpected::UnitVariant => f.debug_tuple("Unexpected::UnitVariant").finish(), + Unexpected::NewtypeVariant => { + f.debug_tuple("Unexpected::NewtypeVariant").finish() + } + Unexpected::TupleVariant => f.debug_tuple("Unexpected::TupleVariant").finish(), + Unexpected::StructVariant => { + f.debug_tuple("Unexpected::StructVariant").finish() + } + Unexpected::Other(e) => f.debug_tuple("Unexpected::Other").field(e).finish(), } } } - } - impl Deserializer { - pub fn erased_deserialize_f32( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-f32"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + #[repr(C)] + pub struct VisitorHandle { + pub handle: i32, + } + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::marker::Copy for VisitorHandle {} + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::clone::Clone for VisitorHandle { + #[inline] + fn clone(&self) -> VisitorHandle { + { + let _: ::core::clone::AssertParamIsClone; + *self } } } - } - impl Deserializer { - pub fn erased_deserialize_f64( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-f64"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } + impl core::fmt::Debug for VisitorHandle { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("VisitorHandle") + .field("handle", &self.handle) + .finish() } } - } - impl Deserializer { - pub fn erased_deserialize_char( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-char"] - fn wit_import(_: i32, _: i32, _: i32); + impl wit_bindgen_wasmtime::Endian for VisitorHandle { + fn into_le(self) -> Self { + Self { + handle: self.handle.into_le(), } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + } + fn from_le(self) -> Self { + Self { + handle: self.handle.from_le(), } } } - } - impl Deserializer { - pub fn erased_deserialize_str( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-str"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + unsafe impl wit_bindgen_wasmtime::AllBytesValid for VisitorHandle {} + #[repr(C)] + pub struct DeValueHandle { + pub handle: i32, + } + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::marker::Copy for DeValueHandle {} + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::clone::Clone for DeValueHandle { + #[inline] + fn clone(&self) -> DeValueHandle { + { + let _: ::core::clone::AssertParamIsClone; + *self } } } - } - impl Deserializer { - pub fn erased_deserialize_string( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-string"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } + impl core::fmt::Debug for DeValueHandle { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("DeValueHandle") + .field("handle", &self.handle) + .finish() } } - } - impl Deserializer { - pub fn erased_deserialize_bytes( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-bytes"] - fn wit_import(_: i32, _: i32, _: i32); + impl wit_bindgen_wasmtime::Endian for DeValueHandle { + fn into_le(self) -> Self { + Self { + handle: self.handle.into_le(), } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + } + fn from_le(self) -> Self { + Self { + handle: self.handle.from_le(), } } } - } - impl Deserializer { - pub fn erased_deserialize_byte_buf( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-byte-buf"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + unsafe impl wit_bindgen_wasmtime::AllBytesValid for DeValueHandle {} + #[repr(C)] + pub struct DeserializeSeedHandle { + pub handle: i32, + } + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::marker::Copy for DeserializeSeedHandle {} + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::clone::Clone for DeserializeSeedHandle { + #[inline] + fn clone(&self) -> DeserializeSeedHandle { + { + let _: ::core::clone::AssertParamIsClone; + *self } } } - } - impl Deserializer { - pub fn erased_deserialize_option( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-option"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } + impl core::fmt::Debug for DeserializeSeedHandle { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("DeserializeSeedHandle") + .field("handle", &self.handle) + .finish() } } - } - impl Deserializer { - pub fn erased_deserialize_unit( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-unit"] - fn wit_import(_: i32, _: i32, _: i32); + impl wit_bindgen_wasmtime::Endian for DeserializeSeedHandle { + fn into_le(self) -> Self { + Self { + handle: self.handle.into_le(), } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + } + fn from_le(self) -> Self { + Self { + handle: self.handle.from_le(), } } } - } - impl Deserializer { - pub fn erased_deserialize_unit_struct( - &self, - name: &str, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let VisitorHandle { handle: handle1 } = visitor; - let ptr2 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-unit-struct"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32); - } - wit_import( - self.0, - ptr0, - len0, - wit_bindgen_rust::rt::as_i32(handle1), - ptr2, - ); - match i32::from(*((ptr2 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr2 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr2 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + unsafe impl wit_bindgen_wasmtime::AllBytesValid for DeserializeSeedHandle {} + pub trait SerdeWasmHost: Sized { + type DeError: std::fmt::Debug; + type Deserializer: std::fmt::Debug; + type EnumAccess: std::fmt::Debug; + type MapAccess: std::fmt::Debug; + type SeqAccess: std::fmt::Debug; + type VariantAccess: std::fmt::Debug; + fn de_error_custom(&mut self, msg: &str) -> Self::DeError; + fn de_error_invalid_type(&mut self, unexp: Unexpected<'_>, exp: &str) -> Self::DeError; + fn de_error_invalid_value(&mut self, unexp: Unexpected<'_>, exp: &str) + -> Self::DeError; + fn de_error_invalid_length(&mut self, len: Usize, exp: &str) -> Self::DeError; + fn de_error_unknown_variant( + &mut self, + variant: &str, + expected: Vec<&str>, + ) -> Self::DeError; + fn de_error_unknown_field(&mut self, field: &str, expected: Vec<&str>) + -> Self::DeError; + fn de_error_missing_field(&mut self, field: &str) -> Self::DeError; + fn de_error_duplicate_field(&mut self, field: &str) -> Self::DeError; + fn deserializer_erased_deserialize_any( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_bool( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_u8( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_u16( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_u32( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_u64( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_i8( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_i16( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_i32( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_i64( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_i128( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_u128( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_f32( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_f64( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_char( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_str( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_string( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_bytes( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_byte_buf( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_option( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_unit( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_unit_struct( + &mut self, + self_: &Self::Deserializer, + name: &str, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_newtype_struct( + &mut self, + self_: &Self::Deserializer, + name: &str, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_seq( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_tuple( + &mut self, + self_: &Self::Deserializer, + len: Usize, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_tuple_struct( + &mut self, + self_: &Self::Deserializer, + name: &str, + len: Usize, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_map( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_struct( + &mut self, + self_: &Self::Deserializer, + name: &str, + fields: Vec<&str>, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_identifier( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_enum( + &mut self, + self_: &Self::Deserializer, + name: &str, + variants: Vec<&str>, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_deserialize_ignored_any( + &mut self, + self_: &Self::Deserializer, + visitor: VisitorHandle, + ) -> Result; + fn deserializer_erased_is_human_readable(&mut self, self_: &Self::Deserializer) + -> bool; + fn seq_access_erased_next_element( + &mut self, + self_: &Self::SeqAccess, + seed: DeserializeSeedHandle, + ) -> Result, Self::DeError>; + fn seq_access_erased_size_hint(&mut self, self_: &Self::SeqAccess) -> Option; + fn map_access_erased_next_key( + &mut self, + self_: &Self::MapAccess, + seed: DeserializeSeedHandle, + ) -> Result, Self::DeError>; + fn map_access_erased_next_value( + &mut self, + self_: &Self::MapAccess, + seed: DeserializeSeedHandle, + ) -> Result; + fn map_access_erased_next_entry( + &mut self, + self_: &Self::MapAccess, + kseed: DeserializeSeedHandle, + vseed: DeserializeSeedHandle, + ) -> Result, Self::DeError>; + fn map_access_erased_size_hint(&mut self, self_: &Self::MapAccess) -> Option; + fn enum_access_erased_variant_seed( + &mut self, + self_: &Self::EnumAccess, + seed: DeserializeSeedHandle, + ) -> Result<(DeValueHandle, Self::VariantAccess), Self::DeError>; + fn variant_access_unit_variant( + &mut self, + self_: &Self::VariantAccess, + ) -> Result<(), Self::DeError>; + fn variant_access_newtype_variant_seed( + &mut self, + self_: &Self::VariantAccess, + seed: DeserializeSeedHandle, + ) -> Result; + fn variant_access_tuple_variant( + &mut self, + self_: &Self::VariantAccess, + len: Usize, + visitor: VisitorHandle, + ) -> Result; + fn variant_access_struct_variant( + &mut self, + self_: &Self::VariantAccess, + fields: Vec<&str>, + visitor: VisitorHandle, + ) -> Result; + fn drop_de_error(&mut self, state: Self::DeError) { + drop(state); + } + fn drop_deserializer(&mut self, state: Self::Deserializer) { + drop(state); + } + fn drop_enum_access(&mut self, state: Self::EnumAccess) { + drop(state); + } + fn drop_map_access(&mut self, state: Self::MapAccess) { + drop(state); + } + fn drop_seq_access(&mut self, state: Self::SeqAccess) { + drop(state); + } + fn drop_variant_access(&mut self, state: Self::VariantAccess) { + drop(state); + } + } + pub struct SerdeWasmHostTables { + pub(crate) de_error_table: wit_bindgen_wasmtime::Table, + pub(crate) deserializer_table: wit_bindgen_wasmtime::Table, + pub(crate) enum_access_table: wit_bindgen_wasmtime::Table, + pub(crate) map_access_table: wit_bindgen_wasmtime::Table, + pub(crate) seq_access_table: wit_bindgen_wasmtime::Table, + pub(crate) variant_access_table: wit_bindgen_wasmtime::Table, + } + impl Default for SerdeWasmHostTables { + fn default() -> Self { + Self { + de_error_table: Default::default(), + deserializer_table: Default::default(), + enum_access_table: Default::default(), + map_access_table: Default::default(), + seq_access_table: Default::default(), + variant_access_table: Default::default(), } } } - } - impl Deserializer { - pub fn erased_deserialize_newtype_struct( - &self, - name: &str, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let VisitorHandle { handle: handle1 } = visitor; - let ptr2 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-newtype-struct"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32); - } - wit_import( - self.0, - ptr0, - len0, - wit_bindgen_rust::rt::as_i32(handle1), - ptr2, - ); - match i32::from(*((ptr2 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr2 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr2 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + pub fn add_to_linker( + linker: &mut wasmtime::Linker, + get: impl Fn(&mut T) -> (&mut U, &mut SerdeWasmHostTables) + Send + Sync + Copy + 'static, + ) -> anyhow::Result<()> + where + U: SerdeWasmHost, + { + use wit_bindgen_wasmtime::rt::get_memory; + linker.func_wrap( + "serde-wasm-host", + "de-error::custom", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let ptr0 = arg0; + let len0 = arg1; + let param0 = _bc.slice_str(ptr0, len0)?; + let result = host.de_error_custom(param0); + Ok(_tables.de_error_table.insert(result) as i32) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "de-error::invalid-type", + move |mut caller: wasmtime::Caller<'_, T>, + arg0: i32, + arg1: i64, + arg2: i32, + arg3: i32, + arg4: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let ptr3 = arg3; + let len3 = arg4; + let param0 = match arg0 { + 0 => Unexpected::Bool(match arg1 as i32 { + 0 => false, + 1 => true, + _ => return Err(invalid_variant("bool")), + }), + 1 => Unexpected::Unsigned(arg1 as u64), + 2 => Unexpected::Signed(arg1), + 3 => Unexpected::Float(f64::from_bits(arg1 as u64)), + 4 => Unexpected::Char(char_from_i32(arg1 as i32)?), + 5 => Unexpected::Str({ + let ptr0 = arg1 as i32; + let len0 = arg2; + _bc.slice_str(ptr0, len0)? + }), + 6 => Unexpected::Bytes({ + let ptr1 = arg1 as i32; + let len1 = arg2; + _bc.slice(ptr1, len1)? + }), + 7 => Unexpected::Unit, + 8 => Unexpected::Option, + 9 => Unexpected::NewtypeStruct, + 10 => Unexpected::Seq, + 11 => Unexpected::Map, + 12 => Unexpected::Enum, + 13 => Unexpected::UnitVariant, + 14 => Unexpected::NewtypeVariant, + 15 => Unexpected::TupleVariant, + 16 => Unexpected::StructVariant, + 17 => Unexpected::Other({ + let ptr2 = arg1 as i32; + let len2 = arg2; + _bc.slice_str(ptr2, len2)? + }), + _ => return Err(invalid_variant("Unexpected")), + }; + let param1 = _bc.slice_str(ptr3, len3)?; + let result = host.de_error_invalid_type(param0, param1); + Ok(_tables.de_error_table.insert(result) as i32) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "de-error::invalid-value", + move |mut caller: wasmtime::Caller<'_, T>, + arg0: i32, + arg1: i64, + arg2: i32, + arg3: i32, + arg4: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let ptr3 = arg3; + let len3 = arg4; + let param0 = match arg0 { + 0 => Unexpected::Bool(match arg1 as i32 { + 0 => false, + 1 => true, + _ => return Err(invalid_variant("bool")), + }), + 1 => Unexpected::Unsigned(arg1 as u64), + 2 => Unexpected::Signed(arg1), + 3 => Unexpected::Float(f64::from_bits(arg1 as u64)), + 4 => Unexpected::Char(char_from_i32(arg1 as i32)?), + 5 => Unexpected::Str({ + let ptr0 = arg1 as i32; + let len0 = arg2; + _bc.slice_str(ptr0, len0)? + }), + 6 => Unexpected::Bytes({ + let ptr1 = arg1 as i32; + let len1 = arg2; + _bc.slice(ptr1, len1)? + }), + 7 => Unexpected::Unit, + 8 => Unexpected::Option, + 9 => Unexpected::NewtypeStruct, + 10 => Unexpected::Seq, + 11 => Unexpected::Map, + 12 => Unexpected::Enum, + 13 => Unexpected::UnitVariant, + 14 => Unexpected::NewtypeVariant, + 15 => Unexpected::TupleVariant, + 16 => Unexpected::StructVariant, + 17 => Unexpected::Other({ + let ptr2 = arg1 as i32; + let len2 = arg2; + _bc.slice_str(ptr2, len2)? + }), + _ => return Err(invalid_variant("Unexpected")), + }; + let param1 = _bc.slice_str(ptr3, len3)?; + let result = host.de_error_invalid_value(param0, param1); + Ok(_tables.de_error_table.insert(result) as i32) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "de-error::invalid-length", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let ptr0 = arg1; + let len0 = arg2; + let param0 = Usize { size: arg0 as u32 }; + let param1 = _bc.slice_str(ptr0, len0)?; + let result = host.de_error_invalid_length(param0, param1); + Ok(_tables.de_error_table.insert(result) as i32) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "de-error::unknown-variant", + move |mut caller: wasmtime::Caller<'_, T>, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let ptr0 = arg0; + let len0 = arg1; + let len4 = arg3; + let base4 = arg2; + let mut result4 = Vec::with_capacity(len4 as usize); + for i in 0..len4 { + let base = base4 + i * 8; + result4.push({ + let load1 = _bc.load::(base + 0)?; + let load2 = _bc.load::(base + 4)?; + let ptr3 = load1; + let len3 = load2; + _bc.slice_str(ptr3, len3)? + }); + } + let param0 = _bc.slice_str(ptr0, len0)?; + let param1 = result4; + let result = host.de_error_unknown_variant(param0, param1); + Ok(_tables.de_error_table.insert(result) as i32) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "de-error::unknown-field", + move |mut caller: wasmtime::Caller<'_, T>, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let ptr0 = arg0; + let len0 = arg1; + let len4 = arg3; + let base4 = arg2; + let mut result4 = Vec::with_capacity(len4 as usize); + for i in 0..len4 { + let base = base4 + i * 8; + result4.push({ + let load1 = _bc.load::(base + 0)?; + let load2 = _bc.load::(base + 4)?; + let ptr3 = load1; + let len3 = load2; + _bc.slice_str(ptr3, len3)? + }); + } + let param0 = _bc.slice_str(ptr0, len0)?; + let param1 = result4; + let result = host.de_error_unknown_field(param0, param1); + Ok(_tables.de_error_table.insert(result) as i32) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "de-error::missing-field", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let ptr0 = arg0; + let len0 = arg1; + let param0 = _bc.slice_str(ptr0, len0)?; + let result = host.de_error_missing_field(param0); + Ok(_tables.de_error_table.insert(result) as i32) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "de-error::duplicate-field", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let ptr0 = arg0; + let len0 = arg1; + let param0 = _bc.slice_str(ptr0, len0)?; + let result = host.de_error_duplicate_field(param0); + Ok(_tables.de_error_table.insert(result) as i32) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-any", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_any(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-bool", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_bool(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-u8", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_u8(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-u16", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_u16(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-u32", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_u32(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-u64", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_u64(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-i8", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_i8(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-i16", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_i16(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-i32", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_i32(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-i64", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_i64(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-i128", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_i128(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-u128", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_u128(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-f32", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_f32(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-f64", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_f64(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-char", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_char(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-str", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_str(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-string", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_string(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-bytes", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_bytes(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-byte-buf", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_byte_buf(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-option", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_option(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-unit", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_unit(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-unit-struct", + move |mut caller: wasmtime::Caller<'_, T>, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32, + arg4: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let ptr0 = arg1; + let len0 = arg2; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = _bc.slice_str(ptr0, len0)?; + let param2 = VisitorHandle { handle: arg3 }; + let result = + host.deserializer_erased_deserialize_unit_struct(param0, param1, param2); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg4 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle1 } = e; + caller_memory.store( + arg4 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle1, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg4 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg4 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-newtype-struct", + move |mut caller: wasmtime::Caller<'_, T>, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32, + arg4: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let ptr0 = arg1; + let len0 = arg2; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = _bc.slice_str(ptr0, len0)?; + let param2 = VisitorHandle { handle: arg3 }; + let result = + host.deserializer_erased_deserialize_newtype_struct(param0, param1, param2); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg4 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle1 } = e; + caller_memory.store( + arg4 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle1, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg4 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg4 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-seq", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_seq(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-tuple", + move |mut caller: wasmtime::Caller<'_, T>, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = Usize { size: arg1 as u32 }; + let param2 = VisitorHandle { handle: arg2 }; + let result = host.deserializer_erased_deserialize_tuple(param0, param1, param2); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg3 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg3 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg3 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg3 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-tuple-struct", + move |mut caller: wasmtime::Caller<'_, T>, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32, + arg4: i32, + arg5: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let ptr0 = arg1; + let len0 = arg2; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = _bc.slice_str(ptr0, len0)?; + let param2 = Usize { size: arg3 as u32 }; + let param3 = VisitorHandle { handle: arg4 }; + let result = host.deserializer_erased_deserialize_tuple_struct( + param0, param1, param2, param3, + ); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg5 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle1 } = e; + caller_memory.store( + arg5 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle1, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg5 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg5 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-map", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_map(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-struct", + move |mut caller: wasmtime::Caller<'_, T>, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32, + arg4: i32, + arg5: i32, + arg6: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let ptr0 = arg1; + let len0 = arg2; + let len4 = arg4; + let base4 = arg3; + let mut result4 = Vec::with_capacity(len4 as usize); + for i in 0..len4 { + let base = base4 + i * 8; + result4.push({ + let load1 = _bc.load::(base + 0)?; + let load2 = _bc.load::(base + 4)?; + let ptr3 = load1; + let len3 = load2; + _bc.slice_str(ptr3, len3)? + }); + } + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = _bc.slice_str(ptr0, len0)?; + let param2 = result4; + let param3 = VisitorHandle { handle: arg5 }; + let result = + host.deserializer_erased_deserialize_struct(param0, param1, param2, param3); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg6 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle5 } = e; + caller_memory.store( + arg6 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle5, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg6 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg6 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-identifier", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_identifier(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-enum", + move |mut caller: wasmtime::Caller<'_, T>, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32, + arg4: i32, + arg5: i32, + arg6: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let ptr0 = arg1; + let len0 = arg2; + let len4 = arg4; + let base4 = arg3; + let mut result4 = Vec::with_capacity(len4 as usize); + for i in 0..len4 { + let base = base4 + i * 8; + result4.push({ + let load1 = _bc.load::(base + 0)?; + let load2 = _bc.load::(base + 4)?; + let ptr3 = load1; + let len3 = load2; + _bc.slice_str(ptr3, len3)? + }); + } + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = _bc.slice_str(ptr0, len0)?; + let param2 = result4; + let param3 = VisitorHandle { handle: arg5 }; + let result = + host.deserializer_erased_deserialize_enum(param0, param1, param2, param3); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg6 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle5 } = e; + caller_memory.store( + arg6 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle5, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg6 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg6 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-deserialize-ignored-any", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = VisitorHandle { handle: arg1 }; + let result = host.deserializer_erased_deserialize_ignored_any(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "deserializer::erased-is-human-readable", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32| { + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .deserializer_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let result = host.deserializer_erased_is_human_readable(param0); + Ok(match result { + true => 1, + false => 0, + }) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "seq-access::erased-next-element", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .seq_access_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = DeserializeSeedHandle { handle: arg1 }; + let result = host.seq_access_erased_next_element(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + match e { + Some(e) => { + let (caller_memory, data) = + memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(1i32) as u8, + )?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 8, + wit_bindgen_wasmtime::rt::as_i32( + wit_bindgen_wasmtime::rt::as_i32(handle0), + ), + )?; + } + None => { + let e = (); + { + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(0i32) as u8, + )?; + let () = e; + } + } + }; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "seq-access::erased-size-hint", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .seq_access_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let result = host.seq_access_erased_size_hint(param0); + match result { + Some(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg1 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + let Usize { size: size0 } = e; + caller_memory.store( + arg1 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + size0, + )), + )?; + } + None => { + let e = (); + { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory.store( + arg1 + 0, + wit_bindgen_wasmtime::rt::as_i32(0i32) as u8, + )?; + let () = e; + } + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "map-access::erased-next-key", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .map_access_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = DeserializeSeedHandle { handle: arg1 }; + let result = host.map_access_erased_next_key(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + match e { + Some(e) => { + let (caller_memory, data) = + memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(1i32) as u8, + )?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 8, + wit_bindgen_wasmtime::rt::as_i32( + wit_bindgen_wasmtime::rt::as_i32(handle0), + ), + )?; + } + None => { + let e = (); + { + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(0i32) as u8, + )?; + let () = e; + } + } + }; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "map-access::erased-next-value", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .map_access_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = DeserializeSeedHandle { handle: arg1 }; + let result = host.map_access_erased_next_value(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "map-access::erased-next-entry", + move |mut caller: wasmtime::Caller<'_, T>, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .map_access_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = DeserializeSeedHandle { handle: arg1 }; + let param2 = DeserializeSeedHandle { handle: arg2 }; + let result = host.map_access_erased_next_entry(param0, param1, param2); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg3 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + match e { + Some(e) => { + let (caller_memory, data) = + memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory.store( + arg3 + 4, + wit_bindgen_wasmtime::rt::as_i32(1i32) as u8, + )?; + let (t0_0, t0_1) = e; + let DeValueHandle { handle: handle1 } = t0_0; + caller_memory.store( + arg3 + 8, + wit_bindgen_wasmtime::rt::as_i32( + wit_bindgen_wasmtime::rt::as_i32(handle1), + ), + )?; + let DeValueHandle { handle: handle2 } = t0_1; + caller_memory.store( + arg3 + 12, + wit_bindgen_wasmtime::rt::as_i32( + wit_bindgen_wasmtime::rt::as_i32(handle2), + ), + )?; + } + None => { + let e = (); + { + caller_memory.store( + arg3 + 4, + wit_bindgen_wasmtime::rt::as_i32(0i32) as u8, + )?; + let () = e; + } + } + }; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg3 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg3 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "map-access::erased-size-hint", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .map_access_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let result = host.map_access_erased_size_hint(param0); + match result { + Some(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg1 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + let Usize { size: size0 } = e; + caller_memory.store( + arg1 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + size0, + )), + )?; + } + None => { + let e = (); + { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory.store( + arg1 + 0, + wit_bindgen_wasmtime::rt::as_i32(0i32) as u8, + )?; + let () = e; + } + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "enum-access::erased-variant-seed", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .enum_access_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = DeserializeSeedHandle { handle: arg1 }; + let result = host.enum_access_erased_variant_seed(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let (t0_0, t0_1) = e; + let DeValueHandle { handle: handle1 } = t0_0; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle1, + )), + )?; + caller_memory.store( + arg2 + 8, + wit_bindgen_wasmtime::rt::as_i32( + _tables.variant_access_table.insert(t0_1) as i32, + ), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "variant-access::unit-variant", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .variant_access_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let result = host.variant_access_unit_variant(param0); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg1 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let () = e; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg1 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg1 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "variant-access::newtype-variant-seed", + move |mut caller: wasmtime::Caller<'_, T>, arg0: i32, arg1: i32, arg2: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .variant_access_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = DeserializeSeedHandle { handle: arg1 }; + let result = host.variant_access_newtype_variant_seed(param0, param1); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg2 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg2 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "variant-access::tuple-variant", + move |mut caller: wasmtime::Caller<'_, T>, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let host = get(caller.data_mut()); + let (host, _tables) = host; + let param0 = _tables + .variant_access_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = Usize { size: arg1 as u32 }; + let param2 = VisitorHandle { handle: arg2 }; + let result = host.variant_access_tuple_variant(param0, param1, param2); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg3 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle0 } = e; + caller_memory.store( + arg3 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle0, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg3 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg3 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "serde-wasm-host", + "variant-access::struct-variant", + move |mut caller: wasmtime::Caller<'_, T>, + arg0: i32, + arg1: i32, + arg2: i32, + arg3: i32, + arg4: i32| { + let memory = &get_memory(&mut caller, "memory")?; + let (mem, data) = memory.data_and_store_mut(&mut caller); + let mut _bc = wit_bindgen_wasmtime::BorrowChecker::new(mem); + let host = get(data); + let (host, _tables) = host; + let len3 = arg2; + let base3 = arg1; + let mut result3 = Vec::with_capacity(len3 as usize); + for i in 0..len3 { + let base = base3 + i * 8; + result3.push({ + let load0 = _bc.load::(base + 0)?; + let load1 = _bc.load::(base + 4)?; + let ptr2 = load0; + let len2 = load1; + _bc.slice_str(ptr2, len2)? + }); + } + let param0 = _tables + .variant_access_table + .get((arg0) as u32) + .ok_or_else(|| wasmtime::Trap::new("invalid handle index"))?; + let param1 = result3; + let param2 = VisitorHandle { handle: arg3 }; + let result = host.variant_access_struct_variant(param0, param1, param2); + match result { + Ok(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg4 + 0, wit_bindgen_wasmtime::rt::as_i32(0i32) as u8)?; + let DeValueHandle { handle: handle4 } = e; + caller_memory.store( + arg4 + 4, + wit_bindgen_wasmtime::rt::as_i32(wit_bindgen_wasmtime::rt::as_i32( + handle4, + )), + )?; + } + Err(e) => { + let (caller_memory, data) = memory.data_and_store_mut(&mut caller); + let (_, _tables) = get(data); + caller_memory + .store(arg4 + 0, wit_bindgen_wasmtime::rt::as_i32(1i32) as u8)?; + caller_memory.store( + arg4 + 4, + wit_bindgen_wasmtime::rt::as_i32( + _tables.de_error_table.insert(e) as i32 + ), + )?; + } + }; + Ok(()) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_drop_de-error", + move |mut caller: wasmtime::Caller<'_, T>, handle: u32| { + let (host, tables) = get(caller.data_mut()); + let handle = tables.de_error_table.remove(handle).map_err(|e| { + wasmtime::Trap::new({ + let res = ::alloc::fmt::format(::core::fmt::Arguments::new_v1( + &["failed to remove handle: "], + &[::core::fmt::ArgumentV1::new_display(&e)], + )); + res + }) + })?; + host.drop_de_error(handle); + Ok(()) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_drop_deserializer", + move |mut caller: wasmtime::Caller<'_, T>, handle: u32| { + let (host, tables) = get(caller.data_mut()); + let handle = tables.deserializer_table.remove(handle).map_err(|e| { + wasmtime::Trap::new({ + let res = ::alloc::fmt::format(::core::fmt::Arguments::new_v1( + &["failed to remove handle: "], + &[::core::fmt::ArgumentV1::new_display(&e)], + )); + res + }) + })?; + host.drop_deserializer(handle); + Ok(()) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_drop_enum-access", + move |mut caller: wasmtime::Caller<'_, T>, handle: u32| { + let (host, tables) = get(caller.data_mut()); + let handle = tables.enum_access_table.remove(handle).map_err(|e| { + wasmtime::Trap::new({ + let res = ::alloc::fmt::format(::core::fmt::Arguments::new_v1( + &["failed to remove handle: "], + &[::core::fmt::ArgumentV1::new_display(&e)], + )); + res + }) + })?; + host.drop_enum_access(handle); + Ok(()) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_drop_map-access", + move |mut caller: wasmtime::Caller<'_, T>, handle: u32| { + let (host, tables) = get(caller.data_mut()); + let handle = tables.map_access_table.remove(handle).map_err(|e| { + wasmtime::Trap::new({ + let res = ::alloc::fmt::format(::core::fmt::Arguments::new_v1( + &["failed to remove handle: "], + &[::core::fmt::ArgumentV1::new_display(&e)], + )); + res + }) + })?; + host.drop_map_access(handle); + Ok(()) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_drop_seq-access", + move |mut caller: wasmtime::Caller<'_, T>, handle: u32| { + let (host, tables) = get(caller.data_mut()); + let handle = tables.seq_access_table.remove(handle).map_err(|e| { + wasmtime::Trap::new({ + let res = ::alloc::fmt::format(::core::fmt::Arguments::new_v1( + &["failed to remove handle: "], + &[::core::fmt::ArgumentV1::new_display(&e)], + )); + res + }) + })?; + host.drop_seq_access(handle); + Ok(()) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_drop_variant-access", + move |mut caller: wasmtime::Caller<'_, T>, handle: u32| { + let (host, tables) = get(caller.data_mut()); + let handle = tables.variant_access_table.remove(handle).map_err(|e| { + wasmtime::Trap::new({ + let res = ::alloc::fmt::format(::core::fmt::Arguments::new_v1( + &["failed to remove handle: "], + &[::core::fmt::ArgumentV1::new_display(&e)], + )); + res + }) + })?; + host.drop_variant_access(handle); + Ok(()) + }, + )?; + Ok(()) + } + use wit_bindgen_wasmtime::rt::RawMem; + use wit_bindgen_wasmtime::rt::char_from_i32; + use wit_bindgen_wasmtime::rt::invalid_variant; + } + const _ : & str = "record usize {\n size: u32,\n}\n\nvariant unexpected {\n %bool(bool),\n unsigned(u64),\n signed(s64),\n float(float64),\n %char(char),\n str(string),\n bytes(list),\n %unit,\n %option,\n newtype-struct,\n seq,\n map,\n %enum,\n unit-variant,\n newtype-variant,\n tuple-variant,\n struct-variant,\n other(string),\n}\n\nresource de-error {\n static custom: func(msg: string) -> de-error\n static invalid-type: func(unexp: unexpected, exp: string) -> de-error\n static invalid-value: func(unexp: unexpected, exp: string) -> de-error\n static invalid-length: func(len: usize, exp: string) -> de-error\n static unknown-variant: func(%variant: string, %expected: list) -> de-error\n static unknown-field: func(field: string, %expected: list) -> de-error\n static missing-field: func(field: string) -> de-error\n static duplicate-field: func(field: string) -> de-error\n}\n\nresource deserializer {\n erased-deserialize-any: func(visitor: visitor-handle) -> expected\n erased-deserialize-bool: func(visitor: visitor-handle) -> expected\n erased-deserialize-u8: func(visitor: visitor-handle) -> expected\n erased-deserialize-u16: func(visitor: visitor-handle) -> expected\n erased-deserialize-u32: func(visitor: visitor-handle) -> expected\n erased-deserialize-u64: func(visitor: visitor-handle) -> expected\n erased-deserialize-i8: func(visitor: visitor-handle) -> expected\n erased-deserialize-i16: func(visitor: visitor-handle) -> expected\n erased-deserialize-i32: func(visitor: visitor-handle) -> expected\n erased-deserialize-i64: func(visitor: visitor-handle) -> expected\n erased-deserialize-i128: func(visitor: visitor-handle) -> expected\n erased-deserialize-u128: func(visitor: visitor-handle) -> expected\n erased-deserialize-f32: func(visitor: visitor-handle) -> expected\n erased-deserialize-f64: func(visitor: visitor-handle) -> expected\n erased-deserialize-char: func(visitor: visitor-handle) -> expected\n erased-deserialize-str: func(visitor: visitor-handle) -> expected\n erased-deserialize-string: func(visitor: visitor-handle) -> expected\n erased-deserialize-bytes: func(visitor: visitor-handle) -> expected\n erased-deserialize-byte-buf: func(visitor: visitor-handle) -> expected\n erased-deserialize-option: func(visitor: visitor-handle) -> expected\n erased-deserialize-unit: func(visitor: visitor-handle) -> expected\n erased-deserialize-unit-struct: func(name: string, visitor: visitor-handle) -> expected\n erased-deserialize-newtype-struct: func(name: string, visitor: visitor-handle) -> expected\n erased-deserialize-seq: func(visitor: visitor-handle) -> expected\n erased-deserialize-tuple: func(len: usize, visitor: visitor-handle) -> expected\n erased-deserialize-tuple-struct: func(name: string, len: usize, visitor: visitor-handle) -> expected\n erased-deserialize-map: func(visitor: visitor-handle) -> expected\n erased-deserialize-struct: func(name: string, fields: list, visitor: visitor-handle) -> expected\n erased-deserialize-identifier: func(visitor: visitor-handle) -> expected\n erased-deserialize-enum: func(name: string, variants: list, visitor: visitor-handle) -> expected\n erased-deserialize-ignored-any: func(visitor: visitor-handle) -> expected\n erased-is-human-readable: func() -> bool\n}\n\nresource seq-access {\n erased-next-element: func(seed: deserialize-seed-handle) -> expected, de-error>\n erased-size-hint: func() -> option\n}\n\nresource map-access {\n erased-next-key: func(seed: deserialize-seed-handle) -> expected, de-error>\n erased-next-value: func(seed: deserialize-seed-handle) -> expected\n erased-next-entry: func(kseed: deserialize-seed-handle, vseed: deserialize-seed-handle) -> expected>, de-error>\n erased-size-hint: func() -> option\n}\n\nresource enum-access {\n erased-variant-seed: func(seed: deserialize-seed-handle) -> expected, de-error>\n}\n\nresource variant-access {\n unit-variant: func() -> expected\n newtype-variant-seed: func(seed: deserialize-seed-handle) -> expected\n tuple-variant: func(len: usize, visitor: visitor-handle) -> expected\n struct-variant: func(fields: list, visitor: visitor-handle) -> expected\n}\n\nrecord visitor-handle {\n %handle: s32\n}\n\nrecord de-value-handle {\n %handle: s32\n}\n\nrecord deserialize-seed-handle {\n %handle: s32\n}\n" ; + #[allow(clippy::all)] + pub mod serde_wasm_guest { + #[allow(unused_imports)] + use wit_bindgen_wasmtime::{wasmtime, anyhow}; + #[repr(C)] + pub struct I128 { + pub hi: u64, + pub lo: u64, + } + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::marker::Copy for I128 {} + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::clone::Clone for I128 { + #[inline] + fn clone(&self) -> I128 { + { + let _: ::core::clone::AssertParamIsClone; + let _: ::core::clone::AssertParamIsClone; + *self } } } - } - impl Deserializer { - pub fn erased_deserialize_seq( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-seq"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } + impl core::fmt::Debug for I128 { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("I128") + .field("hi", &self.hi) + .field("lo", &self.lo) + .finish() } } - } - impl Deserializer { - pub fn erased_deserialize_tuple( - &self, - len: Usize, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let Usize { size: size0 } = len; - let VisitorHandle { handle: handle1 } = visitor; - let ptr2 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-tuple"] - fn wit_import(_: i32, _: i32, _: i32, _: i32); - } - wit_import( - self.0, - wit_bindgen_rust::rt::as_i32(size0), - wit_bindgen_rust::rt::as_i32(handle1), - ptr2, - ); - match i32::from(*((ptr2 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr2 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr2 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + impl wit_bindgen_wasmtime::Endian for I128 { + fn into_le(self) -> Self { + Self { + hi: self.hi.into_le(), + lo: self.lo.into_le(), } } - } - } - impl Deserializer { - pub fn erased_deserialize_tuple_struct( - &self, - name: &str, - len: Usize, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let Usize { size: size1 } = len; - let VisitorHandle { handle: handle2 } = visitor; - let ptr3 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-tuple-struct"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32); - } - wit_import( - self.0, - ptr0, - len0, - wit_bindgen_rust::rt::as_i32(size1), - wit_bindgen_rust::rt::as_i32(handle2), - ptr3, - ); - match i32::from(*((ptr3 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr3 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr3 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + fn from_le(self) -> Self { + Self { + hi: self.hi.from_le(), + lo: self.lo.from_le(), } } } - } - impl Deserializer { - pub fn erased_deserialize_map( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-map"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + unsafe impl wit_bindgen_wasmtime::AllBytesValid for I128 {} + #[repr(C)] + pub struct U128 { + pub hi: u64, + pub lo: u64, + } + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::marker::Copy for U128 {} + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::clone::Clone for U128 { + #[inline] + fn clone(&self) -> U128 { + { + let _: ::core::clone::AssertParamIsClone; + let _: ::core::clone::AssertParamIsClone; + *self } } } - } - impl Deserializer { - pub fn erased_deserialize_struct( - &self, - name: &str, - fields: &[&str], - visitor: VisitorHandle, - ) -> Result { - unsafe { - let vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec2 = fields; - let len2 = vec2.len() as i32; - let layout2 = core::alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); - let result2 = std::alloc::alloc(layout2); - if result2.is_null() { - std::alloc::handle_alloc_error(layout2); - } - for (i, e) in vec2.into_iter().enumerate() { - let base = result2 as i32 + (i as i32) * 8; - { - let vec1 = e; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - *((base + 4) as *mut i32) = len1; - *((base + 0) as *mut i32) = ptr1; - } - } - let VisitorHandle { handle: handle3 } = visitor; - let ptr4 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-struct"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32); - } - wit_import( - self.0, - ptr0, - len0, - result2 as i32, - len2, - wit_bindgen_rust::rt::as_i32(handle3), - ptr4, - ); - std::alloc::dealloc(result2, layout2); - match i32::from(*((ptr4 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr4 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr4 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } + impl core::fmt::Debug for U128 { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("U128") + .field("hi", &self.hi) + .field("lo", &self.lo) + .finish() } } - } - impl Deserializer { - pub fn erased_deserialize_identifier( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-identifier"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + impl wit_bindgen_wasmtime::Endian for U128 { + fn into_le(self) -> Self { + Self { + hi: self.hi.into_le(), + lo: self.lo.into_le(), } } - } - } - impl Deserializer { - pub fn erased_deserialize_enum( - &self, - name: &str, - variants: &[&str], - visitor: VisitorHandle, - ) -> Result { - unsafe { - let vec0 = name; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - let vec2 = variants; - let len2 = vec2.len() as i32; - let layout2 = core::alloc::Layout::from_size_align_unchecked(vec2.len() * 8, 4); - let result2 = std::alloc::alloc(layout2); - if result2.is_null() { - std::alloc::handle_alloc_error(layout2); - } - for (i, e) in vec2.into_iter().enumerate() { - let base = result2 as i32 + (i as i32) * 8; - { - let vec1 = e; - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - *((base + 4) as *mut i32) = len1; - *((base + 0) as *mut i32) = ptr1; - } - } - let VisitorHandle { handle: handle3 } = visitor; - let ptr4 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-enum"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32, _: i32, _: i32); - } - wit_import( - self.0, - ptr0, - len0, - result2 as i32, - len2, - wit_bindgen_rust::rt::as_i32(handle3), - ptr4, - ); - std::alloc::dealloc(result2, layout2); - match i32::from(*((ptr4 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr4 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr4 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + fn from_le(self) -> Self { + Self { + hi: self.hi.from_le(), + lo: self.lo.from_le(), } } } - } - impl Deserializer { - pub fn erased_deserialize_ignored_any( - &self, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let VisitorHandle { handle: handle0 } = visitor; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-deserialize-ignored-any"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } - } + unsafe impl wit_bindgen_wasmtime::AllBytesValid for U128 {} + #[repr(C)] + pub struct DeErrorHandle { + pub handle: i32, } - } - impl Deserializer { - pub fn erased_is_human_readable(&self) -> bool { - unsafe { - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_deserializer::erased-is-human-readable"] - fn wit_import(_: i32) -> i32; - } - let ret = wit_import(self.0); - match ret { - 0 => false, - 1 => true, - _ => ::std::rt::begin_panic("invalid bool discriminant"), + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::marker::Copy for DeErrorHandle {} + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::clone::Clone for DeErrorHandle { + #[inline] + fn clone(&self) -> DeErrorHandle { + { + let _: ::core::clone::AssertParamIsClone; + *self } } } - } - impl SeqAccess { - pub fn erased_next_element( - &self, - seed: DeserializeSeedHandle, - ) -> Result { - unsafe { - let DeserializeSeedHandle { handle: handle0 } = seed; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_seq-access::erased-next-element"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } + impl core::fmt::Debug for DeErrorHandle { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("DeErrorHandle") + .field("handle", &self.handle) + .finish() } } - } - impl SeqAccess { - pub fn erased_size_hint(&self) -> Option { - unsafe { - let ptr0 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_seq-access::erased-size-hint"] - fn wit_import(_: i32, _: i32); - } - wit_import(self.0, ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => None, - 1 => Some(Usize { - size: *((ptr0 + 4) as *const i32) as u32, - }), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + impl wit_bindgen_wasmtime::Endian for DeErrorHandle { + fn into_le(self) -> Self { + Self { + handle: self.handle.into_le(), } } - } - } - impl MapAccess { - pub fn erased_next_key( - &self, - seed: DeserializeSeedHandle, - ) -> Result, DeError> { - unsafe { - let DeserializeSeedHandle { handle: handle0 } = seed; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_map-access::erased-next-key"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(match i32::from(*((ptr1 + 4) as *const u8)) { - 0 => None, - 1 => Some(DeValueHandle { - handle: *((ptr1 + 8) as *const i32), - }), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + fn from_le(self) -> Self { + Self { + handle: self.handle.from_le(), } } } - } - impl MapAccess { - pub fn erased_next_value( - &self, - seed: DeserializeSeedHandle, - ) -> Result { - unsafe { - let DeserializeSeedHandle { handle: handle0 } = seed; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_map-access::erased-next-value"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } - } + unsafe impl wit_bindgen_wasmtime::AllBytesValid for DeErrorHandle {} + #[repr(C)] + pub struct DeserializerHandle { + pub handle: i32, } - } - impl MapAccess { - pub fn erased_next_entry( - &self, - kseed: DeserializeSeedHandle, - vseed: DeserializeSeedHandle, - ) -> Result, DeError> { - unsafe { - let DeserializeSeedHandle { handle: handle0 } = kseed; - let DeserializeSeedHandle { handle: handle1 } = vseed; - let ptr2 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_map-access::erased-next-entry"] - fn wit_import(_: i32, _: i32, _: i32, _: i32); - } - wit_import( - self.0, - wit_bindgen_rust::rt::as_i32(handle0), - wit_bindgen_rust::rt::as_i32(handle1), - ptr2, - ); - match i32::from(*((ptr2 + 0) as *const u8)) { - 0 => Ok(match i32::from(*((ptr2 + 4) as *const u8)) { - 0 => None, - 1 => Some(( - DeValueHandle { - handle: *((ptr2 + 8) as *const i32), - }, - DeValueHandle { - handle: *((ptr2 + 12) as *const i32), - }, - )), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - }), - 1 => Err(DeError(*((ptr2 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::marker::Copy for DeserializerHandle {} + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::clone::Clone for DeserializerHandle { + #[inline] + fn clone(&self) -> DeserializerHandle { + { + let _: ::core::clone::AssertParamIsClone; + *self } } } - } - impl MapAccess { - pub fn erased_size_hint(&self) -> Option { - unsafe { - let ptr0 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_map-access::erased-size-hint"] - fn wit_import(_: i32, _: i32); - } - wit_import(self.0, ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => None, - 1 => Some(Usize { - size: *((ptr0 + 4) as *const i32) as u32, - }), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } + impl core::fmt::Debug for DeserializerHandle { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("DeserializerHandle") + .field("handle", &self.handle) + .finish() } } - } - impl EnumAccess { - pub fn erased_variant( - &self, - seed: DeserializeSeedHandle, - ) -> Result<(DeValueHandle, VariantAccess), DeError> { - unsafe { - let DeserializeSeedHandle { handle: handle0 } = seed; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_enum-access::erased-variant"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(( - DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }, - VariantAccess(*((ptr1 + 8) as *const i32)), - )), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + impl wit_bindgen_wasmtime::Endian for DeserializerHandle { + fn into_le(self) -> Self { + Self { + handle: self.handle.into_le(), } } - } - } - impl VariantAccess { - pub fn unit_variant(&self) -> Result<(), DeError> { - unsafe { - let ptr0 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_variant-access::unit-variant"] - fn wit_import(_: i32, _: i32); - } - wit_import(self.0, ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(()), - 1 => Err(DeError(*((ptr0 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + fn from_le(self) -> Self { + Self { + handle: self.handle.from_le(), } } } - } - impl VariantAccess { - pub fn newtype_variant_seed( - &self, - seed: DeserializeSeedHandle, - ) -> Result { - unsafe { - let DeserializeSeedHandle { handle: handle0 } = seed; - let ptr1 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_variant-access::newtype-variant-seed"] - fn wit_import(_: i32, _: i32, _: i32); - } - wit_import(self.0, wit_bindgen_rust::rt::as_i32(handle0), ptr1); - match i32::from(*((ptr1 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr1 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr1 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } - } + unsafe impl wit_bindgen_wasmtime::AllBytesValid for DeserializerHandle {} + #[repr(C)] + pub struct SeqAccessHandle { + pub handle: i32, } - } - impl VariantAccess { - pub fn newtype_variant(&self) -> Result { - unsafe { - let ptr0 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_variant-access::newtype-variant"] - fn wit_import(_: i32, _: i32); - } - wit_import(self.0, ptr0); - match i32::from(*((ptr0 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr0 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr0 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::marker::Copy for SeqAccessHandle {} + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::clone::Clone for SeqAccessHandle { + #[inline] + fn clone(&self) -> SeqAccessHandle { + { + let _: ::core::clone::AssertParamIsClone; + *self } } } - } - impl VariantAccess { - pub fn tuple_variant( - &self, - len: Usize, - visitor: VisitorHandle, - ) -> Result { - unsafe { - let Usize { size: size0 } = len; - let VisitorHandle { handle: handle1 } = visitor; - let ptr2 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_variant-access::tuple-variant"] - fn wit_import(_: i32, _: i32, _: i32, _: i32); - } - wit_import( - self.0, - wit_bindgen_rust::rt::as_i32(size0), - wit_bindgen_rust::rt::as_i32(handle1), - ptr2, - ); - match i32::from(*((ptr2 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr2 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr2 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), - } + impl core::fmt::Debug for SeqAccessHandle { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("SeqAccessHandle") + .field("handle", &self.handle) + .finish() } } - } - impl VariantAccess { - pub fn struct_variant( - &self, - fields: &[&str], - visitor: VisitorHandle, - ) -> Result { - unsafe { - let vec1 = fields; - let len1 = vec1.len() as i32; - let layout1 = core::alloc::Layout::from_size_align_unchecked(vec1.len() * 8, 4); - let result1 = std::alloc::alloc(layout1); - if result1.is_null() { - std::alloc::handle_alloc_error(layout1); - } - for (i, e) in vec1.into_iter().enumerate() { - let base = result1 as i32 + (i as i32) * 8; - { - let vec0 = e; - let ptr0 = vec0.as_ptr() as i32; - let len0 = vec0.len() as i32; - *((base + 4) as *mut i32) = len0; - *((base + 0) as *mut i32) = ptr0; - } - } - let VisitorHandle { handle: handle2 } = visitor; - let ptr3 = SERDE_WASM_HOST_RET_AREA.0.as_mut_ptr() as i32; - #[link(wasm_import_module = "serde-wasm-host")] - extern "C" { - #[link_name = "serde-wasm-host_variant-access::struct-variant"] - fn wit_import(_: i32, _: i32, _: i32, _: i32, _: i32); - } - wit_import( - self.0, - result1 as i32, - len1, - wit_bindgen_rust::rt::as_i32(handle2), - ptr3, - ); - std::alloc::dealloc(result1, layout1); - match i32::from(*((ptr3 + 0) as *const u8)) { - 0 => Ok(DeValueHandle { - handle: *((ptr3 + 4) as *const i32), - }), - 1 => Err(DeError(*((ptr3 + 4) as *const i32))), - _ => ::std::rt::begin_panic("invalid enum discriminant"), + impl wit_bindgen_wasmtime::Endian for SeqAccessHandle { + fn into_le(self) -> Self { + Self { + handle: self.handle.into_le(), } } - } - } - #[repr(align(4))] - struct RetArea([u8; 16]); - static mut SERDE_WASM_HOST_RET_AREA: RetArea = RetArea([0; 16]); -} -const _ : & str = "record usize {\n size: u32,\n}\n\nvariant unexpected {\n %bool(bool),\n unsigned(u64),\n signed(s64),\n float(float64),\n %char(char),\n str(string),\n bytes(list),\n %unit,\n %option,\n newtype-struct,\n seq,\n map,\n %enum,\n unit-variant,\n newtype-variant,\n tuple-variant,\n struct-variant,\n other(string),\n}\n\nresource de-error {\n static custom: func(msg: string) -> de-error\n static invalid-type: func(unexp: unexpected, exp: string) -> de-error\n static invalid-value: func(unexp: unexpected, exp: string) -> de-error\n static invalid-length: func(len: usize, exp: string) -> de-error\n static unknown-variant: func(%variant: string, %expected: list) -> de-error\n static unknown-field: func(field: string, %expected: list) -> de-error\n static missing-field: func(field: string) -> de-error\n static duplicate-field: func(field: string) -> de-error\n}\n\nresource deserializer {\n erased-deserialize-any: func(visitor: visitor-handle) -> expected\n erased-deserialize-bool: func(visitor: visitor-handle) -> expected\n erased-deserialize-u8: func(visitor: visitor-handle) -> expected\n erased-deserialize-u16: func(visitor: visitor-handle) -> expected\n erased-deserialize-u32: func(visitor: visitor-handle) -> expected\n erased-deserialize-u64: func(visitor: visitor-handle) -> expected\n erased-deserialize-i8: func(visitor: visitor-handle) -> expected\n erased-deserialize-i16: func(visitor: visitor-handle) -> expected\n erased-deserialize-i32: func(visitor: visitor-handle) -> expected\n erased-deserialize-i64: func(visitor: visitor-handle) -> expected\n erased-deserialize-i128: func(visitor: visitor-handle) -> expected\n erased-deserialize-u128: func(visitor: visitor-handle) -> expected\n erased-deserialize-f32: func(visitor: visitor-handle) -> expected\n erased-deserialize-f64: func(visitor: visitor-handle) -> expected\n erased-deserialize-char: func(visitor: visitor-handle) -> expected\n erased-deserialize-str: func(visitor: visitor-handle) -> expected\n erased-deserialize-string: func(visitor: visitor-handle) -> expected\n erased-deserialize-bytes: func(visitor: visitor-handle) -> expected\n erased-deserialize-byte-buf: func(visitor: visitor-handle) -> expected\n erased-deserialize-option: func(visitor: visitor-handle) -> expected\n erased-deserialize-unit: func(visitor: visitor-handle) -> expected\n erased-deserialize-unit-struct: func(name: string, visitor: visitor-handle) -> expected\n erased-deserialize-newtype-struct: func(name: string, visitor: visitor-handle) -> expected\n erased-deserialize-seq: func(visitor: visitor-handle) -> expected\n erased-deserialize-tuple: func(len: usize, visitor: visitor-handle) -> expected\n erased-deserialize-tuple-struct: func(name: string, len: usize, visitor: visitor-handle) -> expected\n erased-deserialize-map: func(visitor: visitor-handle) -> expected\n erased-deserialize-struct: func(name: string, fields: list, visitor: visitor-handle) -> expected\n erased-deserialize-identifier: func(visitor: visitor-handle) -> expected\n erased-deserialize-enum: func(name: string, variants: list, visitor: visitor-handle) -> expected\n erased-deserialize-ignored-any: func(visitor: visitor-handle) -> expected\n erased-is-human-readable: func() -> bool\n}\n\nresource seq-access {\n erased-next-element: func(seed: deserialize-seed-handle) -> expected\n erased-size-hint: func() -> option\n}\n\nresource map-access {\n erased-next-key: func(seed: deserialize-seed-handle) -> expected, de-error>\n erased-next-value: func(seed: deserialize-seed-handle) -> expected\n erased-next-entry: func(kseed: deserialize-seed-handle, vseed: deserialize-seed-handle) -> expected>, de-error>\n erased-size-hint: func() -> option\n}\n\nresource enum-access {\n erased-variant: func(seed: deserialize-seed-handle) -> expected, de-error>\n}\n\nresource variant-access {\n unit-variant: func() -> expected\n newtype-variant-seed: func(seed: deserialize-seed-handle) -> expected\n newtype-variant: func() -> expected\n tuple-variant: func(len: usize, visitor: visitor-handle) -> expected\n struct-variant: func(fields: list, visitor: visitor-handle) -> expected\n}\n\nrecord visitor-handle {\n %handle: s32\n}\n\nrecord de-value-handle {\n %handle: s32\n}\n\nrecord deserialize-seed-handle {\n %handle: s32\n}\n" ; -#[allow(clippy::all)] -mod serde_wasm_guest { - #[repr(C)] - pub struct I128 { - pub hi: u64, - pub lo: u64, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for I128 {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for I128 { - #[inline] - fn clone(&self) -> I128 { - { - let _: ::core::clone::AssertParamIsClone; - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - impl core::fmt::Debug for I128 { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("I128") - .field("hi", &self.hi) - .field("lo", &self.lo) - .finish() - } - } - #[repr(C)] - pub struct U128 { - pub hi: u64, - pub lo: u64, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for U128 {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for U128 { - #[inline] - fn clone(&self) -> U128 { - { - let _: ::core::clone::AssertParamIsClone; - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - impl core::fmt::Debug for U128 { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("U128") - .field("hi", &self.hi) - .field("lo", &self.lo) - .finish() - } - } - #[repr(C)] - pub struct DeErrorHandle { - pub handle: i32, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for DeErrorHandle {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for DeErrorHandle { - #[inline] - fn clone(&self) -> DeErrorHandle { - { - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - impl core::fmt::Debug for DeErrorHandle { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("DeErrorHandle") - .field("handle", &self.handle) - .finish() - } - } - #[repr(C)] - pub struct DeserializerHandle { - pub handle: i32, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for DeserializerHandle {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for DeserializerHandle { - #[inline] - fn clone(&self) -> DeserializerHandle { - { - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - impl core::fmt::Debug for DeserializerHandle { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("DeserializerHandle") - .field("handle", &self.handle) - .finish() - } - } - #[repr(C)] - pub struct SeqAccessHandle { - pub handle: i32, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for SeqAccessHandle {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for SeqAccessHandle { - #[inline] - fn clone(&self) -> SeqAccessHandle { - { - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - impl core::fmt::Debug for SeqAccessHandle { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("SeqAccessHandle") - .field("handle", &self.handle) - .finish() - } - } - #[repr(C)] - pub struct MapAccessHandle { - pub handle: i32, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for MapAccessHandle {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for MapAccessHandle { - #[inline] - fn clone(&self) -> MapAccessHandle { - { - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - impl core::fmt::Debug for MapAccessHandle { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("MapAccessHandle") - .field("handle", &self.handle) - .finish() - } - } - #[repr(C)] - pub struct EnumAccessHandle { - pub handle: i32, - } - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::marker::Copy for EnumAccessHandle {} - #[automatically_derived] - #[allow(unused_qualifications)] - impl ::core::clone::Clone for EnumAccessHandle { - #[inline] - fn clone(&self) -> EnumAccessHandle { - { - let _: ::core::clone::AssertParamIsClone; - *self - } - } - } - impl core::fmt::Debug for EnumAccessHandle { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { - f.debug_struct("EnumAccessHandle") - .field("handle", &self.handle) - .finish() - } - } - unsafe impl wit_bindgen_rust::HandleType for super::DeValue { - #[inline] - fn clone(_val: i32) -> i32 { - #[cfg(not(target_arch = "wasm32"))] - { - { - ::std::rt::begin_panic("handles can only be used on wasm32") - }; - } - } - #[inline] - fn drop(_val: i32) { - #[cfg(not(target_arch = "wasm32"))] - { - { - ::std::rt::begin_panic("handles can only be used on wasm32") - }; - } - } - } - unsafe impl wit_bindgen_rust::LocalHandle for super::DeValue { - #[inline] - fn new(_val: i32) -> i32 { - #[cfg(not(target_arch = "wasm32"))] - { - { - ::std::rt::begin_panic("handles can only be used on wasm32") - }; - } - } - #[inline] - fn get(_val: i32) -> i32 { - #[cfg(not(target_arch = "wasm32"))] - { - { - ::std::rt::begin_panic("handles can only be used on wasm32") - }; - } - } - } - const _: () = { - #[export_name = "canonical_abi_drop_de-value"] - extern "C" fn drop(ty: Box) { - ::drop_de_value(*ty) - } - }; - unsafe impl wit_bindgen_rust::HandleType for super::DeserializeSeed { - #[inline] - fn clone(_val: i32) -> i32 { - #[cfg(not(target_arch = "wasm32"))] - { - { - ::std::rt::begin_panic("handles can only be used on wasm32") - }; - } - } - #[inline] - fn drop(_val: i32) { - #[cfg(not(target_arch = "wasm32"))] - { - { - ::std::rt::begin_panic("handles can only be used on wasm32") - }; - } - } - } - unsafe impl wit_bindgen_rust::LocalHandle for super::DeserializeSeed { - #[inline] - fn new(_val: i32) -> i32 { - #[cfg(not(target_arch = "wasm32"))] - { - { - ::std::rt::begin_panic("handles can only be used on wasm32") - }; - } - } - #[inline] - fn get(_val: i32) -> i32 { - #[cfg(not(target_arch = "wasm32"))] - { - { - ::std::rt::begin_panic("handles can only be used on wasm32") - }; - } - } - } - const _: () = { - #[export_name = "canonical_abi_drop_deserialize-seed"] - extern "C" fn drop(ty: Box) { - ::drop_deserialize_seed(*ty) - } - }; - unsafe impl wit_bindgen_rust::HandleType for super::Visitor { - #[inline] - fn clone(_val: i32) -> i32 { - #[cfg(not(target_arch = "wasm32"))] - { - { - ::std::rt::begin_panic("handles can only be used on wasm32") - }; - } - } - #[inline] - fn drop(_val: i32) { - #[cfg(not(target_arch = "wasm32"))] - { - { - ::std::rt::begin_panic("handles can only be used on wasm32") - }; - } - } - } - unsafe impl wit_bindgen_rust::LocalHandle for super::Visitor { - #[inline] - fn new(_val: i32) -> i32 { - #[cfg(not(target_arch = "wasm32"))] - { - { - ::std::rt::begin_panic("handles can only be used on wasm32") - }; - } - } - #[inline] - fn get(_val: i32) -> i32 { - #[cfg(not(target_arch = "wasm32"))] - { - { - ::std::rt::begin_panic("handles can only be used on wasm32") - }; - } - } - } - const _: () = { - #[export_name = "canonical_abi_drop_visitor"] - extern "C" fn drop(ty: Box) { - ::drop_visitor(*ty) - } - }; - #[export_name = "deserialize-seed::erased-deserialize"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_deserialize_seed_erased_deserialize( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_deserialize( - &wit_bindgen_rust::Handle::from_raw(arg0), - DeserializerHandle { handle: arg1 }, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); - } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); - } - }; - ptr0 - } - #[export_name = "visitor::erased-expecting"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_expecting(arg0: i32) -> i32 { - let result = ::erased_expecting( - &wit_bindgen_rust::Handle::from_raw(arg0), - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Some(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let vec1 = (e.into_bytes()).into_boxed_slice(); - let ptr1 = vec1.as_ptr() as i32; - let len1 = vec1.len() as i32; - core::mem::forget(vec1); - *((ptr0 + 8) as *mut i32) = len1; - *((ptr0 + 4) as *mut i32) = ptr1; - } - None => { - let e = (); - { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - let () = e; + fn from_le(self) -> Self { + Self { + handle: self.handle.from_le(), } } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-bool"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_bool( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_visit_bool( - &wit_bindgen_rust::Handle::from_raw(arg0), - match arg1 { - 0 => false, - 1 => true, - _ => ::std::rt::begin_panic("invalid bool discriminant"), - }, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); - } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); - } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-i8"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_i8( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_visit_i8( - &wit_bindgen_rust::Handle::from_raw(arg0), - arg1 as i8, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); - } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); - } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-i16"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_i16( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_visit_i16( - &wit_bindgen_rust::Handle::from_raw(arg0), - arg1 as i16, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); - } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); - } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-i32"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_i32( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_visit_i32( - &wit_bindgen_rust::Handle::from_raw(arg0), - arg1, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); - } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); - } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-i64"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_i64( - arg0: i32, - arg1: i64, - ) -> i32 { - let result = ::erased_visit_i64( - &wit_bindgen_rust::Handle::from_raw(arg0), - arg1, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); - } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); - } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-i128"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_i128( - arg0: i32, - arg1: i64, - arg2: i64, - ) -> i32 { - let result = ::erased_visit_i128( - &wit_bindgen_rust::Handle::from_raw(arg0), - I128 { - hi: arg1 as u64, - lo: arg2 as u64, - }, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + } + unsafe impl wit_bindgen_wasmtime::AllBytesValid for SeqAccessHandle {} + #[repr(C)] + pub struct MapAccessHandle { + pub handle: i32, + } + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::marker::Copy for MapAccessHandle {} + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::clone::Clone for MapAccessHandle { + #[inline] + fn clone(&self) -> MapAccessHandle { + { + let _: ::core::clone::AssertParamIsClone; + *self + } } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + } + impl core::fmt::Debug for MapAccessHandle { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("MapAccessHandle") + .field("handle", &self.handle) + .finish() } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-u8"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_u8( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_visit_u8( - &wit_bindgen_rust::Handle::from_raw(arg0), - arg1 as u8, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + } + impl wit_bindgen_wasmtime::Endian for MapAccessHandle { + fn into_le(self) -> Self { + Self { + handle: self.handle.into_le(), + } } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + fn from_le(self) -> Self { + Self { + handle: self.handle.from_le(), + } } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-u16"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_u16( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_visit_u16( - &wit_bindgen_rust::Handle::from_raw(arg0), - arg1 as u16, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + } + unsafe impl wit_bindgen_wasmtime::AllBytesValid for MapAccessHandle {} + #[repr(C)] + pub struct EnumAccessHandle { + pub handle: i32, + } + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::marker::Copy for EnumAccessHandle {} + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::clone::Clone for EnumAccessHandle { + #[inline] + fn clone(&self) -> EnumAccessHandle { + { + let _: ::core::clone::AssertParamIsClone; + *self + } } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + } + impl core::fmt::Debug for EnumAccessHandle { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.debug_struct("EnumAccessHandle") + .field("handle", &self.handle) + .finish() } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-u32"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_u32( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_visit_u32( - &wit_bindgen_rust::Handle::from_raw(arg0), - arg1 as u32, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + } + impl wit_bindgen_wasmtime::Endian for EnumAccessHandle { + fn into_le(self) -> Self { + Self { + handle: self.handle.into_le(), + } } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + fn from_le(self) -> Self { + Self { + handle: self.handle.from_le(), + } } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-u64"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_u64( - arg0: i32, - arg1: i64, - ) -> i32 { - let result = ::erased_visit_u64( - &wit_bindgen_rust::Handle::from_raw(arg0), - arg1 as u64, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + } + unsafe impl wit_bindgen_wasmtime::AllBytesValid for EnumAccessHandle {} + pub struct DeValue(wit_bindgen_wasmtime::rt::ResourceIndex); + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::fmt::Debug for DeValue { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + match *self { + DeValue(ref __self_0_0) => { + let debug_trait_builder = + &mut ::core::fmt::Formatter::debug_tuple(f, "DeValue"); + let _ = + ::core::fmt::DebugTuple::field(debug_trait_builder, &&(*__self_0_0)); + ::core::fmt::DebugTuple::finish(debug_trait_builder) + } + } } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + } + pub struct DeserializeSeed(wit_bindgen_wasmtime::rt::ResourceIndex); + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::fmt::Debug for DeserializeSeed { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + match *self { + DeserializeSeed(ref __self_0_0) => { + let debug_trait_builder = + &mut ::core::fmt::Formatter::debug_tuple(f, "DeserializeSeed"); + let _ = + ::core::fmt::DebugTuple::field(debug_trait_builder, &&(*__self_0_0)); + ::core::fmt::DebugTuple::finish(debug_trait_builder) + } + } } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-u128"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_u128( - arg0: i32, - arg1: i64, - arg2: i64, - ) -> i32 { - let result = ::erased_visit_u128( - &wit_bindgen_rust::Handle::from_raw(arg0), - U128 { - hi: arg1 as u64, - lo: arg2 as u64, - }, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + } + pub struct Visitor(wit_bindgen_wasmtime::rt::ResourceIndex); + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::fmt::Debug for Visitor { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + match *self { + Visitor(ref __self_0_0) => { + let debug_trait_builder = + &mut ::core::fmt::Formatter::debug_tuple(f, "Visitor"); + let _ = + ::core::fmt::DebugTuple::field(debug_trait_builder, &&(*__self_0_0)); + ::core::fmt::DebugTuple::finish(debug_trait_builder) + } + } } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + } + /// Auxiliary data associated with the wasm exports. + /// + /// This is required to be stored within the data of a + /// `Store` itself so lifting/lowering state can be managed + /// when translating between the host and wasm. + pub struct SerdeWasmGuestData { + index_slab0: wit_bindgen_wasmtime::rt::IndexSlab, + resource_slab0: wit_bindgen_wasmtime::rt::ResourceSlab, + dtor0: Option>, + index_slab1: wit_bindgen_wasmtime::rt::IndexSlab, + resource_slab1: wit_bindgen_wasmtime::rt::ResourceSlab, + dtor1: Option>, + index_slab2: wit_bindgen_wasmtime::rt::IndexSlab, + resource_slab2: wit_bindgen_wasmtime::rt::ResourceSlab, + dtor2: Option>, + } + #[automatically_derived] + #[allow(unused_qualifications)] + impl ::core::default::Default for SerdeWasmGuestData { + #[inline] + fn default() -> SerdeWasmGuestData { + SerdeWasmGuestData { + index_slab0: ::core::default::Default::default(), + resource_slab0: ::core::default::Default::default(), + dtor0: ::core::default::Default::default(), + index_slab1: ::core::default::Default::default(), + resource_slab1: ::core::default::Default::default(), + dtor1: ::core::default::Default::default(), + index_slab2: ::core::default::Default::default(), + resource_slab2: ::core::default::Default::default(), + dtor2: ::core::default::Default::default(), + } } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-f32"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_f32( - arg0: i32, - arg1: f32, - ) -> i32 { - let result = ::erased_visit_f32( - &wit_bindgen_rust::Handle::from_raw(arg0), - arg1, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + } + pub struct SerdeWasmGuest { + get_state: Box &mut SerdeWasmGuestData + Send + Sync>, + canonical_abi_free: wasmtime::TypedFunc<(i32, i32, i32), ()>, + canonical_abi_realloc: wasmtime::TypedFunc<(i32, i32, i32, i32), i32>, + deserialize_seed_erased_deserialize: wasmtime::TypedFunc<(i32, i32), (i32,)>, + memory: wasmtime::Memory, + visitor_erased_expecting: wasmtime::TypedFunc<(i32,), (i32,)>, + visitor_erased_visit_bool: wasmtime::TypedFunc<(i32, i32), (i32,)>, + visitor_erased_visit_byte_buf: wasmtime::TypedFunc<(i32, i32, i32), (i32,)>, + visitor_erased_visit_bytes: wasmtime::TypedFunc<(i32, i32, i32), (i32,)>, + visitor_erased_visit_char: wasmtime::TypedFunc<(i32, i32), (i32,)>, + visitor_erased_visit_enum: wasmtime::TypedFunc<(i32, i32), (i32,)>, + visitor_erased_visit_f32: wasmtime::TypedFunc<(i32, f32), (i32,)>, + visitor_erased_visit_f64: wasmtime::TypedFunc<(i32, f64), (i32,)>, + visitor_erased_visit_i128: wasmtime::TypedFunc<(i32, i64, i64), (i32,)>, + visitor_erased_visit_i16: wasmtime::TypedFunc<(i32, i32), (i32,)>, + visitor_erased_visit_i32: wasmtime::TypedFunc<(i32, i32), (i32,)>, + visitor_erased_visit_i64: wasmtime::TypedFunc<(i32, i64), (i32,)>, + visitor_erased_visit_i8: wasmtime::TypedFunc<(i32, i32), (i32,)>, + visitor_erased_visit_map: wasmtime::TypedFunc<(i32, i32), (i32,)>, + visitor_erased_visit_newtype_struct: wasmtime::TypedFunc<(i32, i32), (i32,)>, + visitor_erased_visit_none: wasmtime::TypedFunc<(i32,), (i32,)>, + visitor_erased_visit_seq: wasmtime::TypedFunc<(i32, i32), (i32,)>, + visitor_erased_visit_some: wasmtime::TypedFunc<(i32, i32), (i32,)>, + visitor_erased_visit_str: wasmtime::TypedFunc<(i32, i32, i32), (i32,)>, + visitor_erased_visit_string: wasmtime::TypedFunc<(i32, i32, i32), (i32,)>, + visitor_erased_visit_u128: wasmtime::TypedFunc<(i32, i64, i64), (i32,)>, + visitor_erased_visit_u16: wasmtime::TypedFunc<(i32, i32), (i32,)>, + visitor_erased_visit_u32: wasmtime::TypedFunc<(i32, i32), (i32,)>, + visitor_erased_visit_u64: wasmtime::TypedFunc<(i32, i64), (i32,)>, + visitor_erased_visit_u8: wasmtime::TypedFunc<(i32, i32), (i32,)>, + visitor_erased_visit_unit: wasmtime::TypedFunc<(i32,), (i32,)>, + } + impl SerdeWasmGuest { + /// Adds any intrinsics, if necessary for this exported wasm + /// functionality to the `linker` provided. + /// + /// The `get_state` closure is required to access the + /// auxiliary data necessary for these wasm exports from + /// the general store's state. + pub fn add_to_linker( + linker: &mut wasmtime::Linker, + get_state: impl Fn(&mut T) -> &mut SerdeWasmGuestData + Send + Sync + Copy + 'static, + ) -> anyhow::Result<()> { + linker.func_wrap( + "canonical_abi", + "resource_drop_de-value", + move |mut caller: wasmtime::Caller<'_, T>, idx: u32| { + let state = get_state(caller.data_mut()); + let resource_idx = state.index_slab0.remove(idx)?; + let wasm = match state.resource_slab0.drop(resource_idx) { + Some(wasm) => wasm, + None => return Ok(()), + }; + let dtor = state.dtor0.expect("destructor not set yet"); + dtor.call(&mut caller, wasm)?; + Ok(()) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_clone_de-value", + move |mut caller: wasmtime::Caller<'_, T>, idx: u32| { + let state = get_state(caller.data_mut()); + let resource_idx = state.index_slab0.get(idx)?; + state.resource_slab0.clone(resource_idx)?; + Ok(state.index_slab0.insert(resource_idx)) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_get_de-value", + move |mut caller: wasmtime::Caller<'_, T>, idx: u32| { + let state = get_state(caller.data_mut()); + let resource_idx = state.index_slab0.get(idx)?; + Ok(state.resource_slab0.get(resource_idx)) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_new_de-value", + move |mut caller: wasmtime::Caller<'_, T>, val: i32| { + let state = get_state(caller.data_mut()); + let resource_idx = state.resource_slab0.insert(val); + Ok(state.index_slab0.insert(resource_idx)) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_drop_deserialize-seed", + move |mut caller: wasmtime::Caller<'_, T>, idx: u32| { + let state = get_state(caller.data_mut()); + let resource_idx = state.index_slab1.remove(idx)?; + let wasm = match state.resource_slab1.drop(resource_idx) { + Some(wasm) => wasm, + None => return Ok(()), + }; + let dtor = state.dtor1.expect("destructor not set yet"); + dtor.call(&mut caller, wasm)?; + Ok(()) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_clone_deserialize-seed", + move |mut caller: wasmtime::Caller<'_, T>, idx: u32| { + let state = get_state(caller.data_mut()); + let resource_idx = state.index_slab1.get(idx)?; + state.resource_slab1.clone(resource_idx)?; + Ok(state.index_slab1.insert(resource_idx)) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_get_deserialize-seed", + move |mut caller: wasmtime::Caller<'_, T>, idx: u32| { + let state = get_state(caller.data_mut()); + let resource_idx = state.index_slab1.get(idx)?; + Ok(state.resource_slab1.get(resource_idx)) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_new_deserialize-seed", + move |mut caller: wasmtime::Caller<'_, T>, val: i32| { + let state = get_state(caller.data_mut()); + let resource_idx = state.resource_slab1.insert(val); + Ok(state.index_slab1.insert(resource_idx)) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_drop_visitor", + move |mut caller: wasmtime::Caller<'_, T>, idx: u32| { + let state = get_state(caller.data_mut()); + let resource_idx = state.index_slab2.remove(idx)?; + let wasm = match state.resource_slab2.drop(resource_idx) { + Some(wasm) => wasm, + None => return Ok(()), + }; + let dtor = state.dtor2.expect("destructor not set yet"); + dtor.call(&mut caller, wasm)?; + Ok(()) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_clone_visitor", + move |mut caller: wasmtime::Caller<'_, T>, idx: u32| { + let state = get_state(caller.data_mut()); + let resource_idx = state.index_slab2.get(idx)?; + state.resource_slab2.clone(resource_idx)?; + Ok(state.index_slab2.insert(resource_idx)) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_get_visitor", + move |mut caller: wasmtime::Caller<'_, T>, idx: u32| { + let state = get_state(caller.data_mut()); + let resource_idx = state.index_slab2.get(idx)?; + Ok(state.resource_slab2.get(resource_idx)) + }, + )?; + linker.func_wrap( + "canonical_abi", + "resource_new_visitor", + move |mut caller: wasmtime::Caller<'_, T>, val: i32| { + let state = get_state(caller.data_mut()); + let resource_idx = state.resource_slab2.insert(val); + Ok(state.index_slab2.insert(resource_idx)) + }, + )?; + Ok(()) + } + /// Instantiates the provided `module` using the specified + /// parameters, wrapping up the result in a structure that + /// translates between wasm and the host. + /// + /// The `linker` provided will have intrinsics added to it + /// automatically, so it's not necessary to call + /// `add_to_linker` beforehand. This function will + /// instantiate the `module` otherwise using `linker`, and + /// both an instance of this structure and the underlying + /// `wasmtime::Instance` will be returned. + /// + /// The `get_state` parameter is used to access the + /// auxiliary state necessary for these wasm exports from + /// the general store state `T`. + pub fn instantiate( + mut store: impl wasmtime::AsContextMut, + module: &wasmtime::Module, + linker: &mut wasmtime::Linker, + get_state: impl Fn(&mut T) -> &mut SerdeWasmGuestData + Send + Sync + Copy + 'static, + ) -> anyhow::Result<(Self, wasmtime::Instance)> { + Self::add_to_linker(linker, get_state)?; + let instance = linker.instantiate(&mut store, module)?; + Ok((Self::new(store, &instance, get_state)?, instance)) + } + /// Low-level creation wrapper for wrapping up the exports + /// of the `instance` provided in this structure of wasm + /// exports. + /// + /// This function will extract exports from the `instance` + /// defined within `store` and wrap them all up in the + /// returned structure which can be used to interact with + /// the wasm module. + pub fn new( + mut store: impl wasmtime::AsContextMut, + instance: &wasmtime::Instance, + get_state: impl Fn(&mut T) -> &mut SerdeWasmGuestData + Send + Sync + Copy + 'static, + ) -> anyhow::Result { + let mut store = store.as_context_mut(); + let canonical_abi_free = instance + .get_typed_func::<(i32, i32, i32), (), _>(&mut store, "canonical_abi_free")?; + let canonical_abi_realloc = instance + .get_typed_func::<(i32, i32, i32, i32), i32, _>( + &mut store, + "canonical_abi_realloc", + )?; + let deserialize_seed_erased_deserialize = instance + .get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "deserialize-seed::erased-deserialize", + )?; + let memory = instance.get_memory(&mut store, "memory").ok_or_else(|| { + ::anyhow::private::must_use({ + let error = ::anyhow::private::format_err(::core::fmt::Arguments::new_v1( + &["`memory` export not a memory"], + &[], + )); + error + }) + })?; + let visitor_erased_expecting = instance + .get_typed_func::<(i32,), (i32,), _>(&mut store, "visitor::erased-expecting")?; + let visitor_erased_visit_bool = instance.get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-bool", + )?; + let visitor_erased_visit_byte_buf = instance + .get_typed_func::<(i32, i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-byte-buf", + )?; + let visitor_erased_visit_bytes = instance + .get_typed_func::<(i32, i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-bytes", + )?; + let visitor_erased_visit_char = instance.get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-char", + )?; + let visitor_erased_visit_enum = instance.get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-enum", + )?; + let visitor_erased_visit_f32 = instance.get_typed_func::<(i32, f32), (i32,), _>( + &mut store, + "visitor::erased-visit-f32", + )?; + let visitor_erased_visit_f64 = instance.get_typed_func::<(i32, f64), (i32,), _>( + &mut store, + "visitor::erased-visit-f64", + )?; + let visitor_erased_visit_i128 = instance + .get_typed_func::<(i32, i64, i64), (i32,), _>( + &mut store, + "visitor::erased-visit-i128", + )?; + let visitor_erased_visit_i16 = instance.get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-i16", + )?; + let visitor_erased_visit_i32 = instance.get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-i32", + )?; + let visitor_erased_visit_i64 = instance.get_typed_func::<(i32, i64), (i32,), _>( + &mut store, + "visitor::erased-visit-i64", + )?; + let visitor_erased_visit_i8 = instance.get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-i8", + )?; + let visitor_erased_visit_map = instance.get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-map", + )?; + let visitor_erased_visit_newtype_struct = instance + .get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-newtype-struct", + )?; + let visitor_erased_visit_none = instance.get_typed_func::<(i32,), (i32,), _>( + &mut store, + "visitor::erased-visit-none", + )?; + let visitor_erased_visit_seq = instance.get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-seq", + )?; + let visitor_erased_visit_some = instance.get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-some", + )?; + let visitor_erased_visit_str = instance + .get_typed_func::<(i32, i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-str", + )?; + let visitor_erased_visit_string = instance + .get_typed_func::<(i32, i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-string", + )?; + let visitor_erased_visit_u128 = instance + .get_typed_func::<(i32, i64, i64), (i32,), _>( + &mut store, + "visitor::erased-visit-u128", + )?; + let visitor_erased_visit_u16 = instance.get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-u16", + )?; + let visitor_erased_visit_u32 = instance.get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-u32", + )?; + let visitor_erased_visit_u64 = instance.get_typed_func::<(i32, i64), (i32,), _>( + &mut store, + "visitor::erased-visit-u64", + )?; + let visitor_erased_visit_u8 = instance.get_typed_func::<(i32, i32), (i32,), _>( + &mut store, + "visitor::erased-visit-u8", + )?; + let visitor_erased_visit_unit = instance.get_typed_func::<(i32,), (i32,), _>( + &mut store, + "visitor::erased-visit-unit", + )?; + get_state(store.data_mut()).dtor0 = Some( + instance + .get_typed_func::(&mut store, "canonical_abi_drop_de-value")?, + ); + get_state(store.data_mut()).dtor1 = Some(instance.get_typed_func::( + &mut store, + "canonical_abi_drop_deserialize-seed", + )?); + get_state(store.data_mut()).dtor2 = Some( + instance + .get_typed_func::(&mut store, "canonical_abi_drop_visitor")?, + ); + Ok(SerdeWasmGuest { + canonical_abi_free, + canonical_abi_realloc, + deserialize_seed_erased_deserialize, + memory, + visitor_erased_expecting, + visitor_erased_visit_bool, + visitor_erased_visit_byte_buf, + visitor_erased_visit_bytes, + visitor_erased_visit_char, + visitor_erased_visit_enum, + visitor_erased_visit_f32, + visitor_erased_visit_f64, + visitor_erased_visit_i128, + visitor_erased_visit_i16, + visitor_erased_visit_i32, + visitor_erased_visit_i64, + visitor_erased_visit_i8, + visitor_erased_visit_map, + visitor_erased_visit_newtype_struct, + visitor_erased_visit_none, + visitor_erased_visit_seq, + visitor_erased_visit_some, + visitor_erased_visit_str, + visitor_erased_visit_string, + visitor_erased_visit_u128, + visitor_erased_visit_u16, + visitor_erased_visit_u32, + visitor_erased_visit_u64, + visitor_erased_visit_u8, + visitor_erased_visit_unit, + get_state: Box::new(get_state), + }) } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + pub fn deserialize_seed_erased_deserialize( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &DeserializeSeed, + deserializer: DeserializerHandle, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab1 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab1 + .insert(obj0.0); + let DeserializerHandle { handle: handle1 } = deserializer; + let (result2_0,) = self.deserialize_seed_erased_deserialize.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i32(handle1)), + )?; + let load3 = memory.data_mut(&mut caller).load::(result2_0 + 0)?; + Ok(match i32::from(load3) { + 0 => Ok({ + let load4 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + let handle5 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load4 as u32)?; + DeValue(handle5) + }), + 1 => Err({ + let load6 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + DeErrorHandle { handle: load6 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-f64"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_f64( - arg0: i32, - arg1: f64, - ) -> i32 { - let result = ::erased_visit_f64( - &wit_bindgen_rust::Handle::from_raw(arg0), - arg1, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + pub fn visitor_erased_expecting( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + ) -> Result, wasmtime::Trap> { + let func_canonical_abi_free = &self.canonical_abi_free; + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self + .visitor_erased_expecting + .call(&mut caller, (handle0 as i32,))?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => None, + 1 => Some({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let load4 = memory.data_mut(&mut caller).load::(result1_0 + 8)?; + let ptr5 = load3; + let len5 = load4; + let data5 = copy_slice(&mut caller, memory, ptr5, len5, 1)?; + func_canonical_abi_free.call(&mut caller, (ptr5, len5, 1))?; + String::from_utf8(data5) + .map_err(|_| wasmtime::Trap::new("invalid utf-8"))? + }), + _ => return Err(invalid_variant("option")), + }) } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + pub fn visitor_erased_visit_bool( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: bool, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self.visitor_erased_visit_bool.call( + &mut caller, + ( + handle0 as i32, + match v { + true => 1, + false => 0, + }, + ), + )?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-char"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_char( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_visit_char( - &wit_bindgen_rust::Handle::from_raw(arg0), - core::char::from_u32(arg1 as u32).unwrap(), - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + pub fn visitor_erased_visit_i8( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: i8, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self.visitor_erased_visit_i8.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i32(v)), + )?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + pub fn visitor_erased_visit_i16( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: i16, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self.visitor_erased_visit_i16.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i32(v)), + )?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-str"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_str( - arg0: i32, - arg1: i32, - arg2: i32, - ) -> i32 { - let len0 = arg2 as usize; - let result = ::erased_visit_str( - &wit_bindgen_rust::Handle::from_raw(arg0), - String::from_utf8(Vec::from_raw_parts(arg1 as *mut _, len0, len0)).unwrap(), - ); - let ptr1 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; - *((ptr1 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + pub fn visitor_erased_visit_i32( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: i32, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self.visitor_erased_visit_i32.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i32(v)), + )?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - Err(e) => { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle2 } = e; - *((ptr1 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle2); + pub fn visitor_erased_visit_i64( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: i64, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self.visitor_erased_visit_i64.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i64(v)), + )?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr1 - } - #[export_name = "visitor::erased-visit-string"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_string( - arg0: i32, - arg1: i32, - arg2: i32, - ) -> i32 { - let len0 = arg2 as usize; - let result = ::erased_visit_string( - &wit_bindgen_rust::Handle::from_raw(arg0), - String::from_utf8(Vec::from_raw_parts(arg1 as *mut _, len0, len0)).unwrap(), - ); - let ptr1 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; - *((ptr1 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + pub fn visitor_erased_visit_i128( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: I128, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let I128 { hi: hi1, lo: lo1 } = v; + let (result2_0,) = self.visitor_erased_visit_i128.call( + &mut caller, + ( + handle0 as i32, + wit_bindgen_wasmtime::rt::as_i64(hi1), + wit_bindgen_wasmtime::rt::as_i64(lo1), + ), + )?; + let load3 = memory.data_mut(&mut caller).load::(result2_0 + 0)?; + Ok(match i32::from(load3) { + 0 => Ok({ + let load4 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + let handle5 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load4 as u32)?; + DeValue(handle5) + }), + 1 => Err({ + let load6 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + DeErrorHandle { handle: load6 } + }), + _ => return Err(invalid_variant("expected")), + }) } - Err(e) => { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle2 } = e; - *((ptr1 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle2); + pub fn visitor_erased_visit_u8( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: u8, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self.visitor_erased_visit_u8.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i32(v)), + )?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr1 - } - #[export_name = "visitor::erased-visit-bytes"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_bytes( - arg0: i32, - arg1: i32, - arg2: i32, - ) -> i32 { - let len0 = arg2 as usize; - let result = ::erased_visit_bytes( - &wit_bindgen_rust::Handle::from_raw(arg0), - Vec::from_raw_parts(arg1 as *mut _, len0, len0), - ); - let ptr1 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; - *((ptr1 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + pub fn visitor_erased_visit_u16( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: u16, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self.visitor_erased_visit_u16.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i32(v)), + )?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - Err(e) => { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle2 } = e; - *((ptr1 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle2); + pub fn visitor_erased_visit_u32( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: u32, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self.visitor_erased_visit_u32.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i32(v)), + )?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr1 - } - #[export_name = "visitor::erased-visit-byte-buf"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_byte_buf( - arg0: i32, - arg1: i32, - arg2: i32, - ) -> i32 { - let len0 = arg2 as usize; - let result = ::erased_visit_byte_buf( - &wit_bindgen_rust::Handle::from_raw(arg0), - Vec::from_raw_parts(arg1 as *mut _, len0, len0), - ); - let ptr1 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr1 + 0) as *mut u8) = (0i32) as u8; - *((ptr1 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + pub fn visitor_erased_visit_u64( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: u64, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self.visitor_erased_visit_u64.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i64(v)), + )?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - Err(e) => { - *((ptr1 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle2 } = e; - *((ptr1 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle2); + pub fn visitor_erased_visit_u128( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: U128, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let U128 { hi: hi1, lo: lo1 } = v; + let (result2_0,) = self.visitor_erased_visit_u128.call( + &mut caller, + ( + handle0 as i32, + wit_bindgen_wasmtime::rt::as_i64(hi1), + wit_bindgen_wasmtime::rt::as_i64(lo1), + ), + )?; + let load3 = memory.data_mut(&mut caller).load::(result2_0 + 0)?; + Ok(match i32::from(load3) { + 0 => Ok({ + let load4 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + let handle5 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load4 as u32)?; + DeValue(handle5) + }), + 1 => Err({ + let load6 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + DeErrorHandle { handle: load6 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr1 - } - #[export_name = "visitor::erased-visit-none"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_none( - arg0: i32, - ) -> i32 { - let result = ::erased_visit_none( - &wit_bindgen_rust::Handle::from_raw(arg0), - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + pub fn visitor_erased_visit_f32( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: f32, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self + .visitor_erased_visit_f32 + .call(&mut caller, (handle0 as i32, v))?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + pub fn visitor_erased_visit_f64( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: f64, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self + .visitor_erased_visit_f64 + .call(&mut caller, (handle0 as i32, v))?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-some"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_some( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_visit_some( - &wit_bindgen_rust::Handle::from_raw(arg0), - DeserializerHandle { handle: arg1 }, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + pub fn visitor_erased_visit_char( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: char, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self.visitor_erased_visit_char.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i32(v)), + )?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + pub fn visitor_erased_visit_str( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: &str, + ) -> Result, wasmtime::Trap> { + let func_canonical_abi_realloc = &self.canonical_abi_realloc; + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let vec1 = v; + let ptr1 = + func_canonical_abi_realloc.call(&mut caller, (0, 0, 1, vec1.len() as i32))?; + memory + .data_mut(&mut caller) + .store_many(ptr1, vec1.as_bytes())?; + let (result2_0,) = self + .visitor_erased_visit_str + .call(&mut caller, (handle0 as i32, ptr1, vec1.len() as i32))?; + let load3 = memory.data_mut(&mut caller).load::(result2_0 + 0)?; + Ok(match i32::from(load3) { + 0 => Ok({ + let load4 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + let handle5 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load4 as u32)?; + DeValue(handle5) + }), + 1 => Err({ + let load6 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + DeErrorHandle { handle: load6 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-unit"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_unit( - arg0: i32, - ) -> i32 { - let result = ::erased_visit_unit( - &wit_bindgen_rust::Handle::from_raw(arg0), - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + pub fn visitor_erased_visit_string( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: &str, + ) -> Result, wasmtime::Trap> { + let func_canonical_abi_realloc = &self.canonical_abi_realloc; + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let vec1 = v; + let ptr1 = + func_canonical_abi_realloc.call(&mut caller, (0, 0, 1, vec1.len() as i32))?; + memory + .data_mut(&mut caller) + .store_many(ptr1, vec1.as_bytes())?; + let (result2_0,) = self + .visitor_erased_visit_string + .call(&mut caller, (handle0 as i32, ptr1, vec1.len() as i32))?; + let load3 = memory.data_mut(&mut caller).load::(result2_0 + 0)?; + Ok(match i32::from(load3) { + 0 => Ok({ + let load4 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + let handle5 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load4 as u32)?; + DeValue(handle5) + }), + 1 => Err({ + let load6 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + DeErrorHandle { handle: load6 } + }), + _ => return Err(invalid_variant("expected")), + }) } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + pub fn visitor_erased_visit_bytes( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: &[u8], + ) -> Result, wasmtime::Trap> { + let func_canonical_abi_realloc = &self.canonical_abi_realloc; + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let vec1 = v; + let ptr1 = func_canonical_abi_realloc + .call(&mut caller, (0, 0, 1, (vec1.len() as i32) * 1))?; + memory.data_mut(&mut caller).store_many(ptr1, &vec1)?; + let (result2_0,) = self + .visitor_erased_visit_bytes + .call(&mut caller, (handle0 as i32, ptr1, vec1.len() as i32))?; + let load3 = memory.data_mut(&mut caller).load::(result2_0 + 0)?; + Ok(match i32::from(load3) { + 0 => Ok({ + let load4 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + let handle5 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load4 as u32)?; + DeValue(handle5) + }), + 1 => Err({ + let load6 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + DeErrorHandle { handle: load6 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-newtype-struct"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_newtype_struct( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_visit_newtype_struct( - &wit_bindgen_rust::Handle::from_raw(arg0), - DeserializerHandle { handle: arg1 }, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + pub fn visitor_erased_visit_byte_buf( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + v: &[u8], + ) -> Result, wasmtime::Trap> { + let func_canonical_abi_realloc = &self.canonical_abi_realloc; + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let vec1 = v; + let ptr1 = func_canonical_abi_realloc + .call(&mut caller, (0, 0, 1, (vec1.len() as i32) * 1))?; + memory.data_mut(&mut caller).store_many(ptr1, &vec1)?; + let (result2_0,) = self + .visitor_erased_visit_byte_buf + .call(&mut caller, (handle0 as i32, ptr1, vec1.len() as i32))?; + let load3 = memory.data_mut(&mut caller).load::(result2_0 + 0)?; + Ok(match i32::from(load3) { + 0 => Ok({ + let load4 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + let handle5 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load4 as u32)?; + DeValue(handle5) + }), + 1 => Err({ + let load6 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + DeErrorHandle { handle: load6 } + }), + _ => return Err(invalid_variant("expected")), + }) } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + pub fn visitor_erased_visit_none( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self + .visitor_erased_visit_none + .call(&mut caller, (handle0 as i32,))?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-seq"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_seq( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_visit_seq( - &wit_bindgen_rust::Handle::from_raw(arg0), - SeqAccessHandle { handle: arg1 }, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + pub fn visitor_erased_visit_some( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + deserializer: DeserializerHandle, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let DeserializerHandle { handle: handle1 } = deserializer; + let (result2_0,) = self.visitor_erased_visit_some.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i32(handle1)), + )?; + let load3 = memory.data_mut(&mut caller).load::(result2_0 + 0)?; + Ok(match i32::from(load3) { + 0 => Ok({ + let load4 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + let handle5 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load4 as u32)?; + DeValue(handle5) + }), + 1 => Err({ + let load6 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + DeErrorHandle { handle: load6 } + }), + _ => return Err(invalid_variant("expected")), + }) } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + pub fn visitor_erased_visit_unit( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let (result1_0,) = self + .visitor_erased_visit_unit + .call(&mut caller, (handle0 as i32,))?; + let load2 = memory.data_mut(&mut caller).load::(result1_0 + 0)?; + Ok(match i32::from(load2) { + 0 => Ok({ + let load3 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + let handle4 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load3 as u32)?; + DeValue(handle4) + }), + 1 => Err({ + let load5 = memory.data_mut(&mut caller).load::(result1_0 + 4)?; + DeErrorHandle { handle: load5 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-map"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_map( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_visit_map( - &wit_bindgen_rust::Handle::from_raw(arg0), - MapAccessHandle { handle: arg1 }, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + pub fn visitor_erased_visit_newtype_struct( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + deserializer: DeserializerHandle, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let DeserializerHandle { handle: handle1 } = deserializer; + let (result2_0,) = self.visitor_erased_visit_newtype_struct.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i32(handle1)), + )?; + let load3 = memory.data_mut(&mut caller).load::(result2_0 + 0)?; + Ok(match i32::from(load3) { + 0 => Ok({ + let load4 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + let handle5 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load4 as u32)?; + DeValue(handle5) + }), + 1 => Err({ + let load6 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + DeErrorHandle { handle: load6 } + }), + _ => return Err(invalid_variant("expected")), + }) } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + pub fn visitor_erased_visit_seq( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + seq: SeqAccessHandle, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let SeqAccessHandle { handle: handle1 } = seq; + let (result2_0,) = self.visitor_erased_visit_seq.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i32(handle1)), + )?; + let load3 = memory.data_mut(&mut caller).load::(result2_0 + 0)?; + Ok(match i32::from(load3) { + 0 => Ok({ + let load4 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + let handle5 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load4 as u32)?; + DeValue(handle5) + }), + 1 => Err({ + let load6 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + DeErrorHandle { handle: load6 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr0 - } - #[export_name = "visitor::erased-visit-enum"] - unsafe extern "C" fn __wit_bindgen_serde_wasm_guest_visitor_erased_visit_enum( - arg0: i32, - arg1: i32, - ) -> i32 { - let result = ::erased_visit_enum( - &wit_bindgen_rust::Handle::from_raw(arg0), - EnumAccessHandle { handle: arg1 }, - ); - let ptr0 = SERDE_WASM_GUEST_RET_AREA.0.as_mut_ptr() as i32; - match result { - Ok(e) => { - *((ptr0 + 0) as *mut u8) = (0i32) as u8; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::Handle::into_raw(e); + pub fn visitor_erased_visit_map( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + map: MapAccessHandle, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let MapAccessHandle { handle: handle1 } = map; + let (result2_0,) = self.visitor_erased_visit_map.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i32(handle1)), + )?; + let load3 = memory.data_mut(&mut caller).load::(result2_0 + 0)?; + Ok(match i32::from(load3) { + 0 => Ok({ + let load4 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + let handle5 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load4 as u32)?; + DeValue(handle5) + }), + 1 => Err({ + let load6 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + DeErrorHandle { handle: load6 } + }), + _ => return Err(invalid_variant("expected")), + }) } - Err(e) => { - *((ptr0 + 0) as *mut u8) = (1i32) as u8; - let DeErrorHandle { handle: handle1 } = e; - *((ptr0 + 4) as *mut i32) = wit_bindgen_rust::rt::as_i32(handle1); + pub fn visitor_erased_visit_enum( + &self, + mut caller: impl wasmtime::AsContextMut, + self_: &Visitor, + data: EnumAccessHandle, + ) -> Result, wasmtime::Trap> { + let memory = &self.memory; + let obj0 = self_; + (self.get_state)(caller.as_context_mut().data_mut()) + .resource_slab2 + .clone(obj0.0)?; + let handle0 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab2 + .insert(obj0.0); + let EnumAccessHandle { handle: handle1 } = data; + let (result2_0,) = self.visitor_erased_visit_enum.call( + &mut caller, + (handle0 as i32, wit_bindgen_wasmtime::rt::as_i32(handle1)), + )?; + let load3 = memory.data_mut(&mut caller).load::(result2_0 + 0)?; + Ok(match i32::from(load3) { + 0 => Ok({ + let load4 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + let handle5 = (self.get_state)(caller.as_context_mut().data_mut()) + .index_slab0 + .remove(load4 as u32)?; + DeValue(handle5) + }), + 1 => Err({ + let load6 = memory.data_mut(&mut caller).load::(result2_0 + 4)?; + DeErrorHandle { handle: load6 } + }), + _ => return Err(invalid_variant("expected")), + }) } - }; - ptr0 - } - #[repr(align(4))] - struct RetArea([u8; 12]); - static mut SERDE_WASM_GUEST_RET_AREA: RetArea = RetArea([0; 12]); - pub trait SerdeWasmGuest { - /// An optional callback invoked when a handle is finalized - /// and destroyed. - fn drop_de_value(val: super::DeValue) { - drop(val); - } - /// An optional callback invoked when a handle is finalized - /// and destroyed. - fn drop_deserialize_seed(val: super::DeserializeSeed) { - drop(val); - } - /// An optional callback invoked when a handle is finalized - /// and destroyed. - fn drop_visitor(val: super::Visitor) { - drop(val); - } - } - pub trait DeserializeSeed { - fn erased_deserialize( - &self, - deserializer: DeserializerHandle, - ) -> Result, DeErrorHandle>; - } - pub trait Visitor { - fn erased_expecting(&self) -> Option; - fn erased_visit_bool( - &self, - v: bool, - ) -> Result, DeErrorHandle>; - fn erased_visit_i8( - &self, - v: i8, - ) -> Result, DeErrorHandle>; - fn erased_visit_i16( - &self, - v: i16, - ) -> Result, DeErrorHandle>; - fn erased_visit_i32( - &self, - v: i32, - ) -> Result, DeErrorHandle>; - fn erased_visit_i64( - &self, - v: i64, - ) -> Result, DeErrorHandle>; - fn erased_visit_i128( - &self, - v: I128, - ) -> Result, DeErrorHandle>; - fn erased_visit_u8( - &self, - v: u8, - ) -> Result, DeErrorHandle>; - fn erased_visit_u16( - &self, - v: u16, - ) -> Result, DeErrorHandle>; - fn erased_visit_u32( - &self, - v: u32, - ) -> Result, DeErrorHandle>; - fn erased_visit_u64( - &self, - v: u64, - ) -> Result, DeErrorHandle>; - fn erased_visit_u128( - &self, - v: U128, - ) -> Result, DeErrorHandle>; - fn erased_visit_f32( - &self, - v: f32, - ) -> Result, DeErrorHandle>; - fn erased_visit_f64( - &self, - v: f64, - ) -> Result, DeErrorHandle>; - fn erased_visit_char( - &self, - v: char, - ) -> Result, DeErrorHandle>; - fn erased_visit_str( - &self, - v: String, - ) -> Result, DeErrorHandle>; - fn erased_visit_string( - &self, - v: String, - ) -> Result, DeErrorHandle>; - fn erased_visit_bytes( - &self, - v: Vec, - ) -> Result, DeErrorHandle>; - fn erased_visit_byte_buf( - &self, - v: Vec, - ) -> Result, DeErrorHandle>; - fn erased_visit_none( - &self, - ) -> Result, DeErrorHandle>; - fn erased_visit_some( - &self, - deserializer: DeserializerHandle, - ) -> Result, DeErrorHandle>; - fn erased_visit_unit( - &self, - ) -> Result, DeErrorHandle>; - fn erased_visit_newtype_struct( - &self, - deserializer: DeserializerHandle, - ) -> Result, DeErrorHandle>; - fn erased_visit_seq( - &self, - seq: SeqAccessHandle, - ) -> Result, DeErrorHandle>; - fn erased_visit_map( - &self, - map: MapAccessHandle, - ) -> Result, DeErrorHandle>; - fn erased_visit_enum( - &self, - data: EnumAccessHandle, - ) -> Result, DeErrorHandle>; - } -} -const _ : & str = "record i128 {\n hi: u64,\n lo: u64,\n}\n\nrecord u128 {\n hi: u64,\n lo: u64,\n}\n\nresource de-value {}\n\nresource deserialize-seed {\n erased-deserialize: func(deserializer: deserializer-handle) -> expected\n}\n\nresource visitor {\n erased-expecting: func() -> option\n \n erased-visit-bool: func(v: bool) -> expected\n erased-visit-i8: func(v: s8) -> expected\n erased-visit-i16: func(v: s16) -> expected\n erased-visit-i32: func(v: s32) -> expected\n erased-visit-i64: func(v: s64) -> expected\n erased-visit-i128: func(v: i128) -> expected\n erased-visit-u8: func(v: u8) -> expected\n erased-visit-u16: func(v: u16) -> expected\n erased-visit-u32: func(v: u32) -> expected\n erased-visit-u64: func(v: u64) -> expected\n erased-visit-u128: func(v: u128) -> expected\n erased-visit-f32: func(v: float32) -> expected\n erased-visit-f64: func(v: float64) -> expected\n erased-visit-char: func(v: char) -> expected\n erased-visit-str: func(v: string) -> expected\n erased-visit-string: func(v: string) -> expected\n erased-visit-bytes: func(v: list) -> expected\n erased-visit-byte-buf: func(v: list) -> expected\n erased-visit-none: func() -> expected\n erased-visit-some: func(deserializer: deserializer-handle) -> expected\n erased-visit-unit: func() -> expected\n erased-visit-newtype-struct: func(deserializer: deserializer-handle) -> expected\n erased-visit-seq: func(seq: seq-access-handle) -> expected\n erased-visit-map: func(map: map-access-handle) -> expected\n erased-visit-enum: func(data: enum-access-handle) -> expected\n}\n\nrecord de-error-handle {\n %handle: s32\n}\n\nrecord deserializer-handle {\n %handle: s32\n}\n\nrecord seq-access-handle {\n %handle: s32\n}\n\nrecord map-access-handle {\n %handle: s32\n}\n\nrecord enum-access-handle {\n %handle: s32\n}\n" ; -struct DeValue { - inner: RefCell>, -} -struct DeserializeSeed { - inner: Box>>, -} -impl serde_wasm_guest::DeserializeSeed for DeserializeSeed { - fn erased_deserialize( - &self, - deserializer: serde_wasm_guest::DeserializerHandle, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result( - self.inner - .borrow_mut() - .erased_deserialize_seed(&mut Deserializer::from(deserializer)), - ) - } -} -struct Visitor { - inner: RefCell<&'static mut dyn de::Visitor<'static>>, -} -fn map_erased_result( - result: Result, -) -> Result, serde_wasm_guest::DeErrorHandle> { - match result { - Ok(out) => Ok(wit_bindgen_rust::Handle::new(DeValue { - inner: RefCell::new(Some(out)), - })), - Err(err) => Err(err.into()), - } -} -fn map_bridge_result( - result: Result, -) -> Result { - match result { - Ok(handle) => { - let handle: wit_bindgen_rust::Handle = - unsafe { wit_bindgen_rust::Handle::from_raw(handle.handle) }; - let out = handle.inner.borrow_mut().take().unwrap(); - Ok(out) - } - Err(err) => Err(Error { inner: err }), - } -} -impl From for serde_wasm_guest::DeErrorHandle { - fn from(err: Error) -> Self { - Self { - handle: err.inner.into_raw(), - } - } -} -impl From for Deserializer { - fn from(deserializer: serde_wasm_guest::DeserializerHandle) -> Self { - Self { - inner: unsafe { serde_wasm_host::Deserializer::from_raw(deserializer.handle) }, - } - } -} -impl<'a, 'de> From<&'a mut dyn de::Visitor<'de>> for serde_wasm_host::VisitorHandle { - fn from(visitor: &'a mut dyn de::Visitor<'de>) -> Self { - let visitor: &'static mut dyn de::Visitor<'static> = - unsafe { std::mem::transmute(visitor) }; - let visitor = Visitor { - inner: RefCell::new(visitor), - }; - let handle = wit_bindgen_rust::Handle::new(visitor); - Self { - handle: wit_bindgen_rust::Handle::into_raw(handle), - } - } -} -impl serde_wasm_guest::Visitor for Visitor { - fn erased_expecting(&self) -> Option { - struct Expecting<'a>(&'a Visitor); - impl<'a> fmt::Display for Expecting<'a> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - self.0.inner.borrow().erased_expecting(fmt) + /// Drops the host-owned handle to the resource + /// specified. + /// + /// Note that this may execute the WebAssembly-defined + /// destructor for this type. This also may not run + /// the destructor if there are still other references + /// to this type. + pub fn drop_de_value( + &self, + mut store: impl wasmtime::AsContextMut, + val: DeValue, + ) -> Result<(), wasmtime::Trap> { + let mut store = store.as_context_mut(); + let data = (self.get_state)(store.data_mut()); + let wasm = match data.resource_slab0.drop(val.0) { + Some(val) => val, + None => return Ok(()), + }; + data.dtor0.unwrap().call(&mut store, wasm)?; + Ok(()) + } + /// Drops the host-owned handle to the resource + /// specified. + /// + /// Note that this may execute the WebAssembly-defined + /// destructor for this type. This also may not run + /// the destructor if there are still other references + /// to this type. + pub fn drop_deserialize_seed( + &self, + mut store: impl wasmtime::AsContextMut, + val: DeserializeSeed, + ) -> Result<(), wasmtime::Trap> { + let mut store = store.as_context_mut(); + let data = (self.get_state)(store.data_mut()); + let wasm = match data.resource_slab1.drop(val.0) { + Some(val) => val, + None => return Ok(()), + }; + data.dtor1.unwrap().call(&mut store, wasm)?; + Ok(()) + } + /// Drops the host-owned handle to the resource + /// specified. + /// + /// Note that this may execute the WebAssembly-defined + /// destructor for this type. This also may not run + /// the destructor if there are still other references + /// to this type. + pub fn drop_visitor( + &self, + mut store: impl wasmtime::AsContextMut, + val: Visitor, + ) -> Result<(), wasmtime::Trap> { + let mut store = store.as_context_mut(); + let data = (self.get_state)(store.data_mut()); + let wasm = match data.resource_slab2.drop(val.0) { + Some(val) => val, + None => return Ok(()), + }; + data.dtor2.unwrap().call(&mut store, wasm)?; + Ok(()) } } - let mut buffer = String::new(); - match buffer.write_fmt(::core::fmt::Arguments::new_v1( - &[""], - &[::core::fmt::ArgumentV1::new_display(&Expecting(self))], - )) { - Ok(()) => Some(buffer), - Err(_) => None, - } - } - fn erased_visit_bool( - &self, - v: bool, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_bool(v)) - } - fn erased_visit_i8( - &self, - v: i8, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_i8(v)) - } - fn erased_visit_i16( - &self, - v: i16, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_i16(v)) - } - fn erased_visit_i32( - &self, - v: i32, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_i32(v)) - } - fn erased_visit_i64( - &self, - v: i64, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_i64(v)) - } - fn erased_visit_i128( - &self, - v: serde_wasm_guest::I128, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - let v = unsafe { - std::mem::transmute::((u128::from(v.hi) << 64) | u128::from(v.lo)) - }; - map_erased_result(self.inner.borrow_mut().erased_visit_i128(v)) - } - fn erased_visit_u8( - &self, - v: u8, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_u8(v)) - } - fn erased_visit_u16( - &self, - v: u16, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_u16(v)) - } - fn erased_visit_u32( - &self, - v: u32, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_u32(v)) - } - fn erased_visit_u64( - &self, - v: u64, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_u64(v)) - } - fn erased_visit_u128( - &self, - v: serde_wasm_guest::U128, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - let v = (u128::from(v.hi) << 64) | u128::from(v.lo); - map_erased_result(self.inner.borrow_mut().erased_visit_u128(v)) - } - fn erased_visit_f32( - &self, - v: f32, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_f32(v)) - } - fn erased_visit_f64( - &self, - v: f64, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_f64(v)) - } - fn erased_visit_char( - &self, - v: char, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_char(v)) - } - fn erased_visit_str( - &self, - v: String, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_str(&v)) - } - fn erased_visit_string( - &self, - v: String, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_string(v)) - } - fn erased_visit_bytes( - &self, - v: Vec, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_bytes(&v)) - } - fn erased_visit_byte_buf( - &self, - v: Vec, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_byte_buf(v)) - } - fn erased_visit_none( - &self, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_none()) - } - fn erased_visit_some( - &self, - deserializer: serde_wasm_guest::DeserializerHandle, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result( - self.inner - .borrow_mut() - .erased_visit_some(&mut Deserializer::from(deserializer)), - ) - } - fn erased_visit_unit( - &self, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_unit()) - } - fn erased_visit_newtype_struct( - &self, - deserializer: serde_wasm_guest::DeserializerHandle, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result( - self.inner - .borrow_mut() - .erased_visit_newtype_struct(&mut Deserializer::from(deserializer)), - ) - } - fn erased_visit_seq( - &self, - seq: serde_wasm_guest::SeqAccessHandle, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - ::core::panicking::panic("not yet implemented") - } - fn erased_visit_map( - &self, - map: serde_wasm_guest::MapAccessHandle, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - ::core::panicking::panic("not yet implemented") - } - fn erased_visit_enum( - &self, - data: serde_wasm_guest::EnumAccessHandle, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - ::core::panicking::panic("not yet implemented") - } -} -struct SerdeWasmGuest {} -impl serde_wasm_guest::SerdeWasmGuest for SerdeWasmGuest {} -#[cfg(not(target_pointer_width = "32"))] -impl From for serde_wasm_host::Usize { - fn from(size: usize) -> Self { - extern "C" { - fn usize_must_be_u32(size: usize) -> !; - } - unsafe { usize_must_be_u32(size) } - } -} -pub struct Error { - inner: serde_wasm_host::DeError, -} -impl fmt::Debug for Error { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.debug_struct("Error").finish_non_exhaustive() - } -} -impl fmt::Display for Error { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.debug_struct("Error").finish_non_exhaustive() - } -} -impl std::error::Error for Error {} -impl serde::de::Error for Error { - #[cold] - fn custom(msg: T) -> Self { - Self { - inner: serde_wasm_host::DeError::custom(&msg.to_string()), - } - } - #[cold] - fn invalid_type(unexp: serde::de::Unexpected, exp: &dyn serde::de::Expected) -> Self { - Self { - inner: serde_wasm_host::DeError::invalid_type(unexp.into(), &exp.to_string()), - } - } - #[cold] - fn invalid_value(unexp: serde::de::Unexpected, exp: &dyn serde::de::Expected) -> Self { - Self { - inner: serde_wasm_host::DeError::invalid_value(unexp.into(), &exp.to_string()), - } - } - #[cold] - fn invalid_length(len: usize, exp: &dyn serde::de::Expected) -> Self { - Self { - inner: serde_wasm_host::DeError::invalid_length(len.into(), &exp.to_string()), - } - } - #[cold] - fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self { - Self { - inner: serde_wasm_host::DeError::unknown_variant(variant, expected), - } - } - #[cold] - fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self { - Self { - inner: serde_wasm_host::DeError::unknown_field(field, expected), - } - } - #[cold] - fn missing_field(field: &'static str) -> Self { - Self { - inner: serde_wasm_host::DeError::missing_field(field), - } - } - #[cold] - fn duplicate_field(field: &'static str) -> Self { - Self { - inner: serde_wasm_host::DeError::duplicate_field(field), - } - } -} -impl<'a> From> for serde_wasm_host::Unexpected<'a> { - fn from(unexpected: serde::de::Unexpected<'a>) -> Self { - use serde::de::Unexpected::*; - match unexpected { - Bool(b) => Self::Bool(b), - Unsigned(u) => Self::Unsigned(u), - Signed(s) => Self::Signed(s), - Float(f) => Self::Float(f), - Char(c) => Self::Char(c), - Str(s) => Self::Str(s), - Bytes(b) => Self::Bytes(b), - Unit => Self::Unit, - Option => Self::Option, - NewtypeStruct => Self::NewtypeStruct, - Seq => Self::Seq, - Map => Self::Map, - Enum => Self::Enum, - UnitVariant => Self::UnitVariant, - NewtypeVariant => Self::NewtypeVariant, - TupleVariant => Self::TupleVariant, - StructVariant => Self::StructVariant, - Other(o) => Self::Other(o), - } - } -} -struct Deserializer { - inner: serde_wasm_host::Deserializer, -} -impl<'de> de::Deserializer<'de> for Deserializer { - fn erased_deserialize_any(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_any(v.into())) - } - fn erased_deserialize_bool(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_bool(v.into())) - } - fn erased_deserialize_u8(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_u8(v.into())) - } - fn erased_deserialize_u16(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_u16(v.into())) - } - fn erased_deserialize_u32(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_u32(v.into())) - } - fn erased_deserialize_u64(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_u64(v.into())) - } - fn erased_deserialize_i8(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_i8(v.into())) - } - fn erased_deserialize_i16(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_i16(v.into())) - } - fn erased_deserialize_i32(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_i32(v.into())) - } - fn erased_deserialize_i64(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_i64(v.into())) - } - fn erased_deserialize_i128(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_i128(v.into())) - } - fn erased_deserialize_u128(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_u128(v.into())) - } - fn erased_deserialize_f32(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_f32(v.into())) - } - fn erased_deserialize_f64(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_f64(v.into())) - } - fn erased_deserialize_char(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_char(v.into())) - } - fn erased_deserialize_str(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_str(v.into())) - } - fn erased_deserialize_string( - &mut self, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_string(v.into())) - } - fn erased_deserialize_bytes(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_bytes(v.into())) - } - fn erased_deserialize_byte_buf( - &mut self, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_byte_buf(v.into())) - } - fn erased_deserialize_option( - &mut self, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_option(v.into())) - } - fn erased_deserialize_unit(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_unit(v.into())) - } - fn erased_deserialize_unit_struct( - &mut self, - name: &'static str, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_unit_struct(name, v.into())) - } - fn erased_deserialize_newtype_struct( - &mut self, - name: &'static str, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_newtype_struct(name, v.into())) - } - fn erased_deserialize_seq(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_seq(v.into())) - } - fn erased_deserialize_tuple( - &mut self, - len: usize, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_tuple(len.into(), v.into())) - } - fn erased_deserialize_tuple_struct( - &mut self, - name: &'static str, - len: usize, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result( - self.inner - .erased_deserialize_tuple_struct(name, len.into(), v.into()), - ) - } - fn erased_deserialize_map(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_map(v.into())) - } - fn erased_deserialize_struct( - &mut self, - name: &'static str, - fields: &'static [&'static str], - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_struct(name, fields, v.into())) - } - fn erased_deserialize_identifier( - &mut self, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_identifier(v.into())) - } - fn erased_deserialize_enum( - &mut self, - name: &'static str, - variants: &'static [&'static str], - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_enum(name, variants, v.into())) - } - fn erased_deserialize_ignored_any( - &mut self, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_ignored_any(v.into())) - } - fn erased_is_human_readable(&self) -> bool { - self.inner.erased_is_human_readable() + use wit_bindgen_wasmtime::rt::RawMem; + use wit_bindgen_wasmtime::rt::invalid_variant; + use wit_bindgen_wasmtime::rt::copy_slice; } + const _ : & str = "record i128 {\n hi: u64,\n lo: u64,\n}\n\nrecord u128 {\n hi: u64,\n lo: u64,\n}\n\nresource de-value {}\n\nresource deserialize-seed {\n erased-deserialize: func(deserializer: deserializer-handle) -> expected\n}\n\nresource visitor {\n erased-expecting: func() -> option\n \n erased-visit-bool: func(v: bool) -> expected\n erased-visit-i8: func(v: s8) -> expected\n erased-visit-i16: func(v: s16) -> expected\n erased-visit-i32: func(v: s32) -> expected\n erased-visit-i64: func(v: s64) -> expected\n erased-visit-i128: func(v: i128) -> expected\n erased-visit-u8: func(v: u8) -> expected\n erased-visit-u16: func(v: u16) -> expected\n erased-visit-u32: func(v: u32) -> expected\n erased-visit-u64: func(v: u64) -> expected\n erased-visit-u128: func(v: u128) -> expected\n erased-visit-f32: func(v: float32) -> expected\n erased-visit-f64: func(v: float64) -> expected\n erased-visit-char: func(v: char) -> expected\n erased-visit-str: func(v: string) -> expected\n erased-visit-string: func(v: string) -> expected\n erased-visit-bytes: func(v: list) -> expected\n erased-visit-byte-buf: func(v: list) -> expected\n erased-visit-none: func() -> expected\n erased-visit-some: func(deserializer: deserializer-handle) -> expected\n erased-visit-unit: func() -> expected\n erased-visit-newtype-struct: func(deserializer: deserializer-handle) -> expected\n erased-visit-seq: func(seq: seq-access-handle) -> expected\n erased-visit-map: func(map: map-access-handle) -> expected\n erased-visit-enum: func(data: enum-access-handle) -> expected\n}\n\nrecord de-error-handle {\n %handle: s32\n}\n\nrecord deserializer-handle {\n %handle: s32\n}\n\nrecord seq-access-handle {\n %handle: s32\n}\n\nrecord map-access-handle {\n %handle: s32\n}\n\nrecord enum-access-handle {\n %handle: s32\n}\n" ; } diff --git a/necsim/plugins/wasm/src/error.rs b/necsim/plugins/wasm/src/error.rs index a1a0fafb8..e382d92a0 100644 --- a/necsim/plugins/wasm/src/error.rs +++ b/necsim/plugins/wasm/src/error.rs @@ -1,4 +1,4 @@ -pub(crate) use crate::Error; +pub(crate) use crate::guest::DeError as Error; // use core::fmt::{self, Display}; diff --git a/necsim/plugins/wasm/src/guest.rs b/necsim/plugins/wasm/src/guest.rs new file mode 100644 index 000000000..2b8900e69 --- /dev/null +++ b/necsim/plugins/wasm/src/guest.rs @@ -0,0 +1,864 @@ +use std::{ + cell::RefCell, + fmt::{self, Write}, +}; + +wit_bindgen_rust::import!("src/serde-wasm-host.wit"); +wit_bindgen_rust::export!("src/serde-wasm-guest.wit"); + +use crate::{any, de}; + +#[doc(hidden)] +pub struct DeValue { + inner: RefCell>, +} + +#[doc(hidden)] +pub struct DeserializeSeed { + inner: RefCell<&'static mut dyn de::DeserializeSeed<'static>>, +} + +impl serde_wasm_guest::DeserializeSeed for DeserializeSeed { + fn erased_deserialize( + &self, + deserializer: serde_wasm_guest::DeserializerHandle, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result( + self.inner + .borrow_mut() + .erased_deserialize_seed(&mut Deserializer::from(deserializer)), + ) + } +} + +#[doc(hidden)] +pub struct Visitor { + inner: RefCell<&'static mut dyn de::Visitor<'static>>, +} + +fn map_erased_result( + result: Result, +) -> Result, serde_wasm_guest::DeErrorHandle> { + match result { + Ok(out) => Ok(wit_bindgen_rust::Handle::new(DeValue { + inner: RefCell::new(Some(out)), + })), + Err(err) => Err(err.into()), + } +} + +fn map_bridge_result( + result: Result, +) -> Result { + match result { + Ok(handle) => { + let handle: wit_bindgen_rust::Handle = + unsafe { wit_bindgen_rust::Handle::from_raw(handle.handle) }; + let out = handle.inner.borrow_mut().take().unwrap(); + Ok(out) + }, + Err(err) => Err(DeError { inner: err }), + } +} + +fn map_bridge_option_result( + result: Result, serde_wasm_host::DeError>, +) -> Result, DeError> { + match result { + Ok(Some(handle)) => { + let handle: wit_bindgen_rust::Handle = + unsafe { wit_bindgen_rust::Handle::from_raw(handle.handle) }; + let out = handle.inner.borrow_mut().take().unwrap(); + Ok(Some(out)) + }, + Ok(None) => Ok(None), + Err(err) => Err(DeError { inner: err }), + } +} + +fn map_bridge_option_pair_result( + result: Result< + Option<( + serde_wasm_host::DeValueHandle, + serde_wasm_host::DeValueHandle, + )>, + serde_wasm_host::DeError, + >, +) -> Result, DeError> { + match result { + Ok(Some((handle_a, handle_b))) => { + let handle_a: wit_bindgen_rust::Handle = + unsafe { wit_bindgen_rust::Handle::from_raw(handle_a.handle) }; + let out_a = handle_a.inner.borrow_mut().take().unwrap(); + + let handle_b: wit_bindgen_rust::Handle = + unsafe { wit_bindgen_rust::Handle::from_raw(handle_b.handle) }; + let out_b = handle_b.inner.borrow_mut().take().unwrap(); + + Ok(Some((out_a, out_b))) + }, + Ok(None) => Ok(None), + Err(err) => Err(DeError { inner: err }), + } +} + +fn map_bridge_enum_result( + result: Result< + ( + serde_wasm_host::DeValueHandle, + serde_wasm_host::VariantAccess, + ), + serde_wasm_host::DeError, + >, +) -> Result<(de::Out, VariantAccess), DeError> { + match result { + Ok((handle, variant)) => { + let handle: wit_bindgen_rust::Handle = + unsafe { wit_bindgen_rust::Handle::from_raw(handle.handle) }; + let out = handle.inner.borrow_mut().take().unwrap(); + + let variant = VariantAccess { inner: variant }; + + Ok((out, variant)) + }, + Err(err) => Err(DeError { inner: err }), + } +} + +impl From for serde_wasm_guest::DeErrorHandle { + fn from(err: DeError) -> Self { + Self { + handle: err.inner.into_raw(), + } + } +} + +impl From for Deserializer { + fn from(deserializer: serde_wasm_guest::DeserializerHandle) -> Self { + Self { + inner: unsafe { serde_wasm_host::Deserializer::from_raw(deserializer.handle) }, + } + } +} + +impl From for SeqAccess { + fn from(seq: serde_wasm_guest::SeqAccessHandle) -> Self { + Self { + inner: unsafe { serde_wasm_host::SeqAccess::from_raw(seq.handle) }, + } + } +} + +impl From for MapAccess { + fn from(map: serde_wasm_guest::MapAccessHandle) -> Self { + Self { + inner: unsafe { serde_wasm_host::MapAccess::from_raw(map.handle) }, + } + } +} + +impl From for EnumAccess { + fn from(r#enum: serde_wasm_guest::EnumAccessHandle) -> Self { + Self { + inner: unsafe { serde_wasm_host::EnumAccess::from_raw(r#enum.handle) }, + } + } +} + +impl<'a, 'de> From<&'a mut dyn de::Visitor<'de>> for serde_wasm_host::VisitorHandle { + fn from(visitor: &'a mut dyn de::Visitor<'de>) -> Self { + let visitor: &'static mut dyn de::Visitor<'static> = + unsafe { std::mem::transmute(visitor) }; + let visitor = Visitor { + inner: RefCell::new(visitor), + }; + + let handle = wit_bindgen_rust::Handle::new(visitor); + + Self { + handle: wit_bindgen_rust::Handle::into_raw(handle), + } + } +} + +impl<'a, 'de> From<&'a mut dyn de::DeserializeSeed<'de>> + for serde_wasm_host::DeserializeSeedHandle +{ + fn from(deserialize_seed: &'a mut dyn de::DeserializeSeed<'de>) -> Self { + let deserialize_seed: &'static mut dyn de::DeserializeSeed<'static> = + unsafe { std::mem::transmute(deserialize_seed) }; + let deserialize_seed = DeserializeSeed { + inner: RefCell::new(deserialize_seed), + }; + + let handle = wit_bindgen_rust::Handle::new(deserialize_seed); + + Self { + handle: wit_bindgen_rust::Handle::into_raw(handle), + } + } +} + +impl serde_wasm_guest::Visitor for Visitor { + fn erased_expecting(&self) -> Option { + struct Expecting<'a>(&'a Visitor); + + impl<'a> fmt::Display for Expecting<'a> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + self.0.inner.borrow().erased_expecting(fmt) + } + } + + let mut buffer = String::new(); + + match buffer.write_fmt(format_args!("{}", Expecting(self))) { + Ok(()) => Some(buffer), + Err(_) => None, + } + } + + fn erased_visit_bool( + &self, + v: bool, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_bool(v)) + } + + fn erased_visit_i8( + &self, + v: i8, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_i8(v)) + } + + fn erased_visit_i16( + &self, + v: i16, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_i16(v)) + } + + fn erased_visit_i32( + &self, + v: i32, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_i32(v)) + } + + fn erased_visit_i64( + &self, + v: i64, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_i64(v)) + } + + fn erased_visit_i128( + &self, + v: serde_wasm_guest::I128, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + let v = unsafe { + std::mem::transmute::((u128::from(v.hi) << 64) | u128::from(v.lo)) + }; + + map_erased_result(self.inner.borrow_mut().erased_visit_i128(v)) + } + + fn erased_visit_u8( + &self, + v: u8, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_u8(v)) + } + + fn erased_visit_u16( + &self, + v: u16, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_u16(v)) + } + + fn erased_visit_u32( + &self, + v: u32, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_u32(v)) + } + + fn erased_visit_u64( + &self, + v: u64, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_u64(v)) + } + + fn erased_visit_u128( + &self, + v: serde_wasm_guest::U128, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + let v = (u128::from(v.hi) << 64) | u128::from(v.lo); + + map_erased_result(self.inner.borrow_mut().erased_visit_u128(v)) + } + + fn erased_visit_f32( + &self, + v: f32, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_f32(v)) + } + + fn erased_visit_f64( + &self, + v: f64, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_f64(v)) + } + + fn erased_visit_char( + &self, + v: char, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_char(v)) + } + + fn erased_visit_str( + &self, + v: String, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_str(&v)) + } + + fn erased_visit_string( + &self, + v: String, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_string(v)) + } + + fn erased_visit_bytes( + &self, + v: Vec, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_bytes(&v)) + } + + fn erased_visit_byte_buf( + &self, + v: Vec, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_byte_buf(v)) + } + + fn erased_visit_none( + &self, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_none()) + } + + fn erased_visit_some( + &self, + deserializer: serde_wasm_guest::DeserializerHandle, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result( + self.inner + .borrow_mut() + .erased_visit_some(&mut Deserializer::from(deserializer)), + ) + } + + fn erased_visit_unit( + &self, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result(self.inner.borrow_mut().erased_visit_unit()) + } + + fn erased_visit_newtype_struct( + &self, + deserializer: serde_wasm_guest::DeserializerHandle, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result( + self.inner + .borrow_mut() + .erased_visit_newtype_struct(&mut Deserializer::from(deserializer)), + ) + } + + fn erased_visit_seq( + &self, + seq: serde_wasm_guest::SeqAccessHandle, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result( + self.inner + .borrow_mut() + .erased_visit_seq(&mut SeqAccess::from(seq)), + ) + } + + fn erased_visit_map( + &self, + map: serde_wasm_guest::MapAccessHandle, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result( + self.inner + .borrow_mut() + .erased_visit_map(&mut MapAccess::from(map)), + ) + } + + fn erased_visit_enum( + &self, + data: serde_wasm_guest::EnumAccessHandle, + ) -> Result, serde_wasm_guest::DeErrorHandle> { + map_erased_result( + self.inner + .borrow_mut() + .erased_visit_enum(&mut EnumAccess::from(data)), + ) + } +} + +struct SerdeWasmGuest {} + +impl serde_wasm_guest::SerdeWasmGuest for SerdeWasmGuest {} + +#[cfg(target_pointer_width = "32")] +impl From for serde_wasm_host::Usize { + fn from(size: usize) -> Self { + Self { size: size as _ } + } +} + +#[cfg(not(target_pointer_width = "32"))] +impl From for serde_wasm_host::Usize { + fn from(size: usize) -> Self { + extern "C" { + fn usize_must_be_u32(size: usize) -> !; + } + + unsafe { usize_must_be_u32(size) } + } +} + +impl From for usize { + fn from(size: serde_wasm_host::Usize) -> Self { + size.size as usize + } +} + +pub struct DeError { + inner: serde_wasm_host::DeError, +} + +impl fmt::Debug for DeError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("Error").finish_non_exhaustive() + } +} + +impl fmt::Display for DeError { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + fmt.debug_struct("Error").finish_non_exhaustive() + } +} + +impl std::error::Error for DeError {} + +impl serde::de::Error for DeError { + #[cold] + fn custom(msg: T) -> Self { + Self { + inner: serde_wasm_host::DeError::custom(&msg.to_string()), + } + } + + #[cold] + fn invalid_type(unexp: serde::de::Unexpected, exp: &dyn serde::de::Expected) -> Self { + Self { + inner: serde_wasm_host::DeError::invalid_type(unexp.into(), &exp.to_string()), + } + } + + #[cold] + fn invalid_value(unexp: serde::de::Unexpected, exp: &dyn serde::de::Expected) -> Self { + Self { + inner: serde_wasm_host::DeError::invalid_value(unexp.into(), &exp.to_string()), + } + } + + #[cold] + fn invalid_length(len: usize, exp: &dyn serde::de::Expected) -> Self { + Self { + inner: serde_wasm_host::DeError::invalid_length(len.into(), &exp.to_string()), + } + } + + #[cold] + fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self { + Self { + inner: serde_wasm_host::DeError::unknown_variant(variant, expected), + } + } + + #[cold] + fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self { + Self { + inner: serde_wasm_host::DeError::unknown_field(field, expected), + } + } + + #[cold] + fn missing_field(field: &'static str) -> Self { + Self { + inner: serde_wasm_host::DeError::missing_field(field), + } + } + + #[cold] + fn duplicate_field(field: &'static str) -> Self { + Self { + inner: serde_wasm_host::DeError::duplicate_field(field), + } + } +} + +impl<'a> From> for serde_wasm_host::Unexpected<'a> { + fn from(unexpected: serde::de::Unexpected<'a>) -> Self { + use serde::de::Unexpected::*; + + match unexpected { + Bool(b) => Self::Bool(b), + Unsigned(u) => Self::Unsigned(u), + Signed(s) => Self::Signed(s), + Float(f) => Self::Float(f), + Char(c) => Self::Char(c), + Str(s) => Self::Str(s), + Bytes(b) => Self::Bytes(b), + Unit => Self::Unit, + Option => Self::Option, + NewtypeStruct => Self::NewtypeStruct, + Seq => Self::Seq, + Map => Self::Map, + Enum => Self::Enum, + UnitVariant => Self::UnitVariant, + NewtypeVariant => Self::NewtypeVariant, + TupleVariant => Self::TupleVariant, + StructVariant => Self::StructVariant, + Other(o) => Self::Other(o), + } + } +} + +struct SeqAccess { + inner: serde_wasm_host::SeqAccess, +} + +impl<'de> de::SeqAccess<'de> for SeqAccess { + fn erased_next_element( + &mut self, + d: &mut dyn de::DeserializeSeed<'de>, + ) -> Result, DeError> { + map_bridge_option_result(self.inner.erased_next_element(d.into())) + } + + fn erased_size_hint(&self) -> Option { + self.inner.erased_size_hint().map(Into::into) + } +} + +struct MapAccess { + inner: serde_wasm_host::MapAccess, +} + +impl<'de> de::MapAccess<'de> for MapAccess { + fn erased_next_key( + &mut self, + d: &mut dyn de::DeserializeSeed<'de>, + ) -> Result, DeError> { + map_bridge_option_result(self.inner.erased_next_key(d.into())) + } + + fn erased_next_value( + &mut self, + d: &mut dyn de::DeserializeSeed<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_next_value(d.into())) + } + + fn erased_next_entry( + &mut self, + key: &mut dyn de::DeserializeSeed<'de>, + value: &mut dyn de::DeserializeSeed<'de>, + ) -> Result, DeError> { + map_bridge_option_pair_result(self.inner.erased_next_entry(key.into(), value.into())) + } + + fn erased_size_hint(&self) -> Option { + self.inner.erased_size_hint().map(Into::into) + } +} + +struct EnumAccess { + inner: serde_wasm_host::EnumAccess, +} + +impl<'de> de::EnumAccess<'de> for EnumAccess { + fn erased_variant_seed( + &mut self, + d: &mut dyn de::DeserializeSeed<'de>, + ) -> Result<(de::Out, de::Variant<'de>), DeError> { + let (value, variant) = map_bridge_enum_result(self.inner.erased_variant_seed(d.into()))?; + + let erased_variant = de::Variant { + data: unsafe { any::Any::new(variant) }, + unit_variant: { + unsafe fn unit_variant(a: any::Any) -> Result<(), DeError> { + let variant = a.take::(); + + variant + .inner + .unit_variant() + .map_err(|err| DeError { inner: err }) + } + unit_variant + }, + visit_newtype: { + unsafe fn visit_newtype( + a: any::Any, + seed: &mut dyn de::DeserializeSeed, + ) -> Result { + let variant = a.take::(); + + map_bridge_result(variant.inner.newtype_variant_seed(seed.into())) + } + visit_newtype + }, + tuple_variant: { + unsafe fn tuple_variant( + a: any::Any, + len: usize, + visitor: &mut dyn de::Visitor, + ) -> Result { + let variant = a.take::(); + + map_bridge_result(variant.inner.tuple_variant(len.into(), visitor.into())) + } + tuple_variant + }, + struct_variant: { + unsafe fn struct_variant( + a: any::Any, + fields: &'static [&'static str], + visitor: &mut dyn de::Visitor, + ) -> Result { + let variant = a.take::(); + + map_bridge_result(variant.inner.struct_variant(fields, visitor.into())) + } + struct_variant + }, + }; + + Ok((value, erased_variant)) + } +} + +struct VariantAccess { + inner: serde_wasm_host::VariantAccess, +} + +struct Deserializer { + inner: serde_wasm_host::Deserializer, +} + +impl<'de> de::Deserializer<'de> for Deserializer { + fn erased_deserialize_any(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_any(v.into())) + } + + fn erased_deserialize_bool( + &mut self, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_bool(v.into())) + } + + fn erased_deserialize_u8(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_u8(v.into())) + } + + fn erased_deserialize_u16(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_u16(v.into())) + } + + fn erased_deserialize_u32(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_u32(v.into())) + } + + fn erased_deserialize_u64(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_u64(v.into())) + } + + fn erased_deserialize_i8(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_i8(v.into())) + } + + fn erased_deserialize_i16(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_i16(v.into())) + } + + fn erased_deserialize_i32(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_i32(v.into())) + } + + fn erased_deserialize_i64(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_i64(v.into())) + } + + fn erased_deserialize_i128( + &mut self, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_i128(v.into())) + } + + fn erased_deserialize_u128( + &mut self, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_u128(v.into())) + } + + fn erased_deserialize_f32(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_f32(v.into())) + } + + fn erased_deserialize_f64(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_f64(v.into())) + } + + fn erased_deserialize_char( + &mut self, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_char(v.into())) + } + + fn erased_deserialize_str(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_str(v.into())) + } + + fn erased_deserialize_string( + &mut self, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_string(v.into())) + } + + fn erased_deserialize_bytes( + &mut self, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_bytes(v.into())) + } + + fn erased_deserialize_byte_buf( + &mut self, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_byte_buf(v.into())) + } + + fn erased_deserialize_option( + &mut self, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_option(v.into())) + } + + fn erased_deserialize_unit( + &mut self, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_unit(v.into())) + } + + fn erased_deserialize_unit_struct( + &mut self, + name: &'static str, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_unit_struct(name, v.into())) + } + + fn erased_deserialize_newtype_struct( + &mut self, + name: &'static str, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_newtype_struct(name, v.into())) + } + + fn erased_deserialize_seq(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_seq(v.into())) + } + + fn erased_deserialize_tuple( + &mut self, + len: usize, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_tuple(len.into(), v.into())) + } + + fn erased_deserialize_tuple_struct( + &mut self, + name: &'static str, + len: usize, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result( + self.inner + .erased_deserialize_tuple_struct(name, len.into(), v.into()), + ) + } + + fn erased_deserialize_map(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { + map_bridge_result(self.inner.erased_deserialize_map(v.into())) + } + + fn erased_deserialize_struct( + &mut self, + name: &'static str, + fields: &'static [&'static str], + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_struct(name, fields, v.into())) + } + + fn erased_deserialize_identifier( + &mut self, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_identifier(v.into())) + } + + fn erased_deserialize_enum( + &mut self, + name: &'static str, + variants: &'static [&'static str], + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_enum(name, variants, v.into())) + } + + fn erased_deserialize_ignored_any( + &mut self, + v: &mut dyn de::Visitor<'de>, + ) -> Result { + map_bridge_result(self.inner.erased_deserialize_ignored_any(v.into())) + } + + fn erased_is_human_readable(&self) -> bool { + self.inner.erased_is_human_readable() + } +} diff --git a/necsim/plugins/wasm/src/host.rs b/necsim/plugins/wasm/src/host.rs new file mode 100644 index 000000000..ec96a768a --- /dev/null +++ b/necsim/plugins/wasm/src/host.rs @@ -0,0 +1,450 @@ +wit_bindgen_wasmtime::export!("src/serde-wasm-host.wit"); +wit_bindgen_wasmtime::import!("src/serde-wasm-guest.wit"); + +struct DeValue { + inner: serde_wasm_guest::DeValue, +} + +struct DeserializeSeed { + inner: serde_wasm_guest::DeserializeSeed, +} + +struct Visitor { + inner: serde_wasm_guest::Visitor, +} + +#[derive(Debug)] +struct DeError { + // TODO +} + +#[derive(Debug)] +struct SeqAccess { + // TODO +} + +#[derive(Debug)] +struct MapAccess { + // TODO +} + +#[derive(Debug)] +struct EnumAccess { + // TODO +} + +#[derive(Debug)] +struct VariantAccess { + // TODO +} + +#[derive(Debug)] +struct Deserializer { + // TODO +} + +struct SerdeWasmHost {} + +impl serde_wasm_host::SerdeWasmHost for SerdeWasmHost { + type DeError = DeError; + type Deserializer = Deserializer; + type EnumAccess = EnumAccess; + type MapAccess = MapAccess; + type SeqAccess = SeqAccess; + type VariantAccess = VariantAccess; + + fn de_error_custom(&mut self, msg: &str) -> Self::DeError { + todo!() + } + + fn de_error_invalid_type( + &mut self, + unexp: serde_wasm_host::Unexpected<'_>, + exp: &str, + ) -> Self::DeError { + todo!() + } + + fn de_error_invalid_value( + &mut self, + unexp: serde_wasm_host::Unexpected<'_>, + exp: &str, + ) -> Self::DeError { + todo!() + } + + fn de_error_invalid_length(&mut self, len: serde_wasm_host::Usize, exp: &str) -> Self::DeError { + todo!() + } + + fn de_error_unknown_variant(&mut self, variant: &str, expected: Vec<&str>) -> Self::DeError { + todo!() + } + + fn de_error_unknown_field(&mut self, field: &str, expected: Vec<&str>) -> Self::DeError { + todo!() + } + + fn de_error_missing_field(&mut self, field: &str) -> Self::DeError { + todo!() + } + + fn de_error_duplicate_field(&mut self, field: &str) -> Self::DeError { + todo!() + } + + fn deserializer_erased_deserialize_any( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_bool( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_u8( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_u16( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_u32( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_u64( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_i8( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_i16( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_i32( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_i64( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_i128( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_u128( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_f32( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_f64( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_char( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_str( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_string( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_bytes( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_byte_buf( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_option( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_unit( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_unit_struct( + &mut self, + self_: &Self::Deserializer, + name: &str, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_newtype_struct( + &mut self, + self_: &Self::Deserializer, + name: &str, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_seq( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_tuple( + &mut self, + self_: &Self::Deserializer, + len: serde_wasm_host::Usize, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_tuple_struct( + &mut self, + self_: &Self::Deserializer, + name: &str, + len: serde_wasm_host::Usize, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_map( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_struct( + &mut self, + self_: &Self::Deserializer, + name: &str, + fields: Vec<&str>, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_identifier( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_enum( + &mut self, + self_: &Self::Deserializer, + name: &str, + variants: Vec<&str>, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_deserialize_ignored_any( + &mut self, + self_: &Self::Deserializer, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn deserializer_erased_is_human_readable(&mut self, self_: &Self::Deserializer) -> bool { + todo!() + } + + fn seq_access_erased_next_element( + &mut self, + self_: &Self::SeqAccess, + seed: serde_wasm_host::DeserializeSeedHandle, + ) -> Result, Self::DeError> { + todo!() + } + + fn seq_access_erased_size_hint( + &mut self, + self_: &Self::SeqAccess, + ) -> Option { + todo!() + } + + fn map_access_erased_next_key( + &mut self, + self_: &Self::MapAccess, + seed: serde_wasm_host::DeserializeSeedHandle, + ) -> Result, Self::DeError> { + todo!() + } + + fn map_access_erased_next_value( + &mut self, + self_: &Self::MapAccess, + seed: serde_wasm_host::DeserializeSeedHandle, + ) -> Result { + todo!() + } + + fn map_access_erased_next_entry( + &mut self, + self_: &Self::MapAccess, + kseed: serde_wasm_host::DeserializeSeedHandle, + vseed: serde_wasm_host::DeserializeSeedHandle, + ) -> Result< + Option<( + serde_wasm_host::DeValueHandle, + serde_wasm_host::DeValueHandle, + )>, + Self::DeError, + > { + todo!() + } + + fn map_access_erased_size_hint( + &mut self, + self_: &Self::MapAccess, + ) -> Option { + todo!() + } + + fn enum_access_erased_variant_seed( + &mut self, + self_: &Self::EnumAccess, + seed: serde_wasm_host::DeserializeSeedHandle, + ) -> Result<(serde_wasm_host::DeValueHandle, Self::VariantAccess), Self::DeError> { + todo!() + } + + fn variant_access_unit_variant( + &mut self, + self_: &Self::VariantAccess, + ) -> Result<(), Self::DeError> { + todo!() + } + + fn variant_access_newtype_variant_seed( + &mut self, + self_: &Self::VariantAccess, + seed: serde_wasm_host::DeserializeSeedHandle, + ) -> Result { + todo!() + } + + fn variant_access_tuple_variant( + &mut self, + self_: &Self::VariantAccess, + len: serde_wasm_host::Usize, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } + + fn variant_access_struct_variant( + &mut self, + self_: &Self::VariantAccess, + fields: Vec<&str>, + visitor: serde_wasm_host::VisitorHandle, + ) -> Result { + todo!() + } +} diff --git a/necsim/plugins/wasm/src/lib.rs b/necsim/plugins/wasm/src/lib.rs index ba46c4f6a..4805b9565 100644 --- a/necsim/plugins/wasm/src/lib.rs +++ b/necsim/plugins/wasm/src/lib.rs @@ -1,849 +1,6 @@ -use std::{ - cell::RefCell, - fmt::{self, Write}, -}; - mod any; mod de; mod error; +mod guest; +mod host; mod map; - -wit_bindgen_rust::import!("src/serde-wasm-host.wit"); -wit_bindgen_rust::export!("src/serde-wasm-guest.wit"); - -#[doc(hidden)] -pub struct DeValue { - inner: RefCell>, -} - -#[doc(hidden)] -pub struct DeserializeSeed { - inner: RefCell<&'static mut dyn de::DeserializeSeed<'static>>, -} - -impl serde_wasm_guest::DeserializeSeed for DeserializeSeed { - fn erased_deserialize( - &self, - deserializer: serde_wasm_guest::DeserializerHandle, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result( - self.inner - .borrow_mut() - .erased_deserialize_seed(&mut Deserializer::from(deserializer)), - ) - } -} - -#[doc(hidden)] -pub struct Visitor { - inner: RefCell<&'static mut dyn de::Visitor<'static>>, -} - -fn map_erased_result( - result: Result, -) -> Result, serde_wasm_guest::DeErrorHandle> { - match result { - Ok(out) => Ok(wit_bindgen_rust::Handle::new(DeValue { - inner: RefCell::new(Some(out)), - })), - Err(err) => Err(err.into()), - } -} - -fn map_bridge_result( - result: Result, -) -> Result { - match result { - Ok(handle) => { - let handle: wit_bindgen_rust::Handle = - unsafe { wit_bindgen_rust::Handle::from_raw(handle.handle) }; - let out = handle.inner.borrow_mut().take().unwrap(); - Ok(out) - }, - Err(err) => Err(Error { inner: err }), - } -} - -fn map_bridge_option_result( - result: Result, serde_wasm_host::DeError>, -) -> Result, Error> { - match result { - Ok(Some(handle)) => { - let handle: wit_bindgen_rust::Handle = - unsafe { wit_bindgen_rust::Handle::from_raw(handle.handle) }; - let out = handle.inner.borrow_mut().take().unwrap(); - Ok(Some(out)) - }, - Ok(None) => Ok(None), - Err(err) => Err(Error { inner: err }), - } -} - -fn map_bridge_option_pair_result( - result: Result< - Option<( - serde_wasm_host::DeValueHandle, - serde_wasm_host::DeValueHandle, - )>, - serde_wasm_host::DeError, - >, -) -> Result, Error> { - match result { - Ok(Some((handle_a, handle_b))) => { - let handle_a: wit_bindgen_rust::Handle = - unsafe { wit_bindgen_rust::Handle::from_raw(handle_a.handle) }; - let out_a = handle_a.inner.borrow_mut().take().unwrap(); - - let handle_b: wit_bindgen_rust::Handle = - unsafe { wit_bindgen_rust::Handle::from_raw(handle_b.handle) }; - let out_b = handle_b.inner.borrow_mut().take().unwrap(); - - Ok(Some((out_a, out_b))) - }, - Ok(None) => Ok(None), - Err(err) => Err(Error { inner: err }), - } -} - -fn map_bridge_enum_result( - result: Result< - ( - serde_wasm_host::DeValueHandle, - serde_wasm_host::VariantAccess, - ), - serde_wasm_host::DeError, - >, -) -> Result<(de::Out, VariantAccess), Error> { - match result { - Ok((handle, variant)) => { - let handle: wit_bindgen_rust::Handle = - unsafe { wit_bindgen_rust::Handle::from_raw(handle.handle) }; - let out = handle.inner.borrow_mut().take().unwrap(); - - let variant = VariantAccess { inner: variant }; - - Ok((out, variant)) - }, - Err(err) => Err(Error { inner: err }), - } -} - -impl From for serde_wasm_guest::DeErrorHandle { - fn from(err: Error) -> Self { - Self { - handle: err.inner.into_raw(), - } - } -} - -impl From for Deserializer { - fn from(deserializer: serde_wasm_guest::DeserializerHandle) -> Self { - Self { - inner: unsafe { serde_wasm_host::Deserializer::from_raw(deserializer.handle) }, - } - } -} - -impl From for SeqAccess { - fn from(seq: serde_wasm_guest::SeqAccessHandle) -> Self { - Self { - inner: unsafe { serde_wasm_host::SeqAccess::from_raw(seq.handle) }, - } - } -} - -impl From for MapAccess { - fn from(map: serde_wasm_guest::MapAccessHandle) -> Self { - Self { - inner: unsafe { serde_wasm_host::MapAccess::from_raw(map.handle) }, - } - } -} - -impl From for EnumAccess { - fn from(r#enum: serde_wasm_guest::EnumAccessHandle) -> Self { - Self { - inner: unsafe { serde_wasm_host::EnumAccess::from_raw(r#enum.handle) }, - } - } -} - -impl<'a, 'de> From<&'a mut dyn de::Visitor<'de>> for serde_wasm_host::VisitorHandle { - fn from(visitor: &'a mut dyn de::Visitor<'de>) -> Self { - let visitor: &'static mut dyn de::Visitor<'static> = - unsafe { std::mem::transmute(visitor) }; - let visitor = Visitor { - inner: RefCell::new(visitor), - }; - - let handle = wit_bindgen_rust::Handle::new(visitor); - - Self { - handle: wit_bindgen_rust::Handle::into_raw(handle), - } - } -} - -impl<'a, 'de> From<&'a mut dyn de::DeserializeSeed<'de>> - for serde_wasm_host::DeserializeSeedHandle -{ - fn from(deserialize_seed: &'a mut dyn de::DeserializeSeed<'de>) -> Self { - let deserialize_seed: &'static mut dyn de::DeserializeSeed<'static> = - unsafe { std::mem::transmute(deserialize_seed) }; - let deserialize_seed = DeserializeSeed { - inner: RefCell::new(deserialize_seed), - }; - - let handle = wit_bindgen_rust::Handle::new(deserialize_seed); - - Self { - handle: wit_bindgen_rust::Handle::into_raw(handle), - } - } -} - -impl serde_wasm_guest::Visitor for Visitor { - fn erased_expecting(&self) -> Option { - struct Expecting<'a>(&'a Visitor); - - impl<'a> fmt::Display for Expecting<'a> { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - self.0.inner.borrow().erased_expecting(fmt) - } - } - - let mut buffer = String::new(); - - match buffer.write_fmt(format_args!("{}", Expecting(self))) { - Ok(()) => Some(buffer), - Err(_) => None, - } - } - - fn erased_visit_bool( - &self, - v: bool, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_bool(v)) - } - - fn erased_visit_i8( - &self, - v: i8, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_i8(v)) - } - - fn erased_visit_i16( - &self, - v: i16, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_i16(v)) - } - - fn erased_visit_i32( - &self, - v: i32, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_i32(v)) - } - - fn erased_visit_i64( - &self, - v: i64, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_i64(v)) - } - - fn erased_visit_i128( - &self, - v: serde_wasm_guest::I128, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - let v = unsafe { - std::mem::transmute::((u128::from(v.hi) << 64) | u128::from(v.lo)) - }; - - map_erased_result(self.inner.borrow_mut().erased_visit_i128(v)) - } - - fn erased_visit_u8( - &self, - v: u8, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_u8(v)) - } - - fn erased_visit_u16( - &self, - v: u16, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_u16(v)) - } - - fn erased_visit_u32( - &self, - v: u32, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_u32(v)) - } - - fn erased_visit_u64( - &self, - v: u64, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_u64(v)) - } - - fn erased_visit_u128( - &self, - v: serde_wasm_guest::U128, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - let v = (u128::from(v.hi) << 64) | u128::from(v.lo); - - map_erased_result(self.inner.borrow_mut().erased_visit_u128(v)) - } - - fn erased_visit_f32( - &self, - v: f32, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_f32(v)) - } - - fn erased_visit_f64( - &self, - v: f64, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_f64(v)) - } - - fn erased_visit_char( - &self, - v: char, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_char(v)) - } - - fn erased_visit_str( - &self, - v: String, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_str(&v)) - } - - fn erased_visit_string( - &self, - v: String, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_string(v)) - } - - fn erased_visit_bytes( - &self, - v: Vec, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_bytes(&v)) - } - - fn erased_visit_byte_buf( - &self, - v: Vec, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_byte_buf(v)) - } - - fn erased_visit_none( - &self, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_none()) - } - - fn erased_visit_some( - &self, - deserializer: serde_wasm_guest::DeserializerHandle, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result( - self.inner - .borrow_mut() - .erased_visit_some(&mut Deserializer::from(deserializer)), - ) - } - - fn erased_visit_unit( - &self, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result(self.inner.borrow_mut().erased_visit_unit()) - } - - fn erased_visit_newtype_struct( - &self, - deserializer: serde_wasm_guest::DeserializerHandle, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result( - self.inner - .borrow_mut() - .erased_visit_newtype_struct(&mut Deserializer::from(deserializer)), - ) - } - - fn erased_visit_seq( - &self, - seq: serde_wasm_guest::SeqAccessHandle, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result( - self.inner - .borrow_mut() - .erased_visit_seq(&mut SeqAccess::from(seq)), - ) - } - - fn erased_visit_map( - &self, - map: serde_wasm_guest::MapAccessHandle, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result( - self.inner - .borrow_mut() - .erased_visit_map(&mut MapAccess::from(map)), - ) - } - - fn erased_visit_enum( - &self, - data: serde_wasm_guest::EnumAccessHandle, - ) -> Result, serde_wasm_guest::DeErrorHandle> { - map_erased_result( - self.inner - .borrow_mut() - .erased_visit_enum(&mut EnumAccess::from(data)), - ) - } -} - -struct SerdeWasmGuest {} - -impl serde_wasm_guest::SerdeWasmGuest for SerdeWasmGuest {} - -#[cfg(target_pointer_width = "32")] -impl From for serde_wasm_host::Usize { - fn from(size: usize) -> Self { - Self { size: size as _ } - } -} - -#[cfg(not(target_pointer_width = "32"))] -impl From for serde_wasm_host::Usize { - fn from(size: usize) -> Self { - extern "C" { - fn usize_must_be_u32(size: usize) -> !; - } - - unsafe { usize_must_be_u32(size) } - } -} - -impl From for usize { - fn from(size: serde_wasm_host::Usize) -> Self { - size.size as usize - } -} - -pub struct Error { - inner: serde_wasm_host::DeError, -} - -impl fmt::Debug for Error { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.debug_struct("Error").finish_non_exhaustive() - } -} - -impl fmt::Display for Error { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - fmt.debug_struct("Error").finish_non_exhaustive() - } -} - -impl std::error::Error for Error {} - -impl serde::de::Error for Error { - #[cold] - fn custom(msg: T) -> Self { - Self { - inner: serde_wasm_host::DeError::custom(&msg.to_string()), - } - } - - #[cold] - fn invalid_type(unexp: serde::de::Unexpected, exp: &dyn serde::de::Expected) -> Self { - Self { - inner: serde_wasm_host::DeError::invalid_type(unexp.into(), &exp.to_string()), - } - } - - #[cold] - fn invalid_value(unexp: serde::de::Unexpected, exp: &dyn serde::de::Expected) -> Self { - Self { - inner: serde_wasm_host::DeError::invalid_value(unexp.into(), &exp.to_string()), - } - } - - #[cold] - fn invalid_length(len: usize, exp: &dyn serde::de::Expected) -> Self { - Self { - inner: serde_wasm_host::DeError::invalid_length(len.into(), &exp.to_string()), - } - } - - #[cold] - fn unknown_variant(variant: &str, expected: &'static [&'static str]) -> Self { - Self { - inner: serde_wasm_host::DeError::unknown_variant(variant, expected), - } - } - - #[cold] - fn unknown_field(field: &str, expected: &'static [&'static str]) -> Self { - Self { - inner: serde_wasm_host::DeError::unknown_field(field, expected), - } - } - - #[cold] - fn missing_field(field: &'static str) -> Self { - Self { - inner: serde_wasm_host::DeError::missing_field(field), - } - } - - #[cold] - fn duplicate_field(field: &'static str) -> Self { - Self { - inner: serde_wasm_host::DeError::duplicate_field(field), - } - } -} - -impl<'a> From> for serde_wasm_host::Unexpected<'a> { - fn from(unexpected: serde::de::Unexpected<'a>) -> Self { - use serde::de::Unexpected::*; - - match unexpected { - Bool(b) => Self::Bool(b), - Unsigned(u) => Self::Unsigned(u), - Signed(s) => Self::Signed(s), - Float(f) => Self::Float(f), - Char(c) => Self::Char(c), - Str(s) => Self::Str(s), - Bytes(b) => Self::Bytes(b), - Unit => Self::Unit, - Option => Self::Option, - NewtypeStruct => Self::NewtypeStruct, - Seq => Self::Seq, - Map => Self::Map, - Enum => Self::Enum, - UnitVariant => Self::UnitVariant, - NewtypeVariant => Self::NewtypeVariant, - TupleVariant => Self::TupleVariant, - StructVariant => Self::StructVariant, - Other(o) => Self::Other(o), - } - } -} - -struct SeqAccess { - inner: serde_wasm_host::SeqAccess, -} - -impl<'de> de::SeqAccess<'de> for SeqAccess { - fn erased_next_element( - &mut self, - d: &mut dyn de::DeserializeSeed<'de>, - ) -> Result, Error> { - map_bridge_option_result(self.inner.erased_next_element(d.into())) - } - - fn erased_size_hint(&self) -> Option { - self.inner.erased_size_hint().map(Into::into) - } -} - -struct MapAccess { - inner: serde_wasm_host::MapAccess, -} - -impl<'de> de::MapAccess<'de> for MapAccess { - fn erased_next_key( - &mut self, - d: &mut dyn de::DeserializeSeed<'de>, - ) -> Result, Error> { - map_bridge_option_result(self.inner.erased_next_key(d.into())) - } - - fn erased_next_value( - &mut self, - d: &mut dyn de::DeserializeSeed<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_next_value(d.into())) - } - - fn erased_next_entry( - &mut self, - key: &mut dyn de::DeserializeSeed<'de>, - value: &mut dyn de::DeserializeSeed<'de>, - ) -> Result, Error> { - map_bridge_option_pair_result(self.inner.erased_next_entry(key.into(), value.into())) - } - - fn erased_size_hint(&self) -> Option { - self.inner.erased_size_hint().map(Into::into) - } -} - -struct EnumAccess { - inner: serde_wasm_host::EnumAccess, -} - -impl<'de> de::EnumAccess<'de> for EnumAccess { - fn erased_variant_seed( - &mut self, - d: &mut dyn de::DeserializeSeed<'de>, - ) -> Result<(de::Out, de::Variant<'de>), Error> { - let (value, variant) = map_bridge_enum_result(self.inner.erased_variant_seed(d.into()))?; - - let erased_variant = de::Variant { - data: unsafe { any::Any::new(variant) }, - unit_variant: { - unsafe fn unit_variant(a: any::Any) -> Result<(), Error> { - let variant = a.take::(); - - variant - .inner - .unit_variant() - .map_err(|err| Error { inner: err }) - } - unit_variant - }, - visit_newtype: { - unsafe fn visit_newtype( - a: any::Any, - seed: &mut dyn de::DeserializeSeed, - ) -> Result { - let variant = a.take::(); - - map_bridge_result(variant.inner.newtype_variant_seed(seed.into())) - } - visit_newtype - }, - tuple_variant: { - unsafe fn tuple_variant( - a: any::Any, - len: usize, - visitor: &mut dyn de::Visitor, - ) -> Result { - let variant = a.take::(); - - map_bridge_result(variant.inner.tuple_variant(len.into(), visitor.into())) - } - tuple_variant - }, - struct_variant: { - unsafe fn struct_variant( - a: any::Any, - fields: &'static [&'static str], - visitor: &mut dyn de::Visitor, - ) -> Result { - let variant = a.take::(); - - map_bridge_result(variant.inner.struct_variant(fields, visitor.into())) - } - struct_variant - }, - }; - - Ok((value, erased_variant)) - } -} - -struct VariantAccess { - inner: serde_wasm_host::VariantAccess, -} - -struct Deserializer { - inner: serde_wasm_host::Deserializer, -} - -impl<'de> de::Deserializer<'de> for Deserializer { - fn erased_deserialize_any(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_any(v.into())) - } - - fn erased_deserialize_bool(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_bool(v.into())) - } - - fn erased_deserialize_u8(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_u8(v.into())) - } - - fn erased_deserialize_u16(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_u16(v.into())) - } - - fn erased_deserialize_u32(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_u32(v.into())) - } - - fn erased_deserialize_u64(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_u64(v.into())) - } - - fn erased_deserialize_i8(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_i8(v.into())) - } - - fn erased_deserialize_i16(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_i16(v.into())) - } - - fn erased_deserialize_i32(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_i32(v.into())) - } - - fn erased_deserialize_i64(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_i64(v.into())) - } - - fn erased_deserialize_i128(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_i128(v.into())) - } - - fn erased_deserialize_u128(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_u128(v.into())) - } - - fn erased_deserialize_f32(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_f32(v.into())) - } - - fn erased_deserialize_f64(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_f64(v.into())) - } - - fn erased_deserialize_char(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_char(v.into())) - } - - fn erased_deserialize_str(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_str(v.into())) - } - - fn erased_deserialize_string( - &mut self, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_string(v.into())) - } - - fn erased_deserialize_bytes(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_bytes(v.into())) - } - - fn erased_deserialize_byte_buf( - &mut self, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_byte_buf(v.into())) - } - - fn erased_deserialize_option( - &mut self, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_option(v.into())) - } - - fn erased_deserialize_unit(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_unit(v.into())) - } - - fn erased_deserialize_unit_struct( - &mut self, - name: &'static str, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_unit_struct(name, v.into())) - } - - fn erased_deserialize_newtype_struct( - &mut self, - name: &'static str, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_newtype_struct(name, v.into())) - } - - fn erased_deserialize_seq(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_seq(v.into())) - } - - fn erased_deserialize_tuple( - &mut self, - len: usize, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_tuple(len.into(), v.into())) - } - - fn erased_deserialize_tuple_struct( - &mut self, - name: &'static str, - len: usize, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result( - self.inner - .erased_deserialize_tuple_struct(name, len.into(), v.into()), - ) - } - - fn erased_deserialize_map(&mut self, v: &mut dyn de::Visitor<'de>) -> Result { - map_bridge_result(self.inner.erased_deserialize_map(v.into())) - } - - fn erased_deserialize_struct( - &mut self, - name: &'static str, - fields: &'static [&'static str], - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_struct(name, fields, v.into())) - } - - fn erased_deserialize_identifier( - &mut self, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_identifier(v.into())) - } - - fn erased_deserialize_enum( - &mut self, - name: &'static str, - variants: &'static [&'static str], - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_enum(name, variants, v.into())) - } - - fn erased_deserialize_ignored_any( - &mut self, - v: &mut dyn de::Visitor<'de>, - ) -> Result { - map_bridge_result(self.inner.erased_deserialize_ignored_any(v.into())) - } - - fn erased_is_human_readable(&self) -> bool { - self.inner.erased_is_human_readable() - } -}