use serde::{Serialize, ser::Serializer}; use std::sync::Arc; use tokio::task::JoinHandle; use smart_default::SmartDefault; #[derive(Copy, Clone, Debug, Serialize)] #[serde(rename_all = "lowercase")] pub enum Alignment { Left, Center, Right, } impl Default for Alignment { fn default() -> Self { Self::Center } } #[derive(Copy, Clone, Debug, Serialize)] #[serde(rename_all = "lowercase")] pub enum Markup { None, Pango, } impl Default for Markup { fn default() -> Self { Self::None } } fn arc_default(arc: &Arc, serializer: S) -> Result where S: Serializer { serializer.serialize_str(arc) } #[derive(Clone, Serialize, Debug, SmartDefault)] pub struct Block { pub full_text: Box, #[serde(skip_serializing_if = "Option::is_none")] pub short_text: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub color: Option>, #[serde(skip_serializing_if = "Option::is_none", rename = "background")] pub background_color: Option>, #[serde(skip_serializing_if = "Option::is_none", rename = "border")] pub border_color: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub border_top: Option, #[serde(skip_serializing_if = "Option::is_none")] pub border_right: Option, #[serde(skip_serializing_if = "Option::is_none")] pub border_bottom: Option, #[serde(skip_serializing_if = "Option::is_none")] pub border_left: Option, #[serde(skip_serializing_if = "Option::is_none")] pub min_width: Option, #[serde(skip_serializing_if = "Option::is_none")] pub align: Option, pub name: Box, #[serde(serialize_with = "arc_default")] #[default = r#""".into()"#] pub instance: Arc, #[serde(skip_serializing_if = "Option::is_none")] pub urgent: Option, #[serde(skip_serializing_if = "Option::is_none")] pub separator: Option, #[serde(skip_serializing_if = "Option::is_none")] pub separator_block_width: Option, #[serde(skip_serializing_if = "Option::is_none")] pub markup: Option, } #[derive(Clone, Debug)] pub struct TileData { pub sender_id: usize, pub block: Block, } pub trait Tile: Send { fn spawn(self: Arc) -> JoinHandle>>; }