use enum2schema::Schema;
use serde::Serialize;
#[derive(Schema, Serialize)]
enum Command {
Clear,
Circle {
center: [f32; 2],
radius: f32,
},
SetColor(String),
}
fn main() {
println!("schema:");
println!(
"{}",
serde_json::to_string_pretty(&Command::schema()).unwrap()
);
let commands = [
Command::Clear,
Command::Circle {
center: [1.0, 2.0],
radius: 3.0,
},
Command::SetColor("red".to_string()),
];
println!("\nvalues:");
for command in &commands {
println!("{}", serde_json::to_string(command).unwrap());
}
}