feat(style): add support to serialize and deserialize Style using serde

* Add serde as an optional dependency.
* Add feature-gated derives to Color, Modifier and Style.
pull/309/head
Florian Dehau 4 years ago
parent 0bb9b388f7
commit ac99104114

@ -2,6 +2,8 @@
## To be released
* Add feature-gated (`serde`) serialization of `Style`.
## v0.9.5 - 2020-05-21
### Bug Fixes

@ -31,6 +31,7 @@ rustbox = { version = "0.11", optional = true }
crossterm = { version = "0.17", optional = true }
easycurses = { version = "0.12.2", optional = true }
pancurses = { version = "0.16.1", optional = true, features = ["win32a"] }
serde = { version = "1", "optional" = true, features = ["derive"]}
[dev-dependencies]
rand = "0.7"

@ -1,6 +1,7 @@
use bitflags::bitflags;
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Color {
Reset,
Black,
@ -24,6 +25,7 @@ pub enum Color {
}
bitflags! {
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Modifier: u16 {
const BOLD = 0b0000_0000_0001;
const DIM = 0b0000_0000_0010;
@ -38,6 +40,7 @@ bitflags! {
}
#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Style {
pub fg: Color,
pub bg: Color,

Loading…
Cancel
Save