use redgold::structs::HashType;
use std::str::FromStr;
use strum_macros::EnumString;
#[derive(Debug, PartialEq, EnumString)]
enum Color {
Red,
Green {
range: usize,
},
#[strum(serialize = "blue", serialize = "b")]
Blue(usize),
#[strum(disabled)]
Yellow,
#[strum(ascii_case_insensitive)]
Black,
}
#[test]
fn test_enum_ser() {
let color_variant = Color::from_str("Red").unwrap();
assert_eq!(Color::Red, color_variant);
let color_variant = Color::from_str("b").unwrap();
assert_eq!(Color::Blue(0), color_variant);
let color_variant = Color::from_str("Yellow");
assert!(color_variant.is_err());
println!("{:?}", Color::Yellow);
let color_variant = Color::from_str("bLACk").unwrap();
assert_eq!(Color::Black, color_variant);
}
#[test]
fn test_enum_struct_ser() {
let str = format!("{:?}", HashType::Transaction);
println!("{}", str);
let j = serde_json::to_string(&HashType::Transaction).unwrap();
println!("{}", j);
}