diff --git a/Cargo.lock b/Cargo.lock index e3596972..a18e08ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,6 +28,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + [[package]] name = "anyhow" version = "1.0.66" @@ -36,9 +45,9 @@ checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" [[package]] name = "async-trait" -version = "0.1.58" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" +checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364" dependencies = [ "proc-macro2", "quote", @@ -53,9 +62,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "backtrace" -version = "0.3.63" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" dependencies = [ "addr2line", "cc", @@ -80,9 +89,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bumpalo" -version = "3.8.0" +version = "3.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" [[package]] name = "bytecheck" @@ -113,15 +122,15 @@ checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" [[package]] name = "bytes" -version = "1.2.1" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" [[package]] name = "cc" -version = "1.0.72" +version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" [[package]] name = "cfg-if" @@ -137,10 +146,11 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.20" +version = "0.4.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6127248204b9aba09a362f6c930ef6a78f2c1b2215f8a7b398c06e1083f17af0" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" dependencies = [ + "iana-time-zone", "js-sys", "num-integer", "num-traits", @@ -148,12 +158,28 @@ dependencies = [ "winapi", ] +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + [[package]] name = "const_fn" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + [[package]] name = "corosensei" version = "0.1.3" @@ -167,11 +193,55 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "cxx" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a41a86530d0fe7f5d9ea779916b7cadd2d4f9add748b99c2c029cbbdfaf453" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06416d667ff3e3ad2df1cd8cd8afae5da26cf9cec4d0825040f88b5ca659a2f0" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "820a9a2af1669deeef27cb271f476ffd196a2c4b6731336011e0ba63e2c7cf71" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.82" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a08a6e2fcc370a089ad3b4aaf54db3b1b4cee38ddabce5896b33eb693275f470" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "darling" -version = "0.13.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "757c0ded2af11d8e739c4daea1ac623dd1624b06c844cf3f5a39f1bdbd99bb12" +checksum = "b0dd3cd20dc6b5a876612a6e5accfe7f3dd883db6d07acfbf14c128f61550dfa" dependencies = [ "darling_core", "darling_macro", @@ -179,23 +249,22 @@ dependencies = [ [[package]] name = "darling_core" -version = "0.13.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c34d8efb62d0c2d7f60ece80f75e5c63c1588ba68032740494b0b9a996466e3" +checksum = "a784d2ccaf7c98501746bf0be29b2022ba41fd62a2e622af997a03e9f972859f" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", - "strsim", "syn", ] [[package]] name = "darling_macro" -version = "0.13.0" +version = "0.14.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ade7bff147130fe5e6d39f089c6bd49ec0250f35d70b2eebf72afdfc919f15cc" +checksum = "7618812407e9402654622dd402b0a89dff9ba93badd6540781526117b92aab7e" dependencies = [ "darling_core", "quote", @@ -241,18 +310,18 @@ dependencies = [ [[package]] name = "enumset" -version = "1.0.8" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6216d2c19a6fb5f29d1ada1dc7bc4367a8cbf0fa4af5cf12e07b5bbdde6b5b2c" +checksum = "19be8061a06ab6f3a6cf21106c873578bf01bd42ad15e0311a9c76161cb1c753" dependencies = [ "enumset_derive", ] [[package]] name = "enumset_derive" -version = "0.5.5" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6451128aa6655d880755345d085494cf7561a6bee7c8dc821e5d77e6d267ecd4" +checksum = "03e7b551eba279bf0fa88b83a46330168c1560a52a94f5126f892f0b364ab3e0" dependencies = [ "darling", "proc-macro2", @@ -277,9 +346,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -290,15 +359,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.26.1" +version = "0.26.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" - -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" [[package]] name = "hashbrown" @@ -318,6 +381,30 @@ dependencies = [ "unicode-segmentation", ] +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + [[package]] name = "id-arena" version = "2.2.1" @@ -332,25 +419,25 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "indexmap" -version = "1.7.0" +version = "1.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown 0.11.2", + "hashbrown", ] [[package]] name = "itoa" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" [[package]] name = "js-sys" -version = "0.3.55" +version = "0.3.60" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" dependencies = [ "wasm-bindgen", ] @@ -369,15 +456,24 @@ checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" [[package]] name = "libc" -version = "0.2.132" +version = "0.2.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" + +[[package]] +name = "link-cplusplus" +version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8371e4e5341c3a96db127eb2465ac681ced4c433e01dd0e938adbef26ba93ba5" +checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +dependencies = [ + "cc", +] [[package]] name = "log" -version = "0.4.14" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if 1.0.0", ] @@ -393,43 +489,42 @@ dependencies = [ [[package]] name = "memchr" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memmap2" -version = "0.5.0" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4647a11b578fead29cdbb34d4adef8dd3dc35b876c9c6d5240d83f205abfe96e" +checksum = "4b182332558b18d807c4ce1ca8ca983b34c3ee32765e47b3f0f69b90355cc1dc" dependencies = [ "libc", ] [[package]] name = "memoffset" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59accc507f1338036a0477ef61afdae33cde60840f4dfe481319ce3ad116ddf9" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ "autocfg", ] [[package]] name = "miniz_oxide" -version = "0.4.4" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" +checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" dependencies = [ "adler", - "autocfg", ] [[package]] name = "more-asserts" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" +checksum = "7843ec2de400bcbc6a6328c958dc38e5359da6e93e72e37bc5246bf1ae776389" [[package]] name = "num-integer" @@ -452,9 +547,9 @@ dependencies = [ [[package]] name = "object" -version = "0.27.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ "memchr", ] @@ -467,9 +562,9 @@ checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" [[package]] name = "pin-project-lite" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "proc-macro-error" @@ -543,9 +638,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.10" +version = "1.0.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" dependencies = [ "proc-macro2", ] @@ -578,7 +673,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cec2b3485b07d96ddfd3134767b8a447b45ea4eb91448d0a35180ec0ffd5ed15" dependencies = [ "bytecheck", - "hashbrown 0.12.3", + "hashbrown", "indexmap", "ptr_meta", "rend", @@ -624,6 +719,12 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "scratch" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" + [[package]] name = "seahash" version = "4.1.0" @@ -647,9 +748,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.144" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f747710de3dcd43b88c9168773254e809d8ddbdf9653b84e2554ab219f17860" +checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" dependencies = [ "serde_derive", ] @@ -667,9 +768,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.144" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94ed3a816fb1d101812f83e789f888322c34e291f894f19590dc310963e87a00" +checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c" dependencies = [ "proc-macro2", "quote", @@ -678,9 +779,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.85" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e55a28e3aaef9d5ce0506d0a14dbba8054ddc7e499ef522dd8b26859ec9d4a44" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" dependencies = [ "itoa", "ryu", @@ -704,15 +805,18 @@ checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" [[package]] name = "slab" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] [[package]] name = "smallvec" -version = "1.7.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ecab6c735a6bb4139c0caafd0cc3635748bbb3acf4550e8138122099251f309" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" [[package]] name = "standback" @@ -772,17 +876,11 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" -[[package]] -name = "strsim" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" - [[package]] name = "syn" -version = "1.0.103" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +checksum = "4ae548ec36cf198c0ef7710d3c230987c2d6d7bd98ad6edc0274462724c585ce" dependencies = [ "proc-macro2", "quote", @@ -791,24 +889,33 @@ dependencies = [ [[package]] name = "target-lexicon" -version = "0.12.2" +version = "0.12.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9bffcddbc2458fa3e6058414599e3c838a022abae82e5c67b4f7f80298d5bff" +checksum = "9410d0f6853b1d94f0e519fb95df60f29d2c1eff2d921ffdf01a4c8a3b54f12d" + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] [[package]] name = "thiserror" -version = "1.0.30" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.30" +version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" dependencies = [ "proc-macro2", "quote", @@ -870,9 +977,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tracing" -version = "0.1.29" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" dependencies = [ "cfg-if 1.0.0", "pin-project-lite", @@ -882,9 +989,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.18" +version = "0.1.23" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", @@ -893,11 +1000,11 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.21" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] @@ -930,6 +1037,12 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + [[package]] name = "unicode-xid" version = "0.2.4" @@ -938,15 +1051,15 @@ checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] name = "version_check" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" @@ -1273,6 +1386,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" diff --git a/pkg/wasmer_wasi_js.d.ts b/pkg/wasmer_wasi_js.d.ts index 596224c0..80da68f6 100644 --- a/pkg/wasmer_wasi_js.d.ts +++ b/pkg/wasmer_wasi_js.d.ts @@ -1,5 +1,14 @@ /* tslint:disable */ /* eslint-disable */ + +interface WasiConfig { + readonly args?: string[], + readonly env?: Record, + readonly preopens?: Record, + readonly fs?: any, +} + + /** */ export class JSVirtualFile { @@ -102,9 +111,9 @@ export class MemFS { export class WASI { free(): void; /** -* @param {any} config +* @param {WasiConfig} config */ - constructor(config: any); + constructor(config: WasiConfig); /** * @param {WebAssembly.Module} module * @returns {object} diff --git a/pkg/wasmer_wasi_js.js b/pkg/wasmer_wasi_js.js index 0a95cd9c..6bd253df 100644 --- a/pkg/wasmer_wasi_js.js +++ b/pkg/wasmer_wasi_js.js @@ -18,6 +18,23 @@ function addHeapObject(obj) { return idx; } +const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +let cachedUint8Memory0 = new Uint8Array(); + +function getUint8Memory0() { + if (cachedUint8Memory0.byteLength === 0) { + cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8Memory0; +} + +function getStringFromWasm0(ptr, len) { + return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); +} + function dropObject(idx) { if (idx < 36) return; heap[idx] = heap_next; @@ -32,15 +49,6 @@ function takeObject(idx) { let WASM_VECTOR_LEN = 0; -let cachedUint8Memory0 = new Uint8Array(); - -function getUint8Memory0() { - if (cachedUint8Memory0.byteLength === 0) { - cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); - } - return cachedUint8Memory0; -} - const cachedTextEncoder = new TextEncoder('utf-8'); const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' @@ -172,14 +180,6 @@ function debugString(val) { return className; } -const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); -} - let cachedFloat64Memory0 = new Float64Array(); function getFloat64Memory0() { @@ -617,7 +617,7 @@ export class WASI { wasm.__wbg_wasi_free(ptr); } /** - * @param {any} config + * @param {WasiConfig} config */ constructor(config) { try { @@ -911,15 +911,19 @@ function getImports() { const ret = getObject(arg0); return addHeapObject(ret); }; - imports.wbg.__wbg_process_8b43dabeb90bfc71 = function(arg0) { + imports.wbg.__wbg_crypto_e1d53a1d73fb10b8 = function(arg0) { + const ret = getObject(arg0).crypto; + return addHeapObject(ret); + }; + imports.wbg.__wbg_process_038c26bf42b093f8 = function(arg0) { const ret = getObject(arg0).process; return addHeapObject(ret); }; - imports.wbg.__wbg_versions_1a19949b2d6cda48 = function(arg0) { + imports.wbg.__wbg_versions_ab37218d2f0b24a8 = function(arg0) { const ret = getObject(arg0).versions; return addHeapObject(ret); }; - imports.wbg.__wbg_node_f0b47c5c972bf347 = function(arg0) { + imports.wbg.__wbg_node_080f4b19d15bc1fe = function(arg0) { const ret = getObject(arg0).node; return addHeapObject(ret); }; @@ -927,19 +931,27 @@ function getImports() { const ret = typeof(getObject(arg0)) === 'string'; return ret; }; - imports.wbg.__wbg_modulerequire_7f44ca52d65c8fc0 = function() { return handleError(function (arg0, arg1) { - const ret = module.require(getStringFromWasm0(arg0, arg1)); + imports.wbg.__wbg_require_78a3dcfbdba9cbce = function() { return handleError(function () { + const ret = module.require; return addHeapObject(ret); }, arguments) }; - imports.wbg.__wbg_crypto_f92d087c37fffbbf = function(arg0) { - const ret = getObject(arg0).crypto; + imports.wbg.__wbindgen_is_function = function(arg0) { + const ret = typeof(getObject(arg0)) === 'function'; + return ret; + }; + imports.wbg.__wbindgen_string_new = function(arg0, arg1) { + const ret = getStringFromWasm0(arg0, arg1); return addHeapObject(ret); }; - imports.wbg.__wbg_msCrypto_74b0ea9c42a7c831 = function(arg0) { + imports.wbg.__wbg_call_168da88779e35f61 = function() { return handleError(function (arg0, arg1, arg2) { + const ret = getObject(arg0).call(getObject(arg1), getObject(arg2)); + return addHeapObject(ret); + }, arguments) }; + imports.wbg.__wbg_msCrypto_6e7d3e1f92610cbb = function(arg0) { const ret = getObject(arg0).msCrypto; return addHeapObject(ret); }; - imports.wbg.__wbg_newwithlength_4928c68e52c56b6d = function(arg0) { + imports.wbg.__wbg_newwithlength_f5933855e4f48a19 = function(arg0) { const ret = new Uint8Array(arg0 >>> 0); return addHeapObject(ret); }; @@ -948,23 +960,23 @@ function getImports() { const ret = typeof(val) === 'object' && val !== null; return ret; }; - imports.wbg.__wbg_get_1d33f276d45710a4 = function(arg0, arg1) { + imports.wbg.__wbg_get_57245cc7d7c7619d = function(arg0, arg1) { const ret = getObject(arg0)[arg1 >>> 0]; return addHeapObject(ret); }; - imports.wbg.__wbg_self_cc4cded4a07ffe11 = function() { return handleError(function () { + imports.wbg.__wbg_self_6d479506f72c6a71 = function() { return handleError(function () { const ret = self.self; return addHeapObject(ret); }, arguments) }; - imports.wbg.__wbg_window_f8bf2008679bec7e = function() { return handleError(function () { + imports.wbg.__wbg_window_f2557cc78490aceb = function() { return handleError(function () { const ret = window.window; return addHeapObject(ret); }, arguments) }; - imports.wbg.__wbg_globalThis_f1bf7c3c3068b5c3 = function() { return handleError(function () { + imports.wbg.__wbg_globalThis_7f206bda628d5286 = function() { return handleError(function () { const ret = globalThis.globalThis; return addHeapObject(ret); }, arguments) }; - imports.wbg.__wbg_global_2b562fbb2af1aec3 = function() { return handleError(function () { + imports.wbg.__wbg_global_ba75c50d1cf384f4 = function() { return handleError(function () { const ret = global.global; return addHeapObject(ret); }, arguments) }; @@ -972,15 +984,15 @@ function getImports() { const ret = getObject(arg0) === undefined; return ret; }; - imports.wbg.__wbg_newnoargs_111ac35ca85f61f5 = function(arg0, arg1) { + imports.wbg.__wbg_newnoargs_b5b063fc6c2f0376 = function(arg0, arg1) { const ret = new Function(getStringFromWasm0(arg0, arg1)); return addHeapObject(ret); }; - imports.wbg.__wbg_call_2dad239b57d80b42 = function() { return handleError(function (arg0, arg1) { + imports.wbg.__wbg_call_97ae9d8645dc388b = function() { return handleError(function (arg0, arg1) { const ret = getObject(arg0).call(getObject(arg1)); return addHeapObject(ret); }, arguments) }; - imports.wbg.__wbg_instanceof_Function_07f0fd0979b11789 = function(arg0) { + imports.wbg.__wbg_instanceof_Function_056d5b3aef8aaa85 = function(arg0) { let result; try { result = getObject(arg0) instanceof Function; @@ -994,22 +1006,22 @@ function getImports() { const ret = wasm.memory; return addHeapObject(ret); }; - imports.wbg.__wbg_buffer_d81727464c886f26 = function(arg0) { + imports.wbg.__wbg_buffer_3f3d764d4747d564 = function(arg0) { const ret = getObject(arg0).buffer; return addHeapObject(ret); }; - imports.wbg.__wbg_new_a3125f766f3a92ac = function(arg0) { + imports.wbg.__wbg_new_8c3f0052272a457a = function(arg0) { const ret = new Uint8Array(getObject(arg0)); return addHeapObject(ret); }; - imports.wbg.__wbg_set_51d981ee0f618b95 = function(arg0, arg1, arg2) { + imports.wbg.__wbg_set_83db9690f9353e79 = function(arg0, arg1, arg2) { getObject(arg0).set(getObject(arg1), arg2 >>> 0); }; - imports.wbg.__wbg_length_43d4584cbc8565d1 = function(arg0) { + imports.wbg.__wbg_length_9e1ae1900cb0fbd5 = function(arg0) { const ret = getObject(arg0).length; return ret; }; - imports.wbg.__wbg_subarray_2f6b60a6e0c8bb7b = function(arg0, arg1, arg2) { + imports.wbg.__wbg_subarray_58ad4efbb5bcb886 = function(arg0, arg1, arg2) { const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0); return addHeapObject(ret); }; @@ -1024,7 +1036,7 @@ function getImports() { getInt32Memory0()[arg0 / 4 + 1] = len0; getInt32Memory0()[arg0 / 4 + 0] = ptr0; }; - imports.wbg.__wbg_instanceof_Module_095eaf41a48764bc = function(arg0) { + imports.wbg.__wbg_instanceof_Module_09da91721979648d = function(arg0) { let result; try { result = getObject(arg0) instanceof WebAssembly.Module; @@ -1034,7 +1046,7 @@ function getImports() { const ret = result; return ret; }; - imports.wbg.__wbg_instanceof_Table_7aa3c4bf4a3e48a4 = function(arg0) { + imports.wbg.__wbg_instanceof_Table_aab62205c7444b79 = function(arg0) { let result; try { result = getObject(arg0) instanceof WebAssembly.Table; @@ -1044,11 +1056,11 @@ function getImports() { const ret = result; return ret; }; - imports.wbg.__wbg_get_fbd1d9263b918411 = function() { return handleError(function (arg0, arg1) { + imports.wbg.__wbg_get_19328b9e516e0330 = function() { return handleError(function (arg0, arg1) { const ret = getObject(arg0).get(arg1 >>> 0); return addHeapObject(ret); }, arguments) }; - imports.wbg.__wbg_instanceof_Memory_625744f21df3a5ec = function(arg0) { + imports.wbg.__wbg_instanceof_Memory_f1dc0d9a83a9c8ea = function(arg0) { let result; try { result = getObject(arg0) instanceof WebAssembly.Memory; @@ -1058,11 +1070,11 @@ function getImports() { const ret = result; return ret; }; - imports.wbg.__wbg_get_5a78b7783b0bd799 = function() { return handleError(function (arg0, arg1) { + imports.wbg.__wbg_get_765201544a2b6869 = function() { return handleError(function (arg0, arg1) { const ret = Reflect.get(getObject(arg0), getObject(arg1)); return addHeapObject(ret); }, arguments) }; - imports.wbg.__wbg_set_ea8cd341c2a6f8d7 = function() { return handleError(function (arg0, arg1, arg2) { + imports.wbg.__wbg_set_bf3f89b92d5a34bf = function() { return handleError(function (arg0, arg1, arg2) { const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2)); return ret; }, arguments) }; @@ -1079,19 +1091,15 @@ function getImports() { imports.wbg.__wbindgen_rethrow = function(arg0) { throw takeObject(arg0); }; - imports.wbg.__wbg_newwithbyteoffsetandlength_3aba6c798270ebca = function(arg0, arg1, arg2) { + imports.wbg.__wbg_newwithbyteoffsetandlength_d9aa266703cb98be = function(arg0, arg1, arg2) { const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0); return addHeapObject(ret); }; - imports.wbg.__wbindgen_string_new = function(arg0, arg1) { - const ret = getStringFromWasm0(arg0, arg1); - return addHeapObject(ret); - }; - imports.wbg.__wbg_imports_a0b4581dab9c2cb4 = function(arg0) { + imports.wbg.__wbg_imports_5d97b92618ae2b69 = function(arg0) { const ret = WebAssembly.Module.imports(getObject(arg0)); return addHeapObject(ret); }; - imports.wbg.__wbg_length_f41326e394b4fe13 = function(arg0) { + imports.wbg.__wbg_length_6e3bbe7c8bd4dbd8 = function(arg0) { const ret = getObject(arg0).length; return ret; }; @@ -1109,15 +1117,15 @@ function getImports() { const ret = WasmerRuntimeError.__wrap(arg0); return addHeapObject(ret); }; - imports.wbg.__wbg_getPrototypeOf_b62dafee4d50c09e = function(arg0) { + imports.wbg.__wbg_getPrototypeOf_ca7be35aca69033c = function(arg0) { const ret = Object.getPrototypeOf(getObject(arg0)); return addHeapObject(ret); }; - imports.wbg.__wbg_constructor_c3d1d684a586dd5f = function(arg0) { + imports.wbg.__wbg_constructor_20fd216941fe9866 = function(arg0) { const ret = getObject(arg0).constructor; return addHeapObject(ret); }; - imports.wbg.__wbg_name_5436b04184f1adc4 = function(arg0) { + imports.wbg.__wbg_name_da379f055623f0d3 = function(arg0) { const ret = getObject(arg0).name; return addHeapObject(ret); }; @@ -1127,19 +1135,19 @@ function getImports() { getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); }; - imports.wbg.__wbg_new0_172803edd242036c = function() { + imports.wbg.__wbg_new0_a57059d72c5b7aee = function() { const ret = new Date(); return addHeapObject(ret); }; - imports.wbg.__wbg_getTime_8e53aaca359697ac = function(arg0) { + imports.wbg.__wbg_getTime_cb82adb2556ed13e = function(arg0) { const ret = getObject(arg0).getTime(); return ret; }; - imports.wbg.__wbg_getTimezoneOffset_7234c87e6e74aa7d = function(arg0) { + imports.wbg.__wbg_getTimezoneOffset_89bd4275e1ca8341 = function(arg0) { const ret = getObject(arg0).getTimezoneOffset(); return ret; }; - imports.wbg.__wbg_new_08af39e773e3ddfb = function() { + imports.wbg.__wbg_new_0b9bfdd97583284e = function() { const ret = new Object(); return addHeapObject(ret); }; @@ -1147,15 +1155,15 @@ function getImports() { const ret = BigInt.asUintN(64, arg0); return addHeapObject(ret); }; - imports.wbg.__wbg_new_be673b64c5e1d103 = function(arg0, arg1) { + imports.wbg.__wbg_new_8d2af00bc1e329ee = function(arg0, arg1) { const ret = new Error(getStringFromWasm0(arg0, arg1)); return addHeapObject(ret); }; - imports.wbg.__wbg_new_53ee626301534885 = function() { + imports.wbg.__wbg_new_1d9a920c6bfc44a8 = function() { const ret = new Array(); return addHeapObject(ret); }; - imports.wbg.__wbg_push_83f99a9bcae512c6 = function(arg0, arg1) { + imports.wbg.__wbg_push_740e4b286702d964 = function(arg0, arg1) { const ret = getObject(arg0).push(getObject(arg1)); return ret; }; @@ -1164,15 +1172,15 @@ function getImports() { const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; return ret; }; - imports.wbg.__wbg_isArray_d6e9c8ad3e915729 = function(arg0) { + imports.wbg.__wbg_isArray_27c46c67f498e15d = function(arg0) { const ret = Array.isArray(getObject(arg0)); return ret; }; - imports.wbg.__wbg_entries_f97ecc5d8af908a6 = function(arg0) { + imports.wbg.__wbg_entries_65a76a413fc91037 = function(arg0) { const ret = Object.entries(getObject(arg0)); return addHeapObject(ret); }; - imports.wbg.__wbg_instanceof_Instance_38f5bc5383db505e = function(arg0) { + imports.wbg.__wbg_instanceof_Instance_b0fc12339921a27e = function(arg0) { let result; try { result = getObject(arg0) instanceof WebAssembly.Instance; @@ -1186,19 +1194,19 @@ function getImports() { const ret = typeof getObject(arg0); return addHeapObject(ret); }; - imports.wbg.__wbg_new_5a8bb4022c570979 = function() { return handleError(function (arg0, arg1) { + imports.wbg.__wbg_new_1c5d2ff1edfe6d73 = function() { return handleError(function (arg0, arg1) { const ret = new WebAssembly.Instance(getObject(arg0), getObject(arg1)); return addHeapObject(ret); }, arguments) }; - imports.wbg.__wbg_newwithlength_11d3ceadb55d1000 = function(arg0) { + imports.wbg.__wbg_newwithlength_7c42f7e738a9d5d3 = function(arg0) { const ret = new Array(arg0 >>> 0); return addHeapObject(ret); }; - imports.wbg.__wbg_apply_f03a73e552b34c08 = function() { return handleError(function (arg0, arg1, arg2) { + imports.wbg.__wbg_apply_75f7334893eef4ad = function() { return handleError(function (arg0, arg1, arg2) { const ret = Reflect.apply(getObject(arg0), getObject(arg1), getObject(arg2)); return addHeapObject(ret); }, arguments) }; - imports.wbg.__wbg_instanceof_Object_66786225e0dbc8ba = function(arg0) { + imports.wbg.__wbg_instanceof_Object_595a1007518cbea3 = function(arg0) { let result; try { result = getObject(arg0) instanceof Object; @@ -1216,21 +1224,21 @@ function getImports() { const ret = arg0; return addHeapObject(ret); }; - imports.wbg.__wbg_bind_ae625939b6259e2a = function(arg0, arg1, arg2, arg3) { + imports.wbg.__wbg_bind_10dfe70e95d2a480 = function(arg0, arg1, arg2, arg3) { const ret = getObject(arg0).bind(getObject(arg1), getObject(arg2), getObject(arg3)); return addHeapObject(ret); }; - imports.wbg.__wbg_randomFillSync_a1a617f7e299dda2 = function() { return handleError(function (arg0, arg1, arg2) { + imports.wbg.__wbg_randomFillSync_6894564c2c334c42 = function() { return handleError(function (arg0, arg1, arg2) { getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2)); }, arguments) }; - imports.wbg.__wbg_getRandomValues_b90a7d4919317798 = function() { return handleError(function (arg0, arg1) { + imports.wbg.__wbg_getRandomValues_805f1c3d65988a5a = function() { return handleError(function (arg0, arg1) { getObject(arg0).getRandomValues(getObject(arg1)); }, arguments) }; - imports.wbg.__wbg_exports_d440a9b749caa3e0 = function(arg0) { + imports.wbg.__wbg_exports_1f32da4bc6734cea = function(arg0) { const ret = getObject(arg0).exports; return addHeapObject(ret); }; - imports.wbg.__wbg_exports_fbf94aab875c89db = function(arg0) { + imports.wbg.__wbg_exports_4db28c393be16bc5 = function(arg0) { const ret = WebAssembly.Module.exports(getObject(arg0)); return addHeapObject(ret); }; diff --git a/pkg/wasmer_wasi_js_bg.wasm b/pkg/wasmer_wasi_js_bg.wasm index 1439c39e..64c80232 100644 Binary files a/pkg/wasmer_wasi_js_bg.wasm and b/pkg/wasmer_wasi_js_bg.wasm differ diff --git a/src/fs.rs b/src/fs.rs index afcc55a5..4451ef88 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -1,13 +1,13 @@ +use crate::wasi::generic_of_jsval; use js_sys::Reflect; use std::path::{Path, PathBuf}; use std::sync::Arc; use wasm_bindgen::prelude::*; -use wasm_bindgen::JsCast; + use wasmer_vfs::mem_fs::FileSystem as MemoryFilesystem; use wasmer_vfs::{ DirEntry, FileSystem, FileType, FsError, Metadata, OpenOptions, ReadDir, VirtualFile, }; -use crate::wasi::generic_of_jsval; #[wasm_bindgen] #[derive(Debug, Clone)] @@ -51,7 +51,7 @@ fn direntry_to_object(direntry: &DirEntry) -> Result { Reflect::set( &direntry_obj, &"metadata".into(), - &metadata_to_object(&direntry.metadata.as_ref().unwrap())?.into(), + &metadata_to_object(direntry.metadata.as_ref().unwrap())?.into(), )?; Ok(direntry_obj) } @@ -76,13 +76,13 @@ impl MemFS { .inner .read_dir(&PathBuf::from(path)) .map_err(|e| js_sys::Error::new(&format!("Error when reading the dir: {}`", e)))?; - Ok(dir_entries + dir_entries .map(|entry| { let entry = entry .map_err(|e| js_sys::Error::new(&format!("Failed to get entry: {}`", e)))?; direntry_to_object(&entry) }) - .collect::>()?) + .collect::>() } #[wasm_bindgen(js_name = createDir)] @@ -241,9 +241,9 @@ impl JSVirtualFile { } // Write APIs - pub fn write(&mut self, mut buf: &mut [u8]) -> Result { + pub fn write(&mut self, buf: &mut [u8]) -> Result { self.handle - .write(&mut buf) + .write(buf) .map_err(|e| js_sys::Error::new(&format!("Error when writing: {}`", e)).into()) } diff --git a/src/wasi.rs b/src/wasi.rs index 17c18b0a..be0d68a5 100644 --- a/src/wasi.rs +++ b/src/wasi.rs @@ -1,14 +1,30 @@ use crate::fs::MemFS; -use std::io::{Read, Write}; use js_sys::{Object, Reflect}; +use std::io::{Read, Write}; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use wasmer::{Imports, Instance, Module, Store}; use wasmer_wasi::Pipe; -use wasmer_wasi::{Stderr, Stdin, Stdout, WasiError, WasiFunctionEnv, WasiState}; +use wasmer_wasi::{WasiError, WasiFunctionEnv, WasiState}; use wasm_bindgen::convert::RefFromWasmAbi; +#[wasm_bindgen(typescript_custom_section)] +const _: &str = r#" +interface WasiConfig { + readonly args?: string[], + readonly env?: Record, + readonly preopens?: Record, + readonly fs?: any, +} +"#; + +#[wasm_bindgen] +extern "C" { + #[wasm_bindgen(typescript_type = "WasiConfig")] + pub type Config; +} + #[wasm_bindgen] pub struct WASI { store: Store, @@ -23,7 +39,7 @@ pub struct WASI { #[wasm_bindgen] impl WASI { #[wasm_bindgen(constructor)] - pub fn new(config: JsValue) -> Result { + pub fn new(config: Config) -> Result { let args: Vec = { let args = js_sys::Reflect::get(&config, &"args".into())?; if args.is_undefined() { @@ -96,8 +112,8 @@ impl WASI { let stdout = Pipe::default(); let stdin = Pipe::default(); let stderr = Pipe::default(); - let wasi_env = WasiState::new(&args.get(0).unwrap_or(&"".to_string())) - .args(if args.len() > 0 { &args[1..] } else { &[] }) + let wasi_env = WasiState::new(args.get(0).unwrap_or(&"".to_string())) + .args(if !args.is_empty() { &args[1..] } else { &[] }) .envs(env) .set_fs(Box::new(fs)) .stdout(Box::new(stdout.clone())) @@ -123,12 +139,12 @@ impl WASI { #[wasm_bindgen(getter)] pub fn fs(&mut self) -> Result { - let mut state = self.wasi_env.data_mut(&mut self.store).state(); + let state = self.wasi_env.data_mut(&mut self.store).state(); let mem_fs = state .fs .fs_backing .downcast_ref::() - .ok_or_else(|| js_sys::Error::new(&format!("Failed to downcast to MemFS")))?; + .ok_or_else(|| js_sys::Error::new("Failed to downcast to MemFS"))?; Ok(mem_fs.clone()) } @@ -147,7 +163,7 @@ impl WASI { self.module = Some(module); - Ok(import_object.as_jsobject(&self.store).into()) + Ok(import_object.as_jsobject(&self.store)) } fn get_wasi_imports(&mut self, module: &Module) -> Result { @@ -187,15 +203,14 @@ impl WASI { } else if module_or_instance.has_type::() { if let Some(instance) = &self.instance { // We completely skip the set instance step - return Ok(instance.raw(&mut self.store).clone()); + return Ok(instance.raw(&self.store).clone()); } let module = self.module.as_ref().ok_or(js_sys::Error::new("When providing an instance, the `wasi.getImports` must be called with the module first"))?; let js_instance: js_sys::WebAssembly::Instance = module_or_instance.unchecked_into(); - let instance = Instance::from_module_and_instance(&mut self.store, module, js_instance) - .map_err(|e| { - js_sys::Error::new(&format!("Can't get the Wasmer Instance: {:?}", e)) - })?; - instance + + Instance::from_module_and_instance(&mut self.store, module, js_instance).map_err( + |e| js_sys::Error::new(&format!("Can't get the Wasmer Instance: {:?}", e)), + )? } else { return Err( js_sys::Error::new("You need to provide a `WebAssembly.Module` or `WebAssembly.Instance` as first argument to `wasi.instantiate`").into(), @@ -206,7 +221,7 @@ impl WASI { .data_mut(&mut self.store) .set_memory(instance.exports.get_memory("memory").unwrap().clone()); - let raw_instance = instance.raw(&mut self.store).clone(); + let raw_instance = instance.raw(&self.store).clone(); self.instance = Some(instance); Ok(raw_instance) } @@ -239,7 +254,7 @@ impl WASI { match err.downcast::() { Ok(WasiError::Exit(exit_code)) => { // We should exit with the provided exit code - return Ok(exit_code); + Ok(exit_code) } Ok(err) => { return Err(js_sys::Error::new(&format!( @@ -330,22 +345,23 @@ impl WASI { // helper function for passing Rust objects through JS // https://github.com/rustwasm/wasm-bindgen/issues/2231#issuecomment-1147260391 -pub fn generic_of_jsval>(js: JsValue, classname: &str) -> Result { +pub fn generic_of_jsval>( + js: JsValue, + classname: &str, +) -> Result { if !js.is_object() { - return Err(js_sys::Error::new( - &format!("expected object, got {:?}", js).as_str(), - ).into()); + return Err(js_sys::Error::new(format!("expected object, got {:?}", js).as_str()).into()); } let ctor_name = Object::get_prototype_of(&js).constructor().name(); if ctor_name == classname { let ptr = Reflect::get(&js, &JsValue::from_str("ptr"))?; let ptr_u32: u32 = ptr.as_f64().ok_or(JsValue::NULL)? as u32; - let foo = unsafe { T::ref_from_abi(ptr_u32) }; - Ok(foo) + Ok(unsafe { T::ref_from_abi(ptr_u32) }) } else { - Err(js_sys::Error::new( - &format!("expected '{}', got '{}'", classname, ctor_name).as_str() - ).into()) + Err( + js_sys::Error::new(format!("expected '{}', got '{}'", classname, ctor_name).as_str()) + .into(), + ) } }