mod swaybar_object;
fn main() {
- println!("Hello, world!");
-
+ println!(
+ "{}",
+ serde_json::to_string(&swaybar_object::SwaybarHeader::new())
+ .expect("Should be able to serialize SwaybarHeader")
+ );
+ println!("[");
let mut array = swaybar_object::SwaybarArray::new();
array.push_object(swaybar_object::SwaybarObject::default());
array.push_object(swaybar_object::SwaybarObject::new());
use chrono::prelude::*;
use serde::{Deserialize, Serialize};
+#[derive(Serialize, Deserialize, Debug)]
+pub struct SwaybarHeader {
+ pub version: u32,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub click_events: Option<bool>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub cont_signal: Option<u16>,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub stop_signal: Option<u16>,
+}
+
#[derive(Serialize, Deserialize, Debug)]
pub struct SwaybarObject {
pub full_text: String,
objects: Vec<SwaybarObject>,
}
+impl SwaybarHeader {
+ pub fn new() -> Self {
+ Self {
+ version: 1,
+ click_events: None,
+ cont_signal: None,
+ stop_signal: None,
+ }
+ }
+}
+
impl SwaybarObject {
pub fn new() -> Self {
Self {