├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── README.md ├── examples ├── calculator.witx ├── errno.witx ├── using_add.wat └── using_add │ ├── Cargo.lock │ ├── Cargo.toml │ └── src │ └── lib.rs └── src ├── calculator.rs └── main.rs /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "addr2line" 5 | version = "0.12.1" 6 | source = "registry+https://github.com/rust-lang/crates.io-index" 7 | checksum = "a49806b9dadc843c61e7c97e72490ad7f7220ae249012fbda9ad0609457c0543" 8 | dependencies = [ 9 | "gimli 0.21.0", 10 | ] 11 | 12 | [[package]] 13 | name = "adler32" 14 | version = "1.1.0" 15 | source = "registry+https://github.com/rust-lang/crates.io-index" 16 | checksum = "567b077b825e468cc974f0020d4082ee6e03132512f207ef1a02fd5d00d1f32d" 17 | 18 | [[package]] 19 | name = "aho-corasick" 20 | version = "0.7.10" 21 | source = "registry+https://github.com/rust-lang/crates.io-index" 22 | checksum = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada" 23 | dependencies = [ 24 | "memchr", 25 | ] 26 | 27 | [[package]] 28 | name = "anyhow" 29 | version = "1.0.31" 30 | source = "registry+https://github.com/rust-lang/crates.io-index" 31 | checksum = "85bb70cc08ec97ca5450e6eba421deeea5f172c0fc61f78b5357b2a8e8be195f" 32 | 33 | [[package]] 34 | name = "arrayref" 35 | version = "0.3.6" 36 | source = "registry+https://github.com/rust-lang/crates.io-index" 37 | checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" 38 | 39 | [[package]] 40 | name = "arrayvec" 41 | version = "0.5.1" 42 | source = "registry+https://github.com/rust-lang/crates.io-index" 43 | checksum = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8" 44 | 45 | [[package]] 46 | name = "atty" 47 | version = "0.2.14" 48 | source = "registry+https://github.com/rust-lang/crates.io-index" 49 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 50 | dependencies = [ 51 | "hermit-abi", 52 | "libc", 53 | "winapi", 54 | ] 55 | 56 | [[package]] 57 | name = "autocfg" 58 | version = "0.1.7" 59 | source = "registry+https://github.com/rust-lang/crates.io-index" 60 | checksum = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" 61 | 62 | [[package]] 63 | name = "autocfg" 64 | version = "1.0.0" 65 | source = "registry+https://github.com/rust-lang/crates.io-index" 66 | checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" 67 | 68 | [[package]] 69 | name = "backtrace" 70 | version = "0.3.49" 71 | source = "registry+https://github.com/rust-lang/crates.io-index" 72 | checksum = "05100821de9e028f12ae3d189176b41ee198341eb8f369956407fea2f5cc666c" 73 | dependencies = [ 74 | "addr2line", 75 | "cfg-if", 76 | "libc", 77 | "miniz_oxide", 78 | "object 0.20.0", 79 | "rustc-demangle", 80 | ] 81 | 82 | [[package]] 83 | name = "base64" 84 | version = "0.11.0" 85 | source = "registry+https://github.com/rust-lang/crates.io-index" 86 | checksum = "b41b7ea54a0c9d92199de89e20e58d49f02f8e699814ef3fdf266f6f748d15c7" 87 | 88 | [[package]] 89 | name = "base64" 90 | version = "0.12.2" 91 | source = "registry+https://github.com/rust-lang/crates.io-index" 92 | checksum = "e223af0dc48c96d4f8342ec01a4974f139df863896b316681efd36742f22cc67" 93 | 94 | [[package]] 95 | name = "bincode" 96 | version = "1.2.1" 97 | source = "registry+https://github.com/rust-lang/crates.io-index" 98 | checksum = "5753e2a71534719bf3f4e57006c3a4f0d2c672a4b676eec84161f763eca87dbf" 99 | dependencies = [ 100 | "byteorder", 101 | "serde", 102 | ] 103 | 104 | [[package]] 105 | name = "bit-set" 106 | version = "0.5.2" 107 | source = "registry+https://github.com/rust-lang/crates.io-index" 108 | checksum = "6e11e16035ea35e4e5997b393eacbf6f63983188f7a2ad25bfb13465f5ad59de" 109 | dependencies = [ 110 | "bit-vec", 111 | ] 112 | 113 | [[package]] 114 | name = "bit-vec" 115 | version = "0.6.2" 116 | source = "registry+https://github.com/rust-lang/crates.io-index" 117 | checksum = "5f0dc55f2d8a1a85650ac47858bb001b4c0dd73d79e3c455a842925e68d29cd3" 118 | 119 | [[package]] 120 | name = "bitflags" 121 | version = "1.2.1" 122 | source = "registry+https://github.com/rust-lang/crates.io-index" 123 | checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" 124 | 125 | [[package]] 126 | name = "blake2b_simd" 127 | version = "0.5.10" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | checksum = "d8fb2d74254a3a0b5cac33ac9f8ed0e44aa50378d9dbb2e5d83bd21ed1dc2c8a" 130 | dependencies = [ 131 | "arrayref", 132 | "arrayvec", 133 | "constant_time_eq", 134 | ] 135 | 136 | [[package]] 137 | name = "block-buffer" 138 | version = "0.7.3" 139 | source = "registry+https://github.com/rust-lang/crates.io-index" 140 | checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" 141 | dependencies = [ 142 | "block-padding", 143 | "byte-tools", 144 | "byteorder", 145 | "generic-array", 146 | ] 147 | 148 | [[package]] 149 | name = "block-padding" 150 | version = "0.1.5" 151 | source = "registry+https://github.com/rust-lang/crates.io-index" 152 | checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" 153 | dependencies = [ 154 | "byte-tools", 155 | ] 156 | 157 | [[package]] 158 | name = "byte-tools" 159 | version = "0.3.1" 160 | source = "registry+https://github.com/rust-lang/crates.io-index" 161 | checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" 162 | 163 | [[package]] 164 | name = "byteorder" 165 | version = "1.3.4" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" 168 | 169 | [[package]] 170 | name = "cc" 171 | version = "1.0.54" 172 | source = "registry+https://github.com/rust-lang/crates.io-index" 173 | checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311" 174 | dependencies = [ 175 | "jobserver", 176 | ] 177 | 178 | [[package]] 179 | name = "cfg-if" 180 | version = "0.1.10" 181 | source = "registry+https://github.com/rust-lang/crates.io-index" 182 | checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 183 | 184 | [[package]] 185 | name = "cloudabi" 186 | version = "0.0.3" 187 | source = "registry+https://github.com/rust-lang/crates.io-index" 188 | checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" 189 | dependencies = [ 190 | "bitflags", 191 | ] 192 | 193 | [[package]] 194 | name = "constant_time_eq" 195 | version = "0.1.5" 196 | source = "registry+https://github.com/rust-lang/crates.io-index" 197 | checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" 198 | 199 | [[package]] 200 | name = "cpu-time" 201 | version = "1.0.0" 202 | source = "registry+https://github.com/rust-lang/crates.io-index" 203 | checksum = "e9e393a7668fe1fad3075085b86c781883000b4ede868f43627b34a87c8b7ded" 204 | dependencies = [ 205 | "libc", 206 | "winapi", 207 | ] 208 | 209 | [[package]] 210 | name = "cranelift-bforest" 211 | version = "0.63.0" 212 | source = "registry+https://github.com/rust-lang/crates.io-index" 213 | checksum = "d4425bb6c3f3d2f581c650f1a1fdd3196a975490149cf59bea9d34c3bea79eda" 214 | dependencies = [ 215 | "cranelift-entity", 216 | ] 217 | 218 | [[package]] 219 | name = "cranelift-codegen" 220 | version = "0.63.0" 221 | source = "registry+https://github.com/rust-lang/crates.io-index" 222 | checksum = "d166b289fd30062ee6de86284750fc3fe5d037c6b864b3326ce153239b0626e1" 223 | dependencies = [ 224 | "byteorder", 225 | "cranelift-bforest", 226 | "cranelift-codegen-meta", 227 | "cranelift-codegen-shared", 228 | "cranelift-entity", 229 | "gimli 0.20.0", 230 | "log", 231 | "regalloc", 232 | "serde", 233 | "smallvec", 234 | "target-lexicon", 235 | "thiserror", 236 | ] 237 | 238 | [[package]] 239 | name = "cranelift-codegen-meta" 240 | version = "0.63.0" 241 | source = "registry+https://github.com/rust-lang/crates.io-index" 242 | checksum = "02c9fb2306a36d41c5facd4bf3400bc6c157185c43a96eaaa503471c34c5144b" 243 | dependencies = [ 244 | "cranelift-codegen-shared", 245 | "cranelift-entity", 246 | ] 247 | 248 | [[package]] 249 | name = "cranelift-codegen-shared" 250 | version = "0.63.0" 251 | source = "registry+https://github.com/rust-lang/crates.io-index" 252 | checksum = "44e0cfe9b1f97d9f836bca551618106c7d53b93b579029ecd38e73daa7eb689e" 253 | 254 | [[package]] 255 | name = "cranelift-entity" 256 | version = "0.63.0" 257 | source = "registry+https://github.com/rust-lang/crates.io-index" 258 | checksum = "926a73c432e5ba9c891171ff50b75e7d992cd76cd271f0a0a0ba199138077472" 259 | dependencies = [ 260 | "serde", 261 | ] 262 | 263 | [[package]] 264 | name = "cranelift-frontend" 265 | version = "0.63.0" 266 | source = "registry+https://github.com/rust-lang/crates.io-index" 267 | checksum = "e45f82e3446dd1ebb8c2c2f6a6b0e6cd6cd52965c7e5f7b1b35e9a9ace31ccde" 268 | dependencies = [ 269 | "cranelift-codegen", 270 | "log", 271 | "smallvec", 272 | "target-lexicon", 273 | ] 274 | 275 | [[package]] 276 | name = "cranelift-native" 277 | version = "0.63.0" 278 | source = "registry+https://github.com/rust-lang/crates.io-index" 279 | checksum = "488b5d481bb0996a143e55a9d1739ef425efa20d4a5e5e98c859a8573c9ead9a" 280 | dependencies = [ 281 | "cranelift-codegen", 282 | "raw-cpuid", 283 | "target-lexicon", 284 | ] 285 | 286 | [[package]] 287 | name = "cranelift-wasm" 288 | version = "0.63.0" 289 | source = "registry+https://github.com/rust-lang/crates.io-index" 290 | checksum = "00aa8dde71fd9fdb1958e7b0ef8f524c1560e2c6165e4ea54bc302b40551c161" 291 | dependencies = [ 292 | "cranelift-codegen", 293 | "cranelift-entity", 294 | "cranelift-frontend", 295 | "log", 296 | "serde", 297 | "thiserror", 298 | "wasmparser", 299 | ] 300 | 301 | [[package]] 302 | name = "crc32fast" 303 | version = "1.2.0" 304 | source = "registry+https://github.com/rust-lang/crates.io-index" 305 | checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" 306 | dependencies = [ 307 | "cfg-if", 308 | ] 309 | 310 | [[package]] 311 | name = "crossbeam-deque" 312 | version = "0.7.3" 313 | source = "registry+https://github.com/rust-lang/crates.io-index" 314 | checksum = "9f02af974daeee82218205558e51ec8768b48cf524bd01d550abe5573a608285" 315 | dependencies = [ 316 | "crossbeam-epoch", 317 | "crossbeam-utils", 318 | "maybe-uninit", 319 | ] 320 | 321 | [[package]] 322 | name = "crossbeam-epoch" 323 | version = "0.8.2" 324 | source = "registry+https://github.com/rust-lang/crates.io-index" 325 | checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" 326 | dependencies = [ 327 | "autocfg 1.0.0", 328 | "cfg-if", 329 | "crossbeam-utils", 330 | "lazy_static", 331 | "maybe-uninit", 332 | "memoffset", 333 | "scopeguard", 334 | ] 335 | 336 | [[package]] 337 | name = "crossbeam-queue" 338 | version = "0.2.3" 339 | source = "registry+https://github.com/rust-lang/crates.io-index" 340 | checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" 341 | dependencies = [ 342 | "cfg-if", 343 | "crossbeam-utils", 344 | "maybe-uninit", 345 | ] 346 | 347 | [[package]] 348 | name = "crossbeam-utils" 349 | version = "0.7.2" 350 | source = "registry+https://github.com/rust-lang/crates.io-index" 351 | checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" 352 | dependencies = [ 353 | "autocfg 1.0.0", 354 | "cfg-if", 355 | "lazy_static", 356 | ] 357 | 358 | [[package]] 359 | name = "cvt" 360 | version = "0.1.1" 361 | source = "registry+https://github.com/rust-lang/crates.io-index" 362 | checksum = "34ac344c7efccb80cd25bc61b2170aec26f2f693fd40e765a539a1243db48c71" 363 | dependencies = [ 364 | "cfg-if", 365 | ] 366 | 367 | [[package]] 368 | name = "digest" 369 | version = "0.8.1" 370 | source = "registry+https://github.com/rust-lang/crates.io-index" 371 | checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" 372 | dependencies = [ 373 | "generic-array", 374 | ] 375 | 376 | [[package]] 377 | name = "directories" 378 | version = "2.0.2" 379 | source = "registry+https://github.com/rust-lang/crates.io-index" 380 | checksum = "551a778172a450d7fc12e629ca3b0428d00f6afa9a43da1b630d54604e97371c" 381 | dependencies = [ 382 | "cfg-if", 383 | "dirs-sys", 384 | ] 385 | 386 | [[package]] 387 | name = "dirs-sys" 388 | version = "0.3.5" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" 391 | dependencies = [ 392 | "libc", 393 | "redox_users", 394 | "winapi", 395 | ] 396 | 397 | [[package]] 398 | name = "either" 399 | version = "1.5.3" 400 | source = "registry+https://github.com/rust-lang/crates.io-index" 401 | checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" 402 | 403 | [[package]] 404 | name = "env_logger" 405 | version = "0.7.1" 406 | source = "registry+https://github.com/rust-lang/crates.io-index" 407 | checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" 408 | dependencies = [ 409 | "atty", 410 | "humantime", 411 | "log", 412 | "regex", 413 | "termcolor", 414 | ] 415 | 416 | [[package]] 417 | name = "errno" 418 | version = "0.2.5" 419 | source = "registry+https://github.com/rust-lang/crates.io-index" 420 | checksum = "b480f641ccf0faf324e20c1d3e53d81b7484c698b42ea677f6907ae4db195371" 421 | dependencies = [ 422 | "errno-dragonfly", 423 | "libc", 424 | "winapi", 425 | ] 426 | 427 | [[package]] 428 | name = "errno-dragonfly" 429 | version = "0.1.1" 430 | source = "registry+https://github.com/rust-lang/crates.io-index" 431 | checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" 432 | dependencies = [ 433 | "gcc", 434 | "libc", 435 | ] 436 | 437 | [[package]] 438 | name = "faerie" 439 | version = "0.15.0" 440 | source = "registry+https://github.com/rust-lang/crates.io-index" 441 | checksum = "dfef65b0e94693295c5d2fe2506f0ee6f43465342d4b5331659936aee8b16084" 442 | dependencies = [ 443 | "goblin", 444 | "indexmap", 445 | "log", 446 | "scroll", 447 | "string-interner", 448 | "target-lexicon", 449 | "thiserror", 450 | ] 451 | 452 | [[package]] 453 | name = "fake-simd" 454 | version = "0.1.2" 455 | source = "registry+https://github.com/rust-lang/crates.io-index" 456 | checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" 457 | 458 | [[package]] 459 | name = "fallible-iterator" 460 | version = "0.2.0" 461 | source = "registry+https://github.com/rust-lang/crates.io-index" 462 | checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" 463 | 464 | [[package]] 465 | name = "file-per-thread-logger" 466 | version = "0.1.3" 467 | source = "registry+https://github.com/rust-lang/crates.io-index" 468 | checksum = "8b3937f028664bd0e13df401ba49a4567ccda587420365823242977f06609ed1" 469 | dependencies = [ 470 | "env_logger", 471 | "log", 472 | ] 473 | 474 | [[package]] 475 | name = "filetime" 476 | version = "0.2.10" 477 | source = "registry+https://github.com/rust-lang/crates.io-index" 478 | checksum = "affc17579b132fc2461adf7c575cc6e8b134ebca52c51f5411388965227dc695" 479 | dependencies = [ 480 | "cfg-if", 481 | "libc", 482 | "redox_syscall", 483 | "winapi", 484 | ] 485 | 486 | [[package]] 487 | name = "flate2" 488 | version = "1.0.14" 489 | source = "registry+https://github.com/rust-lang/crates.io-index" 490 | checksum = "2cfff41391129e0a856d6d822600b8d71179d46879e310417eb9c762eb178b42" 491 | dependencies = [ 492 | "cfg-if", 493 | "crc32fast", 494 | "libc", 495 | "miniz_oxide", 496 | ] 497 | 498 | [[package]] 499 | name = "fnv" 500 | version = "1.0.7" 501 | source = "registry+https://github.com/rust-lang/crates.io-index" 502 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 503 | 504 | [[package]] 505 | name = "fuchsia-cprng" 506 | version = "0.1.1" 507 | source = "registry+https://github.com/rust-lang/crates.io-index" 508 | checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" 509 | 510 | [[package]] 511 | name = "gcc" 512 | version = "0.3.55" 513 | source = "registry+https://github.com/rust-lang/crates.io-index" 514 | checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" 515 | 516 | [[package]] 517 | name = "generic-array" 518 | version = "0.12.3" 519 | source = "registry+https://github.com/rust-lang/crates.io-index" 520 | checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" 521 | dependencies = [ 522 | "typenum", 523 | ] 524 | 525 | [[package]] 526 | name = "getrandom" 527 | version = "0.1.14" 528 | source = "registry+https://github.com/rust-lang/crates.io-index" 529 | checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" 530 | dependencies = [ 531 | "cfg-if", 532 | "libc", 533 | "wasi", 534 | ] 535 | 536 | [[package]] 537 | name = "gimli" 538 | version = "0.20.0" 539 | source = "registry+https://github.com/rust-lang/crates.io-index" 540 | checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633" 541 | dependencies = [ 542 | "arrayvec", 543 | "byteorder", 544 | "fallible-iterator", 545 | "indexmap", 546 | "smallvec", 547 | "stable_deref_trait", 548 | ] 549 | 550 | [[package]] 551 | name = "gimli" 552 | version = "0.21.0" 553 | source = "registry+https://github.com/rust-lang/crates.io-index" 554 | checksum = "bcc8e0c9bce37868955864dbecd2b1ab2bdf967e6f28066d65aaac620444b65c" 555 | 556 | [[package]] 557 | name = "glob" 558 | version = "0.3.0" 559 | source = "registry+https://github.com/rust-lang/crates.io-index" 560 | checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" 561 | 562 | [[package]] 563 | name = "goblin" 564 | version = "0.1.3" 565 | source = "registry+https://github.com/rust-lang/crates.io-index" 566 | checksum = "3081214398d39e4bd7f2c1975f0488ed04614ffdd976c6fc7a0708278552c0da" 567 | dependencies = [ 568 | "log", 569 | "plain", 570 | "scroll", 571 | ] 572 | 573 | [[package]] 574 | name = "heck" 575 | version = "0.3.1" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" 578 | dependencies = [ 579 | "unicode-segmentation", 580 | ] 581 | 582 | [[package]] 583 | name = "hermit-abi" 584 | version = "0.1.14" 585 | source = "registry+https://github.com/rust-lang/crates.io-index" 586 | checksum = "b9586eedd4ce6b3c498bc3b4dd92fc9f11166aa908a914071953768066c67909" 587 | dependencies = [ 588 | "libc", 589 | ] 590 | 591 | [[package]] 592 | name = "humantime" 593 | version = "1.3.0" 594 | source = "registry+https://github.com/rust-lang/crates.io-index" 595 | checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" 596 | dependencies = [ 597 | "quick-error", 598 | ] 599 | 600 | [[package]] 601 | name = "indexmap" 602 | version = "1.4.0" 603 | source = "registry+https://github.com/rust-lang/crates.io-index" 604 | checksum = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe" 605 | dependencies = [ 606 | "autocfg 1.0.0", 607 | ] 608 | 609 | [[package]] 610 | name = "itertools" 611 | version = "0.9.0" 612 | source = "registry+https://github.com/rust-lang/crates.io-index" 613 | checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" 614 | dependencies = [ 615 | "either", 616 | ] 617 | 618 | [[package]] 619 | name = "jobserver" 620 | version = "0.1.21" 621 | source = "registry+https://github.com/rust-lang/crates.io-index" 622 | checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" 623 | dependencies = [ 624 | "libc", 625 | ] 626 | 627 | [[package]] 628 | name = "lazy_static" 629 | version = "1.4.0" 630 | source = "registry+https://github.com/rust-lang/crates.io-index" 631 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 632 | 633 | [[package]] 634 | name = "leb128" 635 | version = "0.2.4" 636 | source = "registry+https://github.com/rust-lang/crates.io-index" 637 | checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a" 638 | 639 | [[package]] 640 | name = "libc" 641 | version = "0.2.71" 642 | source = "registry+https://github.com/rust-lang/crates.io-index" 643 | checksum = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" 644 | 645 | [[package]] 646 | name = "log" 647 | version = "0.4.8" 648 | source = "registry+https://github.com/rust-lang/crates.io-index" 649 | checksum = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" 650 | dependencies = [ 651 | "cfg-if", 652 | ] 653 | 654 | [[package]] 655 | name = "mach" 656 | version = "0.3.2" 657 | source = "registry+https://github.com/rust-lang/crates.io-index" 658 | checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa" 659 | dependencies = [ 660 | "libc", 661 | ] 662 | 663 | [[package]] 664 | name = "maybe-uninit" 665 | version = "2.0.0" 666 | source = "registry+https://github.com/rust-lang/crates.io-index" 667 | checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" 668 | 669 | [[package]] 670 | name = "memchr" 671 | version = "2.3.3" 672 | source = "registry+https://github.com/rust-lang/crates.io-index" 673 | checksum = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" 674 | 675 | [[package]] 676 | name = "memoffset" 677 | version = "0.5.4" 678 | source = "registry+https://github.com/rust-lang/crates.io-index" 679 | checksum = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8" 680 | dependencies = [ 681 | "autocfg 1.0.0", 682 | ] 683 | 684 | [[package]] 685 | name = "miniz_oxide" 686 | version = "0.3.7" 687 | source = "registry+https://github.com/rust-lang/crates.io-index" 688 | checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435" 689 | dependencies = [ 690 | "adler32", 691 | ] 692 | 693 | [[package]] 694 | name = "more-asserts" 695 | version = "0.2.1" 696 | source = "registry+https://github.com/rust-lang/crates.io-index" 697 | checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238" 698 | 699 | [[package]] 700 | name = "num-traits" 701 | version = "0.2.12" 702 | source = "registry+https://github.com/rust-lang/crates.io-index" 703 | checksum = "ac267bcc07f48ee5f8935ab0d24f316fb722d7a1292e2913f0cc196b29ffd611" 704 | dependencies = [ 705 | "autocfg 1.0.0", 706 | ] 707 | 708 | [[package]] 709 | name = "num_cpus" 710 | version = "1.13.0" 711 | source = "registry+https://github.com/rust-lang/crates.io-index" 712 | checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" 713 | dependencies = [ 714 | "hermit-abi", 715 | "libc", 716 | ] 717 | 718 | [[package]] 719 | name = "object" 720 | version = "0.18.0" 721 | source = "registry+https://github.com/rust-lang/crates.io-index" 722 | checksum = "e5666bbb90bc4d1e5bdcb26c0afda1822d25928341e9384ab187a9b37ab69e36" 723 | dependencies = [ 724 | "flate2", 725 | "target-lexicon", 726 | "wasmparser", 727 | ] 728 | 729 | [[package]] 730 | name = "object" 731 | version = "0.20.0" 732 | source = "registry+https://github.com/rust-lang/crates.io-index" 733 | checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5" 734 | 735 | [[package]] 736 | name = "opaque-debug" 737 | version = "0.2.3" 738 | source = "registry+https://github.com/rust-lang/crates.io-index" 739 | checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" 740 | 741 | [[package]] 742 | name = "plain" 743 | version = "0.2.3" 744 | source = "registry+https://github.com/rust-lang/crates.io-index" 745 | checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" 746 | 747 | [[package]] 748 | name = "ppv-lite86" 749 | version = "0.2.8" 750 | source = "registry+https://github.com/rust-lang/crates.io-index" 751 | checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea" 752 | 753 | [[package]] 754 | name = "proc-macro2" 755 | version = "1.0.18" 756 | source = "registry+https://github.com/rust-lang/crates.io-index" 757 | checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" 758 | dependencies = [ 759 | "unicode-xid", 760 | ] 761 | 762 | [[package]] 763 | name = "proptest" 764 | version = "0.9.6" 765 | source = "registry+https://github.com/rust-lang/crates.io-index" 766 | checksum = "01c477819b845fe023d33583ebf10c9f62518c8d79a0960ba5c36d6ac8a55a5b" 767 | dependencies = [ 768 | "bit-set", 769 | "bitflags", 770 | "byteorder", 771 | "lazy_static", 772 | "num-traits", 773 | "quick-error", 774 | "rand 0.6.5", 775 | "rand_chacha 0.1.1", 776 | "rand_xorshift", 777 | "regex-syntax", 778 | "rusty-fork", 779 | "tempfile", 780 | ] 781 | 782 | [[package]] 783 | name = "quick-error" 784 | version = "1.2.3" 785 | source = "registry+https://github.com/rust-lang/crates.io-index" 786 | checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" 787 | 788 | [[package]] 789 | name = "quote" 790 | version = "1.0.7" 791 | source = "registry+https://github.com/rust-lang/crates.io-index" 792 | checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" 793 | dependencies = [ 794 | "proc-macro2", 795 | ] 796 | 797 | [[package]] 798 | name = "rand" 799 | version = "0.6.5" 800 | source = "registry+https://github.com/rust-lang/crates.io-index" 801 | checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" 802 | dependencies = [ 803 | "autocfg 0.1.7", 804 | "libc", 805 | "rand_chacha 0.1.1", 806 | "rand_core 0.4.2", 807 | "rand_hc 0.1.0", 808 | "rand_isaac", 809 | "rand_jitter", 810 | "rand_os", 811 | "rand_pcg", 812 | "rand_xorshift", 813 | "winapi", 814 | ] 815 | 816 | [[package]] 817 | name = "rand" 818 | version = "0.7.3" 819 | source = "registry+https://github.com/rust-lang/crates.io-index" 820 | checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" 821 | dependencies = [ 822 | "getrandom", 823 | "libc", 824 | "rand_chacha 0.2.2", 825 | "rand_core 0.5.1", 826 | "rand_hc 0.2.0", 827 | ] 828 | 829 | [[package]] 830 | name = "rand_chacha" 831 | version = "0.1.1" 832 | source = "registry+https://github.com/rust-lang/crates.io-index" 833 | checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" 834 | dependencies = [ 835 | "autocfg 0.1.7", 836 | "rand_core 0.3.1", 837 | ] 838 | 839 | [[package]] 840 | name = "rand_chacha" 841 | version = "0.2.2" 842 | source = "registry+https://github.com/rust-lang/crates.io-index" 843 | checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" 844 | dependencies = [ 845 | "ppv-lite86", 846 | "rand_core 0.5.1", 847 | ] 848 | 849 | [[package]] 850 | name = "rand_core" 851 | version = "0.3.1" 852 | source = "registry+https://github.com/rust-lang/crates.io-index" 853 | checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" 854 | dependencies = [ 855 | "rand_core 0.4.2", 856 | ] 857 | 858 | [[package]] 859 | name = "rand_core" 860 | version = "0.4.2" 861 | source = "registry+https://github.com/rust-lang/crates.io-index" 862 | checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" 863 | 864 | [[package]] 865 | name = "rand_core" 866 | version = "0.5.1" 867 | source = "registry+https://github.com/rust-lang/crates.io-index" 868 | checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" 869 | dependencies = [ 870 | "getrandom", 871 | ] 872 | 873 | [[package]] 874 | name = "rand_hc" 875 | version = "0.1.0" 876 | source = "registry+https://github.com/rust-lang/crates.io-index" 877 | checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" 878 | dependencies = [ 879 | "rand_core 0.3.1", 880 | ] 881 | 882 | [[package]] 883 | name = "rand_hc" 884 | version = "0.2.0" 885 | source = "registry+https://github.com/rust-lang/crates.io-index" 886 | checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" 887 | dependencies = [ 888 | "rand_core 0.5.1", 889 | ] 890 | 891 | [[package]] 892 | name = "rand_isaac" 893 | version = "0.1.1" 894 | source = "registry+https://github.com/rust-lang/crates.io-index" 895 | checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" 896 | dependencies = [ 897 | "rand_core 0.3.1", 898 | ] 899 | 900 | [[package]] 901 | name = "rand_jitter" 902 | version = "0.1.4" 903 | source = "registry+https://github.com/rust-lang/crates.io-index" 904 | checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" 905 | dependencies = [ 906 | "libc", 907 | "rand_core 0.4.2", 908 | "winapi", 909 | ] 910 | 911 | [[package]] 912 | name = "rand_os" 913 | version = "0.1.3" 914 | source = "registry+https://github.com/rust-lang/crates.io-index" 915 | checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" 916 | dependencies = [ 917 | "cloudabi", 918 | "fuchsia-cprng", 919 | "libc", 920 | "rand_core 0.4.2", 921 | "rdrand", 922 | "winapi", 923 | ] 924 | 925 | [[package]] 926 | name = "rand_pcg" 927 | version = "0.1.2" 928 | source = "registry+https://github.com/rust-lang/crates.io-index" 929 | checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" 930 | dependencies = [ 931 | "autocfg 0.1.7", 932 | "rand_core 0.4.2", 933 | ] 934 | 935 | [[package]] 936 | name = "rand_xorshift" 937 | version = "0.1.1" 938 | source = "registry+https://github.com/rust-lang/crates.io-index" 939 | checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" 940 | dependencies = [ 941 | "rand_core 0.3.1", 942 | ] 943 | 944 | [[package]] 945 | name = "raw-cpuid" 946 | version = "7.0.3" 947 | source = "registry+https://github.com/rust-lang/crates.io-index" 948 | checksum = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" 949 | dependencies = [ 950 | "bitflags", 951 | "cc", 952 | "rustc_version", 953 | ] 954 | 955 | [[package]] 956 | name = "rayon" 957 | version = "1.3.1" 958 | source = "registry+https://github.com/rust-lang/crates.io-index" 959 | checksum = "62f02856753d04e03e26929f820d0a0a337ebe71f849801eea335d464b349080" 960 | dependencies = [ 961 | "autocfg 1.0.0", 962 | "crossbeam-deque", 963 | "either", 964 | "rayon-core", 965 | ] 966 | 967 | [[package]] 968 | name = "rayon-core" 969 | version = "1.7.1" 970 | source = "registry+https://github.com/rust-lang/crates.io-index" 971 | checksum = "e92e15d89083484e11353891f1af602cc661426deb9564c298b270c726973280" 972 | dependencies = [ 973 | "crossbeam-deque", 974 | "crossbeam-queue", 975 | "crossbeam-utils", 976 | "lazy_static", 977 | "num_cpus", 978 | ] 979 | 980 | [[package]] 981 | name = "rdrand" 982 | version = "0.4.0" 983 | source = "registry+https://github.com/rust-lang/crates.io-index" 984 | checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" 985 | dependencies = [ 986 | "rand_core 0.3.1", 987 | ] 988 | 989 | [[package]] 990 | name = "redox_syscall" 991 | version = "0.1.56" 992 | source = "registry+https://github.com/rust-lang/crates.io-index" 993 | checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" 994 | 995 | [[package]] 996 | name = "redox_users" 997 | version = "0.3.4" 998 | source = "registry+https://github.com/rust-lang/crates.io-index" 999 | checksum = "09b23093265f8d200fa7b4c2c76297f47e681c655f6f1285a8780d6a022f7431" 1000 | dependencies = [ 1001 | "getrandom", 1002 | "redox_syscall", 1003 | "rust-argon2", 1004 | ] 1005 | 1006 | [[package]] 1007 | name = "regalloc" 1008 | version = "0.0.21" 1009 | source = "registry+https://github.com/rust-lang/crates.io-index" 1010 | checksum = "b27b256b41986ac5141b37b8bbba85d314fbf546c182eb255af6720e07e4f804" 1011 | dependencies = [ 1012 | "log", 1013 | "rustc-hash", 1014 | "smallvec", 1015 | ] 1016 | 1017 | [[package]] 1018 | name = "regex" 1019 | version = "1.3.9" 1020 | source = "registry+https://github.com/rust-lang/crates.io-index" 1021 | checksum = "9c3780fcf44b193bc4d09f36d2a3c87b251da4a046c87795a0d35f4f927ad8e6" 1022 | dependencies = [ 1023 | "aho-corasick", 1024 | "memchr", 1025 | "regex-syntax", 1026 | "thread_local", 1027 | ] 1028 | 1029 | [[package]] 1030 | name = "regex-syntax" 1031 | version = "0.6.18" 1032 | source = "registry+https://github.com/rust-lang/crates.io-index" 1033 | checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8" 1034 | 1035 | [[package]] 1036 | name = "region" 1037 | version = "2.2.0" 1038 | source = "registry+https://github.com/rust-lang/crates.io-index" 1039 | checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0" 1040 | dependencies = [ 1041 | "bitflags", 1042 | "libc", 1043 | "mach", 1044 | "winapi", 1045 | ] 1046 | 1047 | [[package]] 1048 | name = "remove_dir_all" 1049 | version = "0.5.3" 1050 | source = "registry+https://github.com/rust-lang/crates.io-index" 1051 | checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" 1052 | dependencies = [ 1053 | "winapi", 1054 | ] 1055 | 1056 | [[package]] 1057 | name = "rust-argon2" 1058 | version = "0.7.0" 1059 | source = "registry+https://github.com/rust-lang/crates.io-index" 1060 | checksum = "2bc8af4bda8e1ff4932523b94d3dd20ee30a87232323eda55903ffd71d2fb017" 1061 | dependencies = [ 1062 | "base64 0.11.0", 1063 | "blake2b_simd", 1064 | "constant_time_eq", 1065 | "crossbeam-utils", 1066 | ] 1067 | 1068 | [[package]] 1069 | name = "rustc-demangle" 1070 | version = "0.1.16" 1071 | source = "registry+https://github.com/rust-lang/crates.io-index" 1072 | checksum = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" 1073 | 1074 | [[package]] 1075 | name = "rustc-hash" 1076 | version = "1.1.0" 1077 | source = "registry+https://github.com/rust-lang/crates.io-index" 1078 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" 1079 | 1080 | [[package]] 1081 | name = "rustc_version" 1082 | version = "0.2.3" 1083 | source = "registry+https://github.com/rust-lang/crates.io-index" 1084 | checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 1085 | dependencies = [ 1086 | "semver", 1087 | ] 1088 | 1089 | [[package]] 1090 | name = "rusty-fork" 1091 | version = "0.2.2" 1092 | source = "registry+https://github.com/rust-lang/crates.io-index" 1093 | checksum = "3dd93264e10c577503e926bd1430193eeb5d21b059148910082245309b424fae" 1094 | dependencies = [ 1095 | "fnv", 1096 | "quick-error", 1097 | "tempfile", 1098 | "wait-timeout", 1099 | ] 1100 | 1101 | [[package]] 1102 | name = "scopeguard" 1103 | version = "1.1.0" 1104 | source = "registry+https://github.com/rust-lang/crates.io-index" 1105 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 1106 | 1107 | [[package]] 1108 | name = "scroll" 1109 | version = "0.10.1" 1110 | source = "registry+https://github.com/rust-lang/crates.io-index" 1111 | checksum = "abb2332cb595d33f7edd5700f4cbf94892e680c7f0ae56adab58a35190b66cb1" 1112 | dependencies = [ 1113 | "scroll_derive", 1114 | ] 1115 | 1116 | [[package]] 1117 | name = "scroll_derive" 1118 | version = "0.10.2" 1119 | source = "registry+https://github.com/rust-lang/crates.io-index" 1120 | checksum = "e367622f934864ffa1c704ba2b82280aab856e3d8213c84c5720257eb34b15b9" 1121 | dependencies = [ 1122 | "proc-macro2", 1123 | "quote", 1124 | "syn", 1125 | ] 1126 | 1127 | [[package]] 1128 | name = "semver" 1129 | version = "0.9.0" 1130 | source = "registry+https://github.com/rust-lang/crates.io-index" 1131 | checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 1132 | dependencies = [ 1133 | "semver-parser", 1134 | ] 1135 | 1136 | [[package]] 1137 | name = "semver-parser" 1138 | version = "0.7.0" 1139 | source = "registry+https://github.com/rust-lang/crates.io-index" 1140 | checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 1141 | 1142 | [[package]] 1143 | name = "serde" 1144 | version = "1.0.112" 1145 | source = "registry+https://github.com/rust-lang/crates.io-index" 1146 | checksum = "736aac72d1eafe8e5962d1d1c3d99b0df526015ba40915cb3c49d042e92ec243" 1147 | dependencies = [ 1148 | "serde_derive", 1149 | ] 1150 | 1151 | [[package]] 1152 | name = "serde_derive" 1153 | version = "1.0.112" 1154 | source = "registry+https://github.com/rust-lang/crates.io-index" 1155 | checksum = "bf0343ce212ac0d3d6afd9391ac8e9c9efe06b533c8d33f660f6390cc4093f57" 1156 | dependencies = [ 1157 | "proc-macro2", 1158 | "quote", 1159 | "syn", 1160 | ] 1161 | 1162 | [[package]] 1163 | name = "sha2" 1164 | version = "0.8.2" 1165 | source = "registry+https://github.com/rust-lang/crates.io-index" 1166 | checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" 1167 | dependencies = [ 1168 | "block-buffer", 1169 | "digest", 1170 | "fake-simd", 1171 | "opaque-debug", 1172 | ] 1173 | 1174 | [[package]] 1175 | name = "smallvec" 1176 | version = "1.4.0" 1177 | source = "registry+https://github.com/rust-lang/crates.io-index" 1178 | checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" 1179 | 1180 | [[package]] 1181 | name = "stable_deref_trait" 1182 | version = "1.1.1" 1183 | source = "registry+https://github.com/rust-lang/crates.io-index" 1184 | checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" 1185 | 1186 | [[package]] 1187 | name = "string-interner" 1188 | version = "0.7.1" 1189 | source = "registry+https://github.com/rust-lang/crates.io-index" 1190 | checksum = "fd710eadff449a1531351b0e43eb81ea404336fa2f56c777427ab0e32a4cf183" 1191 | dependencies = [ 1192 | "serde", 1193 | ] 1194 | 1195 | [[package]] 1196 | name = "syn" 1197 | version = "1.0.31" 1198 | source = "registry+https://github.com/rust-lang/crates.io-index" 1199 | checksum = "b5304cfdf27365b7585c25d4af91b35016ed21ef88f17ced89c7093b43dba8b6" 1200 | dependencies = [ 1201 | "proc-macro2", 1202 | "quote", 1203 | "unicode-xid", 1204 | ] 1205 | 1206 | [[package]] 1207 | name = "target-lexicon" 1208 | version = "0.10.0" 1209 | source = "registry+https://github.com/rust-lang/crates.io-index" 1210 | checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d" 1211 | 1212 | [[package]] 1213 | name = "tempfile" 1214 | version = "3.1.0" 1215 | source = "registry+https://github.com/rust-lang/crates.io-index" 1216 | checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" 1217 | dependencies = [ 1218 | "cfg-if", 1219 | "libc", 1220 | "rand 0.7.3", 1221 | "redox_syscall", 1222 | "remove_dir_all", 1223 | "winapi", 1224 | ] 1225 | 1226 | [[package]] 1227 | name = "termcolor" 1228 | version = "1.1.0" 1229 | source = "registry+https://github.com/rust-lang/crates.io-index" 1230 | checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" 1231 | dependencies = [ 1232 | "winapi-util", 1233 | ] 1234 | 1235 | [[package]] 1236 | name = "thiserror" 1237 | version = "1.0.20" 1238 | source = "registry+https://github.com/rust-lang/crates.io-index" 1239 | checksum = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" 1240 | dependencies = [ 1241 | "thiserror-impl", 1242 | ] 1243 | 1244 | [[package]] 1245 | name = "thiserror-impl" 1246 | version = "1.0.20" 1247 | source = "registry+https://github.com/rust-lang/crates.io-index" 1248 | checksum = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" 1249 | dependencies = [ 1250 | "proc-macro2", 1251 | "quote", 1252 | "syn", 1253 | ] 1254 | 1255 | [[package]] 1256 | name = "thread_local" 1257 | version = "1.0.1" 1258 | source = "registry+https://github.com/rust-lang/crates.io-index" 1259 | checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" 1260 | dependencies = [ 1261 | "lazy_static", 1262 | ] 1263 | 1264 | [[package]] 1265 | name = "toml" 1266 | version = "0.5.6" 1267 | source = "registry+https://github.com/rust-lang/crates.io-index" 1268 | checksum = "ffc92d160b1eef40665be3a05630d003936a3bc7da7421277846c2613e92c71a" 1269 | dependencies = [ 1270 | "serde", 1271 | ] 1272 | 1273 | [[package]] 1274 | name = "typenum" 1275 | version = "1.12.0" 1276 | source = "registry+https://github.com/rust-lang/crates.io-index" 1277 | checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" 1278 | 1279 | [[package]] 1280 | name = "unicode-segmentation" 1281 | version = "1.6.0" 1282 | source = "registry+https://github.com/rust-lang/crates.io-index" 1283 | checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" 1284 | 1285 | [[package]] 1286 | name = "unicode-xid" 1287 | version = "0.2.0" 1288 | source = "registry+https://github.com/rust-lang/crates.io-index" 1289 | checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" 1290 | 1291 | [[package]] 1292 | name = "wait-timeout" 1293 | version = "0.2.0" 1294 | source = "registry+https://github.com/rust-lang/crates.io-index" 1295 | checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" 1296 | dependencies = [ 1297 | "libc", 1298 | ] 1299 | 1300 | [[package]] 1301 | name = "wasi" 1302 | version = "0.9.0+wasi-snapshot-preview1" 1303 | source = "registry+https://github.com/rust-lang/crates.io-index" 1304 | checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" 1305 | 1306 | [[package]] 1307 | name = "wasi-common" 1308 | version = "0.16.0" 1309 | source = "registry+https://github.com/rust-lang/crates.io-index" 1310 | checksum = "3c36197fe20e0a0673f346064a57122ee63a10c7e4da84d014ce8e97e7dd666c" 1311 | dependencies = [ 1312 | "anyhow", 1313 | "cfg-if", 1314 | "cpu-time", 1315 | "filetime", 1316 | "getrandom", 1317 | "lazy_static", 1318 | "libc", 1319 | "log", 1320 | "thiserror", 1321 | "wig", 1322 | "wiggle 0.16.0", 1323 | "winapi", 1324 | "winx", 1325 | "yanix", 1326 | ] 1327 | 1328 | [[package]] 1329 | name = "wasm-calc" 1330 | version = "0.1.0" 1331 | dependencies = [ 1332 | "anyhow", 1333 | "proptest", 1334 | "wasi-common", 1335 | "wasmtime", 1336 | "wasmtime-wasi", 1337 | "wat", 1338 | "wig", 1339 | "wiggle 0.16.0", 1340 | "wiggle-test", 1341 | ] 1342 | 1343 | [[package]] 1344 | name = "wasmparser" 1345 | version = "0.51.4" 1346 | source = "registry+https://github.com/rust-lang/crates.io-index" 1347 | checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a" 1348 | 1349 | [[package]] 1350 | name = "wasmtime" 1351 | version = "0.16.0" 1352 | source = "registry+https://github.com/rust-lang/crates.io-index" 1353 | checksum = "b98eb07c950a0e192d7eccca1aae502c2ec6eb46e65d785e49cc2878e9962aa1" 1354 | dependencies = [ 1355 | "anyhow", 1356 | "backtrace", 1357 | "cfg-if", 1358 | "lazy_static", 1359 | "libc", 1360 | "region", 1361 | "rustc-demangle", 1362 | "target-lexicon", 1363 | "wasmparser", 1364 | "wasmtime-environ", 1365 | "wasmtime-jit", 1366 | "wasmtime-profiling", 1367 | "wasmtime-runtime", 1368 | "wat", 1369 | "winapi", 1370 | ] 1371 | 1372 | [[package]] 1373 | name = "wasmtime-debug" 1374 | version = "0.16.0" 1375 | source = "registry+https://github.com/rust-lang/crates.io-index" 1376 | checksum = "d39ba645aee700b29ff0093028b4123556dd142a74973f04ed6225eedb40e77d" 1377 | dependencies = [ 1378 | "anyhow", 1379 | "faerie", 1380 | "gimli 0.20.0", 1381 | "more-asserts", 1382 | "target-lexicon", 1383 | "thiserror", 1384 | "wasmparser", 1385 | "wasmtime-environ", 1386 | ] 1387 | 1388 | [[package]] 1389 | name = "wasmtime-environ" 1390 | version = "0.16.0" 1391 | source = "registry+https://github.com/rust-lang/crates.io-index" 1392 | checksum = "ed54fd9d64dfeeee7c285fd126174a6b5e6d4efc7e5a1566fdb635e60ff6a74e" 1393 | dependencies = [ 1394 | "anyhow", 1395 | "base64 0.12.2", 1396 | "bincode", 1397 | "cranelift-codegen", 1398 | "cranelift-entity", 1399 | "cranelift-wasm", 1400 | "directories", 1401 | "errno", 1402 | "file-per-thread-logger", 1403 | "indexmap", 1404 | "libc", 1405 | "log", 1406 | "more-asserts", 1407 | "rayon", 1408 | "serde", 1409 | "sha2", 1410 | "thiserror", 1411 | "toml", 1412 | "wasmparser", 1413 | "winapi", 1414 | "zstd", 1415 | ] 1416 | 1417 | [[package]] 1418 | name = "wasmtime-jit" 1419 | version = "0.16.0" 1420 | source = "registry+https://github.com/rust-lang/crates.io-index" 1421 | checksum = "8da8f32b1cc4c133612ff78e413213e24facb52f07748fc9f3c457b20918fa1d" 1422 | dependencies = [ 1423 | "anyhow", 1424 | "cfg-if", 1425 | "cranelift-codegen", 1426 | "cranelift-entity", 1427 | "cranelift-frontend", 1428 | "cranelift-native", 1429 | "cranelift-wasm", 1430 | "gimli 0.20.0", 1431 | "log", 1432 | "more-asserts", 1433 | "region", 1434 | "target-lexicon", 1435 | "thiserror", 1436 | "wasmparser", 1437 | "wasmtime-debug", 1438 | "wasmtime-environ", 1439 | "wasmtime-profiling", 1440 | "wasmtime-runtime", 1441 | "winapi", 1442 | ] 1443 | 1444 | [[package]] 1445 | name = "wasmtime-profiling" 1446 | version = "0.16.0" 1447 | source = "registry+https://github.com/rust-lang/crates.io-index" 1448 | checksum = "4b0b0c85eda9345e1dc260c7e3e532dd3544dc0e885b0d35aab7ceb95664fd4d" 1449 | dependencies = [ 1450 | "anyhow", 1451 | "cfg-if", 1452 | "gimli 0.20.0", 1453 | "lazy_static", 1454 | "libc", 1455 | "object 0.18.0", 1456 | "scroll", 1457 | "serde", 1458 | "target-lexicon", 1459 | "wasmtime-environ", 1460 | "wasmtime-runtime", 1461 | ] 1462 | 1463 | [[package]] 1464 | name = "wasmtime-runtime" 1465 | version = "0.16.0" 1466 | source = "registry+https://github.com/rust-lang/crates.io-index" 1467 | checksum = "460b71a4366e26e2d95ecb972d8375d5a8a0c6f0394752d2906c0d37516e0d27" 1468 | dependencies = [ 1469 | "backtrace", 1470 | "cc", 1471 | "cfg-if", 1472 | "indexmap", 1473 | "libc", 1474 | "memoffset", 1475 | "more-asserts", 1476 | "region", 1477 | "thiserror", 1478 | "wasmtime-environ", 1479 | "winapi", 1480 | ] 1481 | 1482 | [[package]] 1483 | name = "wasmtime-wasi" 1484 | version = "0.16.0" 1485 | source = "registry+https://github.com/rust-lang/crates.io-index" 1486 | checksum = "952779cb796013af3468a865e4a07added91223eac61d18d4567f8e89be29592" 1487 | dependencies = [ 1488 | "anyhow", 1489 | "log", 1490 | "wasi-common", 1491 | "wasmtime", 1492 | "wasmtime-runtime", 1493 | "wig", 1494 | "wiggle 0.16.0", 1495 | ] 1496 | 1497 | [[package]] 1498 | name = "wast" 1499 | version = "11.0.0" 1500 | source = "registry+https://github.com/rust-lang/crates.io-index" 1501 | checksum = "df4d67ba9266f4fcaf2e8a1afadc5e2a959e51aecc07b1ecbdf85a6ddaf08bde" 1502 | dependencies = [ 1503 | "leb128", 1504 | ] 1505 | 1506 | [[package]] 1507 | name = "wast" 1508 | version = "18.0.0" 1509 | source = "registry+https://github.com/rust-lang/crates.io-index" 1510 | checksum = "01b1f23531740a81f9300bd2febd397a95c76bfa4aa4bfaf4ca8b1ee3438f337" 1511 | dependencies = [ 1512 | "leb128", 1513 | ] 1514 | 1515 | [[package]] 1516 | name = "wat" 1517 | version = "1.0.19" 1518 | source = "registry+https://github.com/rust-lang/crates.io-index" 1519 | checksum = "4006d418d59293172aebfeeadb7673459dc151874a79135946ea7996b6a98515" 1520 | dependencies = [ 1521 | "wast 18.0.0", 1522 | ] 1523 | 1524 | [[package]] 1525 | name = "wig" 1526 | version = "0.16.0" 1527 | source = "registry+https://github.com/rust-lang/crates.io-index" 1528 | checksum = "81c465c26ea1bfda64b38ec24f8036dab5a46963e7952cd55694dbb6ace7597d" 1529 | dependencies = [ 1530 | "heck", 1531 | "proc-macro2", 1532 | "quote", 1533 | "witx", 1534 | ] 1535 | 1536 | [[package]] 1537 | name = "wiggle" 1538 | version = "0.15.0" 1539 | source = "registry+https://github.com/rust-lang/crates.io-index" 1540 | checksum = "2b8f2a7b5e882d8e5f5f5b3586b859b434d341e14ca608ef8d840cd1cdc3cae0" 1541 | dependencies = [ 1542 | "thiserror", 1543 | "wiggle-macro 0.15.0", 1544 | "witx", 1545 | ] 1546 | 1547 | [[package]] 1548 | name = "wiggle" 1549 | version = "0.16.0" 1550 | source = "registry+https://github.com/rust-lang/crates.io-index" 1551 | checksum = "ba87f956932fb15ce9deaca86b94cf9695ad69be12861d009b1be626d20710c5" 1552 | dependencies = [ 1553 | "thiserror", 1554 | "wiggle-macro 0.16.0", 1555 | "witx", 1556 | ] 1557 | 1558 | [[package]] 1559 | name = "wiggle-generate" 1560 | version = "0.15.0" 1561 | source = "registry+https://github.com/rust-lang/crates.io-index" 1562 | checksum = "01b366da52bffd4b3680aaf63d347c8a4abb8ea25521b0528c50646eb72cb1bc" 1563 | dependencies = [ 1564 | "anyhow", 1565 | "heck", 1566 | "proc-macro2", 1567 | "quote", 1568 | "syn", 1569 | "witx", 1570 | ] 1571 | 1572 | [[package]] 1573 | name = "wiggle-generate" 1574 | version = "0.16.0" 1575 | source = "registry+https://github.com/rust-lang/crates.io-index" 1576 | checksum = "b831c66c7f0d6f5c99feef50814a24578308ff47264dca468718977404c72ee7" 1577 | dependencies = [ 1578 | "anyhow", 1579 | "heck", 1580 | "proc-macro2", 1581 | "quote", 1582 | "syn", 1583 | "witx", 1584 | ] 1585 | 1586 | [[package]] 1587 | name = "wiggle-macro" 1588 | version = "0.15.0" 1589 | source = "registry+https://github.com/rust-lang/crates.io-index" 1590 | checksum = "f35e98cd16ad3762c033ebe0b1971268dc236c97490a8ac2ebdd1fe331748fb3" 1591 | dependencies = [ 1592 | "syn", 1593 | "wiggle-generate 0.15.0", 1594 | "witx", 1595 | ] 1596 | 1597 | [[package]] 1598 | name = "wiggle-macro" 1599 | version = "0.16.0" 1600 | source = "registry+https://github.com/rust-lang/crates.io-index" 1601 | checksum = "91be3bbcc4c3be9c3384e93230bd2785bfa8a2c510609f879c283524229124ac" 1602 | dependencies = [ 1603 | "quote", 1604 | "syn", 1605 | "wiggle-generate 0.16.0", 1606 | "witx", 1607 | ] 1608 | 1609 | [[package]] 1610 | name = "wiggle-test" 1611 | version = "0.15.0" 1612 | source = "registry+https://github.com/rust-lang/crates.io-index" 1613 | checksum = "6b5139ea91ab620705dd6dc20341dbf0395e5d449877cc9fc6fe38652bd37c8f" 1614 | dependencies = [ 1615 | "proptest", 1616 | "wiggle 0.15.0", 1617 | ] 1618 | 1619 | [[package]] 1620 | name = "winapi" 1621 | version = "0.3.8" 1622 | source = "registry+https://github.com/rust-lang/crates.io-index" 1623 | checksum = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" 1624 | dependencies = [ 1625 | "winapi-i686-pc-windows-gnu", 1626 | "winapi-x86_64-pc-windows-gnu", 1627 | ] 1628 | 1629 | [[package]] 1630 | name = "winapi-i686-pc-windows-gnu" 1631 | version = "0.4.0" 1632 | source = "registry+https://github.com/rust-lang/crates.io-index" 1633 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1634 | 1635 | [[package]] 1636 | name = "winapi-util" 1637 | version = "0.1.5" 1638 | source = "registry+https://github.com/rust-lang/crates.io-index" 1639 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 1640 | dependencies = [ 1641 | "winapi", 1642 | ] 1643 | 1644 | [[package]] 1645 | name = "winapi-x86_64-pc-windows-gnu" 1646 | version = "0.4.0" 1647 | source = "registry+https://github.com/rust-lang/crates.io-index" 1648 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1649 | 1650 | [[package]] 1651 | name = "winx" 1652 | version = "0.16.0" 1653 | source = "registry+https://github.com/rust-lang/crates.io-index" 1654 | checksum = "bd961a9c47fb866ee8289fa0917ac5e1c9c1145ec49572d7e434a69c7478d48a" 1655 | dependencies = [ 1656 | "bitflags", 1657 | "cvt", 1658 | "winapi", 1659 | ] 1660 | 1661 | [[package]] 1662 | name = "witx" 1663 | version = "0.8.5" 1664 | source = "registry+https://github.com/rust-lang/crates.io-index" 1665 | checksum = "9cae706991db0527c4b60d87d5d0600b08f62018600315fbdb4c05d7dcd98b21" 1666 | dependencies = [ 1667 | "anyhow", 1668 | "log", 1669 | "thiserror", 1670 | "wast 11.0.0", 1671 | ] 1672 | 1673 | [[package]] 1674 | name = "yanix" 1675 | version = "0.16.0" 1676 | source = "registry+https://github.com/rust-lang/crates.io-index" 1677 | checksum = "7c9b1a7c85f9dcf48fadb129461dc1e54cdf82f6a52cb7ab3b53a4a4234d056f" 1678 | dependencies = [ 1679 | "bitflags", 1680 | "cfg-if", 1681 | "filetime", 1682 | "libc", 1683 | "log", 1684 | ] 1685 | 1686 | [[package]] 1687 | name = "zstd" 1688 | version = "0.5.3+zstd.1.4.5" 1689 | source = "registry+https://github.com/rust-lang/crates.io-index" 1690 | checksum = "01b32eaf771efa709e8308605bbf9319bf485dc1503179ec0469b611937c0cd8" 1691 | dependencies = [ 1692 | "zstd-safe", 1693 | ] 1694 | 1695 | [[package]] 1696 | name = "zstd-safe" 1697 | version = "2.0.5+zstd.1.4.5" 1698 | source = "registry+https://github.com/rust-lang/crates.io-index" 1699 | checksum = "1cfb642e0d27f64729a639c52db457e0ae906e7bc6f5fe8f5c453230400f1055" 1700 | dependencies = [ 1701 | "libc", 1702 | "zstd-sys", 1703 | ] 1704 | 1705 | [[package]] 1706 | name = "zstd-sys" 1707 | version = "1.4.17+zstd.1.4.5" 1708 | source = "registry+https://github.com/rust-lang/crates.io-index" 1709 | checksum = "b89249644df056b522696b1bb9e7c18c87e8ffa3e2f0dc3b0155875d6498f01b" 1710 | dependencies = [ 1711 | "cc", 1712 | "glob", 1713 | "itertools", 1714 | "libc", 1715 | ] 1716 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "wasm-calc" 3 | version = "0.1.0" 4 | authors = ["Radu M "] 5 | edition = "2018" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | anyhow = "1.0.19" 11 | wiggle = "0.16.0" 12 | wiggle-test = "0.15.0" 13 | proptest = "0.9" 14 | wasmtime = "0.16" 15 | wasmtime-wasi = "0.16" 16 | wasi-common = "0.16" 17 | wat = "1.0.18" 18 | wig = "0.16.0" -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `wasm-calc` 2 | 3 | Simple example of using WITX for writing a simple WebAssembly API. 4 | -------------------------------------------------------------------------------- /examples/calculator.witx: -------------------------------------------------------------------------------- 1 | (use "errno.witx") 2 | 3 | ;;; Add two integers 4 | (module $calculator 5 | (@interface func (export "add") 6 | (param $lh s32) 7 | (param $rh s32) 8 | (result $error $errno) 9 | (result $res s32) 10 | ) 11 | ) 12 | -------------------------------------------------------------------------------- /examples/errno.witx: -------------------------------------------------------------------------------- 1 | (typename $errno 2 | (enum u32 3 | ;;; Success 4 | $ok 5 | ;;; Invalid argument 6 | $invalid_arg)) 7 | -------------------------------------------------------------------------------- /examples/using_add.wat: -------------------------------------------------------------------------------- 1 | (module 2 | (import "calculator" "add" (func $calc_add (param i32 i32) (result i32))) 3 | 4 | (func $consume_add (param $lhs i32) (param $rhs i32) (result i32) 5 | local.get $lhs 6 | local.get $rhs 7 | call $calc_add) 8 | (export "consume_add" (func $consume_add)) 9 | ) 10 | -------------------------------------------------------------------------------- /examples/using_add/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | [[package]] 4 | name = "using_add" 5 | version = "0.1.0" 6 | -------------------------------------------------------------------------------- /examples/using_add/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "using_add" 3 | version = "0.1.0" 4 | authors = ["Radu M "] 5 | edition = "2018" 6 | 7 | [lib] 8 | crate-type = ["cdylib"] # <-- this is the bit we need to add 9 | 10 | [dependencies] 11 | -------------------------------------------------------------------------------- /examples/using_add/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[link(wasm_import_module = "calculator")] 2 | extern "C" { 3 | fn add(lh: i32, rh: i32) -> i32; 4 | } 5 | 6 | #[no_mangle] 7 | pub unsafe extern "C" fn consume_add(lh: i32, rh: i32) -> i32 { 8 | add(lh, rh) 9 | } 10 | -------------------------------------------------------------------------------- /src/calculator.rs: -------------------------------------------------------------------------------- 1 | wiggle::from_witx!({ 2 | witx: ["examples/calculator.witx"], 3 | ctx: CalculatorCtx, 4 | }); 5 | 6 | pub struct CalculatorCtx {} 7 | 8 | impl calculator::Calculator for CalculatorCtx { 9 | fn add(&self, lh: i32, rh: i32) -> Result { 10 | Ok(lh + rh) 11 | } 12 | } 13 | 14 | impl wiggle::GuestErrorType for types::Errno { 15 | fn success() -> Self { 16 | unimplemented!() 17 | } 18 | } 19 | 20 | impl types::GuestErrorConversion for CalculatorCtx { 21 | fn into_errno(&self, _e: wiggle::GuestError) -> types::Errno { 22 | unimplemented!() 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | use anyhow::{bail, Context as _, Result}; 2 | use std::path::Path; 3 | use wasmtime::{Engine, Extern, Instance, Linker, Module, Store, Val, ValType}; 4 | use wasmtime_wasi::{old::snapshot_0::Wasi as WasiSnapshot0, Wasi}; 5 | 6 | use crate::calculator::calculator::Calculator; 7 | 8 | mod calculator; 9 | 10 | fn main() { 11 | let config = wasmtime::Config::new(); 12 | let engine = Engine::new(&config); 13 | let store = Store::new(&engine); 14 | 15 | let args: Vec = std::env::args().collect(); 16 | let path = args.get(1).unwrap(); 17 | let path = Path::new(path); 18 | let func_name = args.get(2).unwrap(); 19 | 20 | let module_registry = ModuleRegistry::new(&store).unwrap(); 21 | 22 | let instance = instantiate_module(&store, &module_registry, path).unwrap(); 23 | let x = args[3..args.len()].to_vec(); 24 | invoke_export(instance, func_name, x).unwrap() 25 | } 26 | 27 | fn instantiate_module( 28 | store: &Store, 29 | module_registry: &ModuleRegistry, 30 | path: &Path, 31 | ) -> Result { 32 | let data = wat::parse_file(path)?; 33 | let module = Module::new(store, &data)?; 34 | let mut linker = Linker::new(store); 35 | 36 | for (_, item) in module.imports().enumerate() { 37 | match item.module() { 38 | "wasi_snapshot_preview1" => { 39 | linker.define( 40 | "wasi_snapshot_preview1", 41 | item.name(), 42 | Extern::Func( 43 | module_registry 44 | .wasi_snapshot_preview1 45 | .get_export(item.name()) 46 | .unwrap() 47 | .clone(), 48 | ), 49 | )?; 50 | } 51 | "wasi_unstable" => { 52 | linker.define( 53 | "wasi_unstable", 54 | item.name(), 55 | Extern::Func( 56 | module_registry 57 | .wasi_unstable 58 | .get_export(item.name()) 59 | .unwrap() 60 | .clone(), 61 | ), 62 | )?; 63 | } 64 | _ => {} 65 | } 66 | } 67 | 68 | linker.func("calculator", "add", |x: i32, y: i32| { 69 | let ctx = calculator::CalculatorCtx {}; 70 | ctx.add(x, y).unwrap() 71 | })?; 72 | 73 | linker.instantiate(&module) 74 | } 75 | 76 | fn invoke_export(instance: Instance, name: &str, args: Vec) -> Result<()> { 77 | let func = if let Some(export) = instance.get_export(name) { 78 | if let Some(func) = export.into_func() { 79 | func 80 | } else { 81 | bail!("export of `{}` wasn't a function", name) 82 | } 83 | } else { 84 | bail!("failed to find export of `{}` in module", name) 85 | }; 86 | 87 | let mut values = Vec::new(); 88 | let mut x = args.iter(); 89 | for ty in func.ty().params() { 90 | let val = match x.next() { 91 | Some(s) => s, 92 | None => bail!("baaah"), 93 | }; 94 | values.push(match ty { 95 | ValType::I32 => Val::I32(val.parse()?), 96 | ValType::I64 => Val::I64(val.parse()?), 97 | ValType::F32 => Val::F32(val.parse()?), 98 | ValType::F64 => Val::F64(val.parse()?), 99 | t => bail!("unsupported argument type {:?}", t), 100 | }); 101 | } 102 | 103 | let results = func 104 | .call(&values) 105 | .with_context(|| format!("failed to invoke `{}`", name))?; 106 | 107 | for result in results.into_vec() { 108 | match result { 109 | Val::I32(i) => println!("{}", i), 110 | Val::I64(i) => println!("{}", i), 111 | Val::F32(f) => println!("{}", f), 112 | Val::F64(f) => println!("{}", f), 113 | Val::FuncRef(_) => println!(""), 114 | Val::AnyRef(_) => println!(""), 115 | Val::V128(i) => println!("{}", i), 116 | } 117 | } 118 | 119 | Ok(()) 120 | } 121 | 122 | struct ModuleRegistry { 123 | wasi_snapshot_preview1: Wasi, 124 | wasi_unstable: WasiSnapshot0, 125 | } 126 | 127 | impl ModuleRegistry { 128 | fn new(store: &Store) -> Result { 129 | let cx1 = wasi_common::WasiCtxBuilder::new() 130 | .inherit_stdin() 131 | .inherit_stdout() 132 | .inherit_stderr() 133 | .build()?; 134 | let cx2 = wasi_common::old::snapshot_0::WasiCtxBuilder::new() 135 | .inherit_stdin() 136 | .inherit_stdout() 137 | .inherit_stderr() 138 | .build()?; 139 | 140 | Ok(ModuleRegistry { 141 | wasi_snapshot_preview1: Wasi::new(store, cx1), 142 | wasi_unstable: WasiSnapshot0::new(store, cx2), 143 | }) 144 | } 145 | } 146 | --------------------------------------------------------------------------------