Skip to content

Commit

Permalink
feat: derive serde and schemars traits for State enum (svartalf#2)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
  • Loading branch information
KentaKariya and davidkna authored Apr 12, 2023
1 parent 79f1359 commit 487ebc2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ license = "ISC"
build = "build.rs"
rust-version = "1.56"

[features]
config-schema = ["schemars", "serde"]

[dependencies]
cfg-if = "1.0"
num-traits = { version = "0.2", default_features = false }
uom = { version = "0.33", features = ["autoconvert", "f32", "si"] }
serde = { version = "1.0.160", features = ["derive"], optional = true }
schemars = { version = "0.8.12", optional = true }

[target.'cfg(target_os = "linux")'.dependencies]
lazycell = "~1.3"
Expand Down
6 changes: 6 additions & 0 deletions src/types/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ use std::str;
/// Unknown can mean either controller returned unknown,
/// or not able to retrieve state due to some error.
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
#[cfg_attr(feature = "config-schema", derive(schemars::JsonSchema))]
#[cfg_attr(
feature = "serde",
derive(serde::Serialize, serde::Deserialize),
serde(rename_all = "lowercase")
)]
pub enum State {
Unknown,
Charging,
Expand Down

0 comments on commit 487ebc2

Please sign in to comment.