From d5a403f04942ab2dbb6ffda4060616395cddfcbe Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Tue, 23 Apr 2024 20:12:59 +0100 Subject: [PATCH] Include extra fields in Event --- Cargo.lock | 5 +++-- Cargo.toml | 1 + client/Cargo.toml | 1 + client/src/schedule/event/mod.rs | 8 ++++++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7b17a32..56cd10b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -368,6 +368,7 @@ dependencies = [ "chrono", "reqwest", "serde", + "serde_json", "serde_with", "url", ] @@ -1079,9 +1080,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.114" +version = "1.0.116" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" +checksum = "3e17db7126d17feb94eb3fad46bf1a96b034e8aacbc2e775fe81505f8b0b2813" dependencies = [ "itoa", "ryu", diff --git a/Cargo.toml b/Cargo.toml index 6b290d1..86b83a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ clap = { version = "~4.4.0", features = ["derive", "env"] } emfcamp-schedule-api = { path = "./client/" } reqwest = { version = "0.11.27", default-features = false, features = ["json", "rustls-tls"] } serde = { version = "1.0.198", features = ["derive"] } +serde_json = "1.0.116" serde_with = "3.7.0" tokio = { version = "1.37.0", features = ["rt-multi-thread", "macros"] } tracing = "0.1.40" diff --git a/client/Cargo.toml b/client/Cargo.toml index cd12aa9..89022c4 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -8,5 +8,6 @@ edition.workspace = true chrono.workspace = true reqwest.workspace = true serde.workspace = true +serde_json.workspace = true serde_with.workspace = true url.workspace = true diff --git a/client/src/schedule/event/mod.rs b/client/src/schedule/event/mod.rs index 1876c29..3a6621d 100644 --- a/client/src/schedule/event/mod.rs +++ b/client/src/schedule/event/mod.rs @@ -3,8 +3,9 @@ mod timestamp; use chrono::{DateTime, FixedOffset}; use serde::{Deserialize, Serialize}; +use serde_json::Value; use serde_with::{serde_as, NoneAsEmptyString}; -use std::cmp::Ordering; +use std::{cmp::Ordering, collections::HashMap}; use url::Url; pub use self::kind::{Kind, Workshop}; @@ -44,7 +45,9 @@ pub struct Event { pub is_family_friendly: Option, pub link: Url, - // TODO: other fields + + #[serde(flatten)] + pub extra: HashMap, } impl Event { @@ -69,6 +72,7 @@ impl Event { may_record: None, is_family_friendly: None, link: Url::parse("http://example.com").unwrap(), + extra: Default::default(), } }