use serde::{Serialize, Deserialize}; use chrono::{DateTime, Utc}; #[derive(Serialize, Deserialize, PartialEq, Debug)] pub enum ConsentType { Fight, Medicine, Gifts, Visit, Sex } impl ConsentType { pub fn from_str(inp: &str) -> Option { use ConsentType::*; match inp { "fight" => Some(Fight), "medicine" => Some(Medicine), "gifts" => Some(Gifts), "visit" => Some(Visit), "sex" => Some(Sex), _ => None } } pub fn to_str(&self) -> &'static str { use ConsentType::*; match self { Fight => "fight", Medicine => "medicine", Gifts => "gifts", Visit => "visit", Sex => "sex", } } } #[derive(Serialize, Deserialize, PartialEq, Clone, Debug)] pub enum ConsentStatus { PendingAdd, // Added but awaiting other party to ratify by giving matching consent. Active, // Consent in force, no delete pending. PendingDelete, // Pending cancellation but other party has to also disallow to ratify. } #[derive(Serialize, Deserialize, PartialEq, Clone, Debug)] pub struct FightConsent { pub status: ConsentStatus, pub pending_change: Option>, pub allow_pick: bool, pub freely_revoke: bool, } impl Default for FightConsent { fn default() -> Self { Self { status: ConsentStatus::PendingAdd, pending_change: None, allow_pick: false, freely_revoke: false } } } #[derive(Serialize, Deserialize, PartialEq, Clone, Debug)] pub struct Consent { pub fight_consent: Option, pub expires: Option>, pub only_in: Vec, pub allow_private: bool, pub until_death: bool, } impl Default for Consent { fn default() -> Self { Self { fight_consent: None, expires: None, only_in: vec!(), allow_private: false, until_death: false } } }