From f0c93d9423c830f9ae3d3ce69b5db93fe7ff7ac7 Mon Sep 17 00:00:00 2001 From: Valery Antopol Date: Wed, 1 Sep 2021 13:29:00 +0300 Subject: [PATCH] add VariantCount for IType and Value (#12) --- Cargo.lock | 13 ++++++++++++- crates/it-types/Cargo.toml | 4 +++- crates/it-types/src/types.rs | 4 ++-- crates/it-types/src/values.rs | 4 +++- wasmer-it/Cargo.toml | 2 +- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 087d3d7..7ce4593 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -28,11 +28,12 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" [[package]] name = "fluence-it-types" -version = "0.3.0" +version = "0.3.1" dependencies = [ "it-to-bytes", "nom", "serde", + "variant_count", "wast", ] @@ -253,6 +254,16 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" +[[package]] +name = "variant_count" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae2faf80ac463422992abf4de234731279c058aaf33171ca70277c98406b124" +dependencies = [ + "quote", + "syn", +] + [[package]] name = "version_check" version = "0.9.3" diff --git a/crates/it-types/Cargo.toml b/crates/it-types/Cargo.toml index 0c89119..41f72ad 100644 --- a/crates/it-types/Cargo.toml +++ b/crates/it-types/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "fluence-it-types" -version = "0.3.0" +version = "0.3.1" description = "Definitions of IValue and IType" authors = ["Fluence Labs"] edition = "2018" @@ -18,5 +18,7 @@ serde = { version = "1.0.118", features = ["derive", "rc"]} nom = { version = "5.1", optional = true } wast = { version = "8.0", optional = true } +variant_count = "1.1" + [features] impls = ["nom", "wast"] diff --git a/crates/it-types/src/types.rs b/crates/it-types/src/types.rs index 362cd6f..f3f1355 100644 --- a/crates/it-types/src/types.rs +++ b/crates/it-types/src/types.rs @@ -4,9 +4,9 @@ use crate::ne_vec::NEVec; use serde::Deserialize; use serde::Serialize; - +use variant_count::VariantCount; /// Represents the types supported by WIT. -#[derive(PartialEq, Eq, Debug, Clone, Hash, Serialize, Deserialize)] +#[derive(PartialEq, Eq, Debug, Clone, Hash, Serialize, Deserialize, VariantCount)] pub enum IType { /// Boolean. Boolean, diff --git a/crates/it-types/src/values.rs b/crates/it-types/src/values.rs index 2e0a237..3494a9a 100644 --- a/crates/it-types/src/values.rs +++ b/crates/it-types/src/values.rs @@ -2,8 +2,10 @@ use crate::ne_vec::NEVec; +use variant_count::VariantCount; + /// A WIT value. -#[derive(Debug, Clone, PartialEq)] +#[derive(Debug, Clone, PartialEq, VariantCount)] pub enum IValue { /// Boolean value. Boolean(bool), diff --git a/wasmer-it/Cargo.toml b/wasmer-it/Cargo.toml index 7d004e3..a7d3007 100644 --- a/wasmer-it/Cargo.toml +++ b/wasmer-it/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/wasmerio/wasmer" edition = "2018" [dependencies] -fluence-it-types = { path = "../crates/it-types", version = "0.3.0", features = ["impls"] } +fluence-it-types = { path = "../crates/it-types", version = "0.3.1", features = ["impls"] } it-to-bytes = { path = "../crates/to-bytes", version = "0.1.0" } it-lilo = { path = "../crates/it-lilo", version = "0.1.0" }