From d8c4d8fa83d1e91a780afb6368af2b2119da0271 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 2 Apr 2020 13:53:10 +0200 Subject: [PATCH] feat(interface-types) Make `serde` optional behind a feature flag. --- Cargo.toml | 9 ++++++++- src/interpreter/instructions/records.rs | 1 + src/interpreter/wasm/mod.rs | 2 ++ src/interpreter/wasm/values.rs | 4 +++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index f19b6ee..34e19c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,4 +10,11 @@ edition = "2018" [dependencies] nom = "5.1" wast = "8.0" -serde = { version = "1.0", features = ["derive"] } \ No newline at end of file + +# `serde` is useful only to simplify the users' life. It is not +# required by WIT itself, is is used to transform WIT values like +# `record`s to Rust sum types. +serde = { version = "1.0", features = ["derive"], optional = true } + +[features] +default = ["serde"] \ No newline at end of file diff --git a/src/interpreter/instructions/records.rs b/src/interpreter/instructions/records.rs index 9faebf1..9a248e8 100644 --- a/src/interpreter/instructions/records.rs +++ b/src/interpreter/instructions/records.rs @@ -214,6 +214,7 @@ mod tests { ])], ); + #[cfg(feature = "serde")] #[test] #[allow(non_snake_case, unused)] fn test_record_lift__to_rust_struct() { diff --git a/src/interpreter/wasm/mod.rs b/src/interpreter/wasm/mod.rs index 8923d2f..539e5ff 100644 --- a/src/interpreter/wasm/mod.rs +++ b/src/interpreter/wasm/mod.rs @@ -2,6 +2,8 @@ //! types, and traits —basically this is the part a runtime should //! take a look to use the `wasmer-interface-types` crate—. +#[cfg(feature = "serde")] mod serde; + pub mod structures; pub mod values; diff --git a/src/interpreter/wasm/values.rs b/src/interpreter/wasm/values.rs index 3895aa0..1ba005d 100644 --- a/src/interpreter/wasm/values.rs +++ b/src/interpreter/wasm/values.rs @@ -2,9 +2,11 @@ pub use crate::ast::{InterfaceType, RecordType}; use crate::errors::WasmValueNativeCastError; -pub use crate::interpreter::wasm::serde::*; use std::{convert::TryFrom, slice::Iter}; +#[cfg(feature = "serde")] +pub use crate::interpreter::wasm::serde::*; + /// A WIT value. #[derive(Debug, Clone, PartialEq)] pub enum InterfaceValue {