Rewrite to chatty but functional API.

This commit is contained in:
2025-06-14 22:16:13 +02:00
parent d1832bc794
commit db6f55bc47
20 changed files with 423 additions and 175 deletions

View File

@@ -1,27 +1,20 @@
use std::fmt::Display;
use chrono::{DateTime, Local};
use gamenight_api_client_rs::models;
use uuid::Uuid;
#[derive(Clone)]
pub struct Gamenight {
pub id: Uuid,
pub name: String,
pub start_time: DateTime<Local>
pub start_time: DateTime<Local>,
pub owner_id: Uuid,
}
impl From<models::Gamenight> for Gamenight {
fn from(value: models::Gamenight) -> Self {
Self {
name: value.name,
start_time: DateTime::parse_from_rfc3339(&value.datetime).unwrap().into()
}
}
}
impl Display for Gamenight {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, r#"
write!(f, r#"
Name: {}
When: {}
"#, self.name, self.start_time.format("%d-%m-%Y %H:%M"))
When: {}"#, self.name, self.start_time.format("%d-%m-%Y %H:%M"))
}
}