Added feature flag

changed field name to size
This commit is contained in:
ccgauche 2021-01-08 08:48:30 +00:00 committed by Joshua Barretto
parent 17be17834e
commit 06ffe61219
9 changed files with 444 additions and 302 deletions

485
Cargo.lock generated
View File

@ -22,7 +22,7 @@ version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b6a2d3371669ab3ca9797670853d61402b03d0b4b9ebf33d677dfa720203072"
dependencies = [
"gimli 0.22.0",
"gimli",
]
[[package]]
@ -358,7 +358,7 @@ dependencies = [
"cfg-if 0.1.10",
"libc",
"miniz_oxide 0.4.2",
"object",
"object 0.20.0",
"rustc-demangle",
]
@ -448,21 +448,6 @@ dependencies = [
"constant_time_eq",
]
[[package]]
name = "blake3"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9ff35b701f3914bdb8fad3368d822c766ef2858b2583198e41639b936f09d3f"
dependencies = [
"arrayref",
"arrayvec",
"cc",
"cfg-if 0.1.10",
"constant_time_eq",
"crypto-mac",
"digest 0.9.0",
]
[[package]]
name = "block"
version = "0.1.6"
@ -1041,36 +1026,37 @@ dependencies = [
[[package]]
name = "cranelift-bforest"
version = "0.59.0"
version = "0.68.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45a9c21f8042b9857bda93f6c1910b9f9f24100187a3d3d52f214a34e3dc5818"
checksum = "9221545c0507dc08a62b2d8b5ffe8e17ac580b0a74d1813b496b8d70b070fbd0"
dependencies = [
"cranelift-entity",
]
[[package]]
name = "cranelift-codegen"
version = "0.59.0"
version = "0.68.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7853f77a6e4a33c67a69c40f5e1bb982bd2dc5c4a22e17e67b65bbccf9b33b2e"
checksum = "7e9936ea608b6cd176f107037f6adbb4deac933466fc7231154f96598b2d3ab1"
dependencies = [
"byteorder",
"cranelift-bforest",
"cranelift-codegen-meta",
"cranelift-codegen-shared",
"cranelift-entity",
"gimli 0.20.0",
"gimli",
"log",
"smallvec 1.4.2",
"regalloc",
"smallvec 1.5.1",
"target-lexicon",
"thiserror",
]
[[package]]
name = "cranelift-codegen-meta"
version = "0.59.0"
version = "0.68.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "084cd6d5fb0d1da28acd72c199471bfb09acc703ec8f3bf07b1699584272a3b9"
checksum = "4ef2b2768568306540f4c8db3acce9105534d34c4a1e440529c1e702d7f8c8d7"
dependencies = [
"cranelift-codegen-shared",
"cranelift-entity",
@ -1078,24 +1064,28 @@ dependencies = [
[[package]]
name = "cranelift-codegen-shared"
version = "0.59.0"
version = "0.68.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "701b599783305a58c25027a4d73f2d6b599b2d8ef3f26677275f480b4d51e05d"
checksum = "6759012d6d19c4caec95793f052613e9d4113e925e7f14154defbac0f1d4c938"
[[package]]
name = "cranelift-entity"
version = "0.59.0"
version = "0.68.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b88e792b28e1ebbc0187b72ba5ba880dad083abe9231a99d19604d10c9e73f38"
checksum = "86badbce14e15f52a45b666b38abe47b204969dd7f8fb7488cb55dd46b361fa6"
dependencies = [
"serde",
]
[[package]]
name = "cranelift-native"
version = "0.59.0"
name = "cranelift-frontend"
version = "0.68.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32daf082da21c0c05d93394ff4842c2ab7c4991b1f3186a1d952f8ac660edd0b"
checksum = "b608bb7656c554d0a4cf8f50c7a10b857e80306f6ff829ad6d468a7e2323c8d8"
dependencies = [
"cranelift-codegen",
"raw-cpuid",
"log",
"smallvec 1.5.1",
"target-lexicon",
]
@ -1220,7 +1210,7 @@ dependencies = [
"crossbeam-utils 0.7.2",
"lazy_static",
"maybe-uninit",
"memoffset",
"memoffset 0.5.6",
"scopeguard",
]
@ -1234,7 +1224,7 @@ dependencies = [
"const_fn",
"crossbeam-utils 0.8.1",
"lazy_static",
"memoffset",
"memoffset 0.5.6",
"scopeguard",
]
@ -1332,16 +1322,6 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "crypto-mac"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab"
dependencies = [
"generic-array 0.14.4",
"subtle",
]
[[package]]
name = "csv"
version = "1.1.3"
@ -1494,24 +1474,6 @@ dependencies = [
"migrations_macros",
]
[[package]]
name = "digest"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
dependencies = [
"generic-array 0.12.3",
]
[[package]]
name = "digest"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
dependencies = [
"generic-array 0.14.4",
]
[[package]]
name = "directories-next"
version = "2.0.0"
@ -1656,24 +1618,25 @@ dependencies = [
]
[[package]]
name = "errno"
version = "0.2.7"
name = "enumset"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe"
checksum = "959a80a2062fedd66ed41d99736212de987b3a8c83a4c2cef243968075256bd1"
dependencies = [
"errno-dragonfly",
"libc",
"winapi 0.3.9",
"enumset_derive",
"num-traits 0.2.14",
]
[[package]]
name = "errno-dragonfly"
version = "0.1.1"
name = "enumset_derive"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067"
checksum = "74bef436ac71820c5cf768d7af9ba33121246b09a00e09a55d94ef8095a875ac"
dependencies = [
"gcc",
"libc",
"darling",
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.54",
]
[[package]]
@ -1713,6 +1676,12 @@ dependencies = [
"num-traits 0.2.14",
]
[[package]]
name = "fallible-iterator"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"
[[package]]
name = "fehler"
version = "1.0.0"
@ -1990,12 +1959,6 @@ dependencies = [
"byteorder",
]
[[package]]
name = "gcc"
version = "0.3.55"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
[[package]]
name = "generic-array"
version = "0.12.3"
@ -2122,21 +2085,16 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "gimli"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81dd6190aad0f05ddbbf3245c54ed14ca4aa6dd32f22312b70d8f168c3e3e633"
dependencies = [
"byteorder",
"indexmap",
]
[[package]]
name = "gimli"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aaf91faf136cb47367fa430cd46e37a788775e7fa104f8b4bcb3861dc389b724"
dependencies = [
"fallible-iterator",
"indexmap",
"stable_deref_trait",
]
[[package]]
name = "git2"
@ -2417,12 +2375,6 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
[[package]]
name = "hex"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "644f9158b2f133fd50f5fb3242878846d9eb792e445c893805ff0e3824006e35"
[[package]]
name = "hibitset"
version = "0.6.3"
@ -2897,6 +2849,12 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "leb128"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3576a87f2ba00f6f106fdfcd16db1d698d648a26ad8e0573cad8537c3c362d2a"
[[package]]
name = "lewton"
version = "0.10.1"
@ -3132,6 +3090,15 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "memmap2"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b70ca2a6103ac8b665dc150b142ef0e4e89df640c9e6cf295d189c3caebe5a"
dependencies = [
"libc",
]
[[package]]
name = "memoffset"
version = "0.5.6"
@ -3141,6 +3108,15 @@ dependencies = [
"autocfg 1.0.1",
]
[[package]]
name = "memoffset"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "157b4208e3059a8f9e78d559edc658e13df41410cb3ae03979c83130067fdd87"
dependencies = [
"autocfg 1.0.1",
]
[[package]]
name = "migrations_internals"
version = "1.4.1"
@ -3300,6 +3276,12 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a785740271256c230f57462d3b83e52f998433a7062fc18f96d5999474a9f915"
[[package]]
name = "more-asserts"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0debeb9fcf88823ea64d64e4a815ab1643f33127d995978e099942ce38f25238"
[[package]]
name = "native-dialog"
version = "0.4.3"
@ -3705,6 +3687,16 @@ version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ab52be62400ca80aa00285d25253d7f7c437b7375c4de678f5405d3afe82ca5"
[[package]]
name = "object"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d3b63360ec3cb337817c2dbd47ab4a0f170d285d8e5a2064600f3def1402397"
dependencies = [
"crc32fast",
"indexmap",
]
[[package]]
name = "oboe"
version = "0.3.0"
@ -3855,16 +3847,6 @@ dependencies = [
"libm",
]
[[package]]
name = "page_size"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eebde548fbbf1ea81a99b128872779c437752fb99f217c45245e1a61dcd9edcd"
dependencies = [
"libc",
"winapi 0.3.9",
]
[[package]]
name = "parking_lot"
version = "0.9.0"
@ -3922,7 +3904,7 @@ dependencies = [
"cloudabi 0.0.3",
"libc",
"redox_syscall",
"smallvec 1.4.2",
"smallvec 1.5.1",
"winapi 0.3.9",
]
@ -3937,7 +3919,7 @@ dependencies = [
"instant",
"libc",
"redox_syscall",
"smallvec 1.4.2",
"smallvec 1.5.1",
"winapi 0.3.9",
]
@ -4442,6 +4424,17 @@ dependencies = [
"rust-argon2",
]
[[package]]
name = "regalloc"
version = "0.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "571f7f397d61c4755285cd37853fe8e03271c243424a907415909379659381c5"
dependencies = [
"log",
"rustc-hash",
"smallvec 1.5.1",
]
[[package]]
name = "regex"
version = "1.3.9"
@ -4470,6 +4463,18 @@ version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26412eb97c6b088a6997e05f69403a802a92d520de2f8e63c2b65f9e0f47c4e8"
[[package]]
name = "region"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877e54ea2adcd70d80e9179344c97f93ef0dffd6b03e1f4529e6e83ab2fa9ae0"
dependencies = [
"bitflags",
"libc",
"mach 0.3.2",
"winapi 0.3.9",
]
[[package]]
name = "remove_dir_all"
version = "0.5.3"
@ -4769,16 +4774,6 @@ dependencies = [
"serde_derive",
]
[[package]]
name = "serde-bench"
version = "0.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d733da87e79faaac25616e33d26299a41143fd4cd42746cbb0e91d8feea243fd"
dependencies = [
"byteorder",
"serde",
]
[[package]]
name = "serde_bytes"
version = "0.11.5"
@ -4906,7 +4901,7 @@ dependencies = [
"mopa",
"rayon",
"shred-derive",
"smallvec 1.4.2",
"smallvec 1.5.1",
"tynm",
]
@ -4984,9 +4979,9 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.4.2"
version = "1.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252"
checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75"
[[package]]
name = "smithay-client-toolkit"
@ -5227,12 +5222,6 @@ dependencies = [
"syn 1.0.54",
]
[[package]]
name = "subtle"
version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "343f3f510c2915908f155e94f17220b19ccfacf2a64a2a5d8004f2c3e311e7fd"
[[package]]
name = "sum_type"
version = "0.2.0"
@ -5293,9 +5282,9 @@ dependencies = [
[[package]]
name = "target-lexicon"
version = "0.10.0"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab0e7238dcc7b40a7be719a25365910f6807bd864f4cce6b2e6b873658e2b19d"
checksum = "4ee5a98e506fb7231a304c3a1bd7c132a55016cf65001e0282480665870dfcb9"
[[package]]
name = "tempfile"
@ -5687,7 +5676,7 @@ dependencies = [
"matchers",
"regex",
"sharded-slab",
"smallvec 1.4.2",
"smallvec 1.5.1",
"thread_local",
"tracing-core",
"tracing-log",
@ -6067,7 +6056,7 @@ dependencies = [
"veloren-common",
"veloren-common-net",
"veloren-plugin-api",
"wasmer-runtime",
"wasmer",
]
[[package]]
@ -6432,117 +6421,203 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d649a3145108d7d3fbcde896a468d1bd636791823c9921135218ad89be08307"
[[package]]
name = "wasmer-clif-backend"
version = "0.17.1"
name = "wasmer"
version = "1.0.0-beta2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a2fae69b1c7429316cad6743f3d2ca83cf8957924c477c5a4eff036ec0097a9"
checksum = "51f8c17f314d1c2f07be241764c2e2366aacd9c0943fa0e9ee4b3615fb8f2e21"
dependencies = [
"cfg-if 0.1.10",
"indexmap",
"more-asserts",
"target-lexicon",
"thiserror",
"wasmer-compiler",
"wasmer-compiler-cranelift",
"wasmer-derive",
"wasmer-engine",
"wasmer-engine-jit",
"wasmer-engine-native",
"wasmer-types",
"wasmer-vm",
"wat",
"winapi 0.3.9",
]
[[package]]
name = "wasmer-compiler"
version = "1.0.0-beta2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cb143e05edc0bdf0ef5710897b09323768c21871d8f378031110be5e7c5b513"
dependencies = [
"enumset",
"raw-cpuid",
"serde",
"serde_bytes",
"smallvec 1.5.1",
"target-lexicon",
"thiserror",
"wasmer-types",
"wasmer-vm",
"wasmparser",
]
[[package]]
name = "wasmer-compiler-cranelift"
version = "1.0.0-beta2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f295786fc5dcc574fa1521d9f396ef4fb3f5c9ad11eb2c47861be7c9a57bcaf"
dependencies = [
"byteorder",
"cranelift-codegen",
"cranelift-entity",
"cranelift-native",
"libc",
"nix 0.15.0",
"cranelift-frontend",
"gimli",
"more-asserts",
"rayon",
"serde",
"serde-bench",
"serde_bytes",
"serde_derive",
"target-lexicon",
"wasmer-clif-fork-frontend",
"wasmer-clif-fork-wasm",
"wasmer-runtime-core",
"wasmer-win-exception-handler",
"wasmparser",
"winapi 0.3.9",
"smallvec 1.5.1",
"tracing",
"wasmer-compiler",
"wasmer-types",
"wasmer-vm",
]
[[package]]
name = "wasmer-clif-fork-frontend"
version = "0.59.0"
name = "wasmer-derive"
version = "1.0.0-beta2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c23f2824f354a00a77e4b040eef6e1d4c595a8a3e9013bad65199cc8dade9a5a"
checksum = "8aacff588e9d9c006f898342eb4e1677fe07da499bb04fa41f9323a117a2d1e2"
dependencies = [
"cranelift-codegen",
"log",
"smallvec 1.4.2",
"target-lexicon",
"proc-macro-error",
"proc-macro2 1.0.24",
"quote 1.0.7",
"syn 1.0.54",
]
[[package]]
name = "wasmer-clif-fork-wasm"
version = "0.59.0"
name = "wasmer-engine"
version = "1.0.0-beta2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a35e21d3aebc51cc6ebc0e830cf8458a9891c3482fb3c65ad18d408102929ae5"
dependencies = [
"cranelift-codegen",
"cranelift-entity",
"log",
"thiserror",
"wasmer-clif-fork-frontend",
"wasmparser",
]
[[package]]
name = "wasmer-runtime"
version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c92a9ae96b193c35c47fc829265198322cf980edc353a9de32bc87a1545d44f3"
checksum = "f88852ba7447d595d00f6d695cd0c5c6e47c46bfdbf4d67d0ea82a76be41ce18"
dependencies = [
"backtrace",
"bincode",
"lazy_static",
"memmap",
"memmap2",
"more-asserts",
"rustc-demangle",
"serde",
"serde_derive",
"wasmer-clif-backend",
"wasmer-runtime-core",
"serde_bytes",
"target-lexicon",
"thiserror",
"wasmer-compiler",
"wasmer-types",
"wasmer-vm",
]
[[package]]
name = "wasmer-runtime-core"
version = "0.17.1"
name = "wasmer-engine-jit"
version = "1.0.0-beta2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "740161245998752cf1a567e860fd6355df0336fedca6be1940ec7aaa59643220"
checksum = "fa4634a6e6cf62104c5842aebd16bcffc5c695f19d8f0bf78c276fe01cca517e"
dependencies = [
"bincode",
"blake3",
"cc",
"digest 0.8.1",
"errno",
"hex 0.4.2",
"indexmap",
"lazy_static",
"libc",
"nix 0.15.0",
"page_size",
"parking_lot 0.10.2",
"rustc_version",
"cfg-if 0.1.10",
"region",
"serde",
"serde-bench",
"serde_bytes",
"serde_derive",
"smallvec 1.4.2",
"target-lexicon",
"wasmparser",
"wasmer-compiler",
"wasmer-engine",
"wasmer-types",
"wasmer-vm",
"winapi 0.3.9",
]
[[package]]
name = "wasmer-win-exception-handler"
version = "0.17.1"
name = "wasmer-engine-native"
version = "1.0.0-beta2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1cd39f3b2bd7964b28ea6f944a7eaa445cfbc91c4f2695d188103f2689bb37d9"
checksum = "e19ceed45b9a4f5c5b113e320f6bb5c01fc007e05a4eac3eaf08e4763dfbbdf4"
dependencies = [
"bincode",
"cfg-if 0.1.10",
"leb128",
"libloading 0.6.3",
"serde",
"tempfile",
"tracing",
"wasmer-compiler",
"wasmer-engine",
"wasmer-object",
"wasmer-types",
"wasmer-vm",
"which",
]
[[package]]
name = "wasmer-object"
version = "1.0.0-beta2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abdd0bc02ec5194847d9ebbb9507f61fdfe35c04704ab4b2d80d86388adbad8c"
dependencies = [
"object 0.22.0",
"thiserror",
"wasmer-compiler",
"wasmer-types",
]
[[package]]
name = "wasmer-types"
version = "1.0.0-beta2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9f903d7213db728674dbdc883140f24779467820e3c5d812d3afb2887ed4797"
dependencies = [
"cranelift-entity",
"serde",
"thiserror",
]
[[package]]
name = "wasmer-vm"
version = "1.0.0-beta2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97ba5391d3f01e18ee610209f653bffe472b25213bb033e173d55aa12b38b645"
dependencies = [
"backtrace",
"cc",
"cfg-if 0.1.10",
"indexmap",
"libc",
"wasmer-runtime-core",
"memoffset 0.6.1",
"more-asserts",
"region",
"serde",
"thiserror",
"wasmer-types",
"winapi 0.3.9",
]
[[package]]
name = "wasmparser"
version = "0.51.4"
version = "0.65.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aeb1956b19469d1c5e63e459d29e7b5aa0f558d9f16fcef09736f8a265e6c10a"
checksum = "87cc2fe6350834b4e528ba0901e7aa405d78b89dc1fa3145359eb4de0e323fcf"
[[package]]
name = "wast"
version = "30.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b79907b22f740634810e882d8d1d9d0f9563095a8ab94e786e370242bff5cd2"
dependencies = [
"leb128",
]
[[package]]
name = "wat"
version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8279a02835bf12e61ed2b3c3cbc6ecf9918762fd97e036917c11a09ec20ca44"
dependencies = [
"wast",
]
[[package]]
name = "wayland-client"
@ -6584,7 +6659,7 @@ checksum = "e972e9336ad5a9dd861b4e21ff35ad71d3e5c6b4803d65c39913612f851b95f1"
dependencies = [
"nix 0.17.0",
"once_cell",
"smallvec 1.4.2",
"smallvec 1.5.1",
"wayland-sys 0.27.0",
]
@ -6596,7 +6671,7 @@ checksum = "7602d75560fe6f02cac723609cce658042fe60541b5107999818d29d4dab7cfa"
dependencies = [
"nix 0.18.0",
"once_cell",
"smallvec 1.4.2",
"smallvec 1.5.1",
"wayland-sys 0.28.1",
]

View File

@ -7,7 +7,7 @@ version = "0.8.0"
[features]
tracy = ["tracy-client"]
simd = ["vek/platform_intrinsics"]
plugins = ["toml", "tar", "wasmer-runtime", "bincode", "plugin-api"]
plugins = ["toml", "tar", "wasmer", "bincode", "plugin-api"]
default = ["simd"]
@ -37,6 +37,6 @@ tracy-client = { version = "0.10.0", optional = true }
# Plugins
toml = { version = "0.5.7", optional = true }
tar = { version = "0.4.30", optional = true }
wasmer-runtime = { version = "0.17.1", optional = true }
wasmer = { version = "1.0.0-beta2", optional = true, default-features = false, features = ["wat", "default-cranelift", "default-jit"] }
bincode = { version = "1.3.1", optional = true }
plugin-api = { package = "veloren-plugin-api", path = "../../plugin/api", optional = true }

View File

@ -1,28 +1,30 @@
use bincode::ErrorKind;
use wasmer_runtime::error::{ResolveError, RuntimeError};
use wasmer::{ExportError, InstantiationError, RuntimeError};
#[allow(clippy::large_enum_variant)]
#[derive(Debug)]
pub enum PluginError {
Io(std::io::Error),
Toml(toml::de::Error),
NoConfig,
NoSuchModule,
PluginModuleError(PluginModuleError),
Encoding(Box<ErrorKind>),
PluginModuleError(String, String, PluginModuleError),
}
#[derive(Debug)]
pub enum PluginModuleError {
FindFunction(String),
FunctionGet(ResolveError),
Compile(wasmer_runtime::error::CompileError),
Instantiate(wasmer_runtime::error::Error),
InstantiationError(InstantiationError),
MemoryAllocation(MemoryAllocationError),
MemoryUninit(ExportError),
FindFunction(ExportError),
RunFunction(RuntimeError),
InvalidArgumentType(),
Encoding(Box<ErrorKind>),
}
#[derive(Debug)]
pub enum MemoryAllocationError {
AllocatorNotFound(ResolveError),
AllocatorNotFound(ExportError),
CantAllocate(RuntimeError),
}

View File

@ -65,7 +65,9 @@ impl Plugin {
.iter()
.map(|path| {
let wasm_data = files.remove(path).ok_or(PluginError::NoSuchModule)?;
PluginModule::new(&wasm_data).map_err(PluginError::PluginModuleError)
PluginModule::new(data.name.to_owned(), &wasm_data).map_err(|e| {
PluginError::PluginModuleError(data.name.to_owned(), "<init>".to_owned(), e)
})
})
.collect::<Result<_, _>>()?;
@ -87,9 +89,15 @@ impl Plugin {
self.modules
.iter()
.flat_map(|module| {
module
.try_execute(event_name, event)
.map(|x| x.map_err(PluginError::PluginModuleError))
module.try_execute(event_name, event).map(|x| {
x.map_err(|e| {
PluginError::PluginModuleError(
self.data.name.to_owned(),
event_name.to_owned(),
e,
)
})
})
})
.collect::<Result<Vec<_>, _>>()
}

View File

@ -5,34 +5,75 @@ use std::{
sync::{Arc, Mutex},
};
use error::RuntimeError;
use wasmer_runtime::*;
use wasmer::{
imports, Cranelift, Function, HostEnvInitError, Instance, LazyInit, Memory, MemoryView, Module,
Store, Value, WasmerEnv, JIT,
};
use super::errors::{MemoryAllocationError, PluginError, PluginModuleError};
use plugin_api::{Action, Event};
// This represent a WASM function interface
pub type Function<'a> = Func<'a, (i32, u32), i32>;
use plugin_api::{Action, Event};
#[derive(Clone)]
// This structure represent the WASM State of the plugin.
pub struct PluginModule {
wasm_state: Arc<Mutex<WasmState>>,
events: HashSet<String>,
name: String,
}
impl PluginModule {
// This function takes bytes from a WASM File and compile them
pub fn new(wasm_data: &[u8]) -> Result<Self, PluginModuleError> {
let module = compile(&wasm_data).map_err(PluginModuleError::Compile)?;
let instance = module
.instantiate(&imports! {"env" => {
"raw_emit_actions" => func!(read_action),
}})
.map_err(PluginModuleError::Instantiate)?;
pub fn new(name: String, wasm_data: &[u8]) -> Result<Self, PluginModuleError> {
// This is creating the engine is this case a JIT based on Cranelift
let engine = JIT::new(Cranelift::default()).engine();
// We are creating an enironnement
let store = Store::new(&engine);
// We are compiling the WASM file in the previously generated environement
let module = Module::new(&store, &wasm_data).expect("Can't compile");
// This is the function imported into the wasm environement
fn raw_emit_actions(env: &EmitActionEnv, ptr: u32, len: u32) {
let memory: &Memory = if let Some(e) = env.memory.get_ref() {
e
} else {
// This should not be possible but I prefer be safer!
tracing::error!("Can't get memory from: `{}` plugin", env.name);
return;
};
let memory: MemoryView<u8> = memory.view();
let str_slice = &memory[ptr as usize..(ptr + len) as usize];
let bytes: Vec<u8> = str_slice.iter().map(|x| x.get()).collect();
handle_actions(match bincode::deserialize(&bytes) {
Ok(e) => e,
Err(e) => {
tracing::error!(?e, "Can't decode action");
return;
},
});
}
// Create an import object.
let import_object = imports! {
"env" => {
"raw_emit_actions" => Function::new_native_with_env(&store, EmitActionEnv::new(name.clone()), raw_emit_actions),
}
};
// Create an instance (Code execution environement)
let instance = Instance::new(&module, &import_object)
.map_err(PluginModuleError::InstantiationError)?;
Ok(Self {
events: instance.exports.into_iter().map(|(name, _)| name).collect(),
events: instance
.exports
.iter()
.map(|(name, _)| name.to_string())
.collect(),
wasm_state: Arc::new(Mutex::new(WasmState::new(instance))),
name,
})
}
@ -51,9 +92,7 @@ impl PluginModule {
}
let bytes = {
let mut state = self.wasm_state.lock().unwrap();
match execute_raw(&mut state, event_name, &request.bytes)
.map_err(PluginModuleError::RunFunction)
{
match execute_raw(&mut state, event_name, &request.bytes) {
Ok(e) => e,
Err(e) => return Some(Err(e)),
}
@ -62,6 +101,31 @@ impl PluginModule {
}
}
/// This is an internal struct used to represent the WASM state when the
/// emit_action function is called
#[derive(Clone)]
struct EmitActionEnv {
memory: LazyInit<Memory>,
name: String,
}
impl EmitActionEnv {
fn new(name: String) -> Self {
Self {
memory: LazyInit::new(),
name,
}
}
}
impl WasmerEnv for EmitActionEnv {
fn init_with_instance(&mut self, instance: &Instance) -> Result<(), HostEnvInitError> {
let memory = instance.exports.get_memory("memory").unwrap();
self.memory.initialize(memory.clone());
Ok(())
}
}
pub struct WasmMemoryContext {
memory_buffer_size: usize,
memory_pointer: i32,
@ -99,8 +163,7 @@ impl<T: Event> PreparedEventQuery<T> {
T: Event,
{
Ok(Self {
bytes: bincode::serialize(&event)
.map_err(|e| PluginError::PluginModuleError(PluginModuleError::Encoding(e)))?,
bytes: bincode::serialize(&event).map_err(PluginError::Encoding)?,
_phantom: PhantomData::default(),
})
}
@ -110,62 +173,75 @@ impl<T: Event> PreparedEventQuery<T> {
// an interface to limit unsafe behaviours
#[allow(clippy::needless_range_loop)]
fn execute_raw(
context: &mut WasmState,
instance: &mut WasmState,
event_name: &str,
bytes: &[u8],
) -> Result<Vec<u8>, RuntimeError> {
// This reserves space for the buffer
) -> Result<Vec<u8>, PluginModuleError> {
let len = bytes.len();
let start = {
let memory_pos = reserve_wasm_memory_buffer(len, &context.instance, &mut context.memory)
.expect("Fatal error while allocating memory for a plugin! Closing server...")
as usize;
let function: Func<(i32, u32), i32> = context
.instance
.exports
.get(event_name)
.expect("Function not found this should never happen");
let memory = context.instance.context().memory(0);
let view = memory.view::<u8>();
for (cell, byte) in view[memory_pos..memory_pos + len].iter().zip(bytes.iter()) {
cell.set(*byte)
}
function.call(memory_pos as i32, len as u32)? as usize
};
let mem_position = reserve_wasm_memory_buffer(len, &instance.instance, &mut instance.memory)
.map_err(PluginModuleError::MemoryAllocation)? as usize;
let memory = instance
.instance
.exports
.get_memory("memory")
.map_err(PluginModuleError::MemoryUninit)?;
memory.view()[mem_position..mem_position + len]
.iter()
.zip(bytes.iter())
.for_each(|(cell, byte)| cell.set(*byte));
let func = instance
.instance
.exports
.get_function(event_name)
.map_err(PluginModuleError::MemoryUninit)?;
let mem_position = func
.call(&[Value::I32(mem_position as i32), Value::I32(len as i32)])
.map_err(PluginModuleError::RunFunction)?[0]
.i32()
.ok_or_else(PluginModuleError::InvalidArgumentType)? as usize;
let view: MemoryView<u8> = memory.view();
let memory = context.instance.context().memory(0);
let view = memory.view::<u8>();
let mut new_len_bytes = [0u8; 4];
// TODO: It is probably better to dirrectly make the new_len_bytes
for i in 0..4 {
new_len_bytes[i] = view.get(i + 1).map(Cell::get).unwrap_or(0);
}
let new_len = u32::from_ne_bytes(new_len_bytes) as usize;
Ok(view[start..start + new_len]
let len = u32::from_ne_bytes(new_len_bytes) as usize;
Ok(view[mem_position..mem_position + len]
.iter()
.map(|c| c.get())
.map(|x| x.get())
.collect())
}
pub fn read_action(ctx: &mut Ctx, ptr: u32, len: u32) {
let memory = ctx.memory(0);
fn reserve_wasm_memory_buffer(
size: usize,
instance: &Instance,
context: &mut WasmMemoryContext,
) -> Result<i32, MemoryAllocationError> {
if context.memory_buffer_size >= size {
return Ok(context.memory_pointer);
}
let pointer = instance
.exports
.get_function("wasm_prepare_buffer")
.map_err(MemoryAllocationError::AllocatorNotFound)?
.call(&[Value::I32(size as i32)])
.map_err(MemoryAllocationError::CantAllocate)?;
context.memory_buffer_size = size;
context.memory_pointer = pointer[0].i32().unwrap();
Ok(context.memory_pointer)
}
let memory = memory.view::<u8>();
let str_slice = &memory[ptr as usize..(ptr + len) as usize];
let bytes: Vec<u8> = str_slice.iter().map(|x| x.get()).collect();
let e: Vec<Action> = match bincode::deserialize(&bytes) {
Ok(e) => e,
Err(e) => {
tracing::error!(?e, "Can't decode action");
return;
},
};
for action in e {
fn handle_actions(actions: Vec<Action>) {
for action in actions {
match action {
Action::ServerClose => {
tracing::info!("Server closed by plugin");
@ -183,22 +259,3 @@ pub fn read_action(ctx: &mut Ctx, ptr: u32, len: u32) {
}
}
}
fn reserve_wasm_memory_buffer<'a>(
value: usize,
instance: &'a Instance,
context: &mut WasmMemoryContext,
) -> Result<i32, MemoryAllocationError> {
if context.memory_buffer_size >= value {
return Ok(context.memory_pointer);
}
let pointer = instance
.exports
.get::<Func<'a, i32, i32>>("wasm_prepare_buffer")
.map_err(MemoryAllocationError::AllocatorNotFound)?
.call(value as i32)
.map_err(MemoryAllocationError::CantAllocate)?;
context.memory_buffer_size = value;
context.memory_pointer = pointer;
Ok(pointer)
}

View File

@ -207,13 +207,13 @@ impl State {
}
},
Err(_) => {
info!("Error occurred when loading plugins. Running without plugins instead.");
tracing::info!(
"Error occurred when loading plugins. Running without plugins instead."
);
PluginMgr::default()
},
});
//manager.execute_event("on_load", &);
ecs
}

View File

@ -9,7 +9,7 @@ worldgen = []
simd = ["vek/platform_intrinsics"]
plugins = ["common-sys/plugins"]
default = ["worldgen", "simd"]
default = ["worldgen", "plugins", "simd"]
[dependencies]
common = { package = "veloren-common", path = "../common" }

View File

@ -1052,7 +1052,7 @@ impl Server {
self.notify_client(
entity,
ServerGeneral::server_msg(
ChatType::CommandInfo,
comp::ChatType::CommandInfo,
e.join("\n"),
),
);

View File

@ -17,7 +17,7 @@ simd = ["vek/platform_intrinsics"]
tracy = ["tracing-tracy", "common/tracy"]
plugins = ["client/plugins"]
default = ["gl", "singleplayer", "native-dialog", "simd"]
default = ["gl", "singleplayer", "native-dialog", "plugins", "simd"]
[dependencies]
client = {package = "veloren-client", path = "../client"}