use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum ItemKind { Mocion, Enmienda, EnmiendaSustitutiva, } impl ItemKind { pub const fn label(&self) -> &'static str { match self { Self::Mocion => "Moción", Self::Enmienda => "Enmienda", Self::EnmiendaSustitutiva => "Enm. Susti.", } } } #[derive(Debug, Clone, Default, Serialize, Deserialize)] pub struct Vote { pub favor: u32, pub contra: u32, } #[derive(Debug, Clone, Serialize, Deserialize)] pub enum Stage { AwaitingSecundar, AwaitingOpposition, Voting(Vote), } impl Stage { pub fn label(&self) -> String { match self { Self::AwaitingSecundar => "awaiting secundar".to_string(), Self::AwaitingOpposition => "awaiting opposition".to_string(), Self::Voting(v) => format!("voting {}f / {}c", v.favor, v.contra), } } } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct StackItem { pub kind: ItemKind, pub text: String, pub stage: Stage, } impl StackItem { pub const fn new(kind: ItemKind, text: String) -> Self { Self { kind, text, stage: Stage::AwaitingSecundar } } } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct PassedMocion { pub number: usize, pub text: String, /// `Some((favor, contra))` when voted; `None` when passed without opposition. pub votes: Option<(u32, u32)>, }