From b196dd4826c44f4cb2fd0061513009af5ed109ab Mon Sep 17 00:00:00 2001 From: Brady Fomegne Date: Sun, 3 Mar 2024 12:58:06 +0100 Subject: [PATCH] feat(preprocessor): implement the serde feature (#179) Now, we are able to serialize/deserialize the command enum. --- engine/preprocessor/Cargo.toml | 7 ++++++- engine/preprocessor/src/message.rs | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/engine/preprocessor/Cargo.toml b/engine/preprocessor/Cargo.toml index 84e8db8..b3bfb12 100644 --- a/engine/preprocessor/Cargo.toml +++ b/engine/preprocessor/Cargo.toml @@ -14,7 +14,12 @@ authors = ["Brady Fomegne "] [features] default = [] inhibit = [] +serde = ["dep:serde", "keyboard-types/serde"] [dependencies] -keyboard-types = "0.7.0" +keyboard-types = { version = "0.7.0", default-features = false } afrim-memory = { version = "0.3.2", path = "../../memory" } +serde = { version = "1.0.197", features = ["derive"], optional = true } + +[dev-dependencies] +keyboard-types = { version = "0.7.0", features = ["webdriver"] } diff --git a/engine/preprocessor/src/message.rs b/engine/preprocessor/src/message.rs index 279c7e3..b5b2416 100644 --- a/engine/preprocessor/src/message.rs +++ b/engine/preprocessor/src/message.rs @@ -2,6 +2,7 @@ /// Possible commands that can be generated by the `afrim-preprocessor`. #[derive(Clone, Debug, Eq, PartialEq)] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum Command { /// Request to commit a text. CommitText(String),