Skip to content

Commit

Permalink
Deserialise empty strings as None
Browse files Browse the repository at this point in the history
  • Loading branch information
DanNixon committed Apr 23, 2024
1 parent 4f08952 commit c4ccb3e
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 3 deletions.
155 changes: 152 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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_with = "3.7.0"
tokio = { version = "1.37.0", features = ["rt-multi-thread", "macros"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
Expand Down
1 change: 1 addition & 0 deletions client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ edition.workspace = true
chrono.workspace = true
reqwest.workspace = true
serde.workspace = true
serde_with.workspace = true
url.workspace = true
4 changes: 4 additions & 0 deletions client/src/schedule/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ mod timestamp;

use chrono::{DateTime, FixedOffset};
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, NoneAsEmptyString};
use std::cmp::Ordering;
use url::Url;

pub use self::kind::{Kind, Workshop};

#[serde_as]
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct Event {
pub id: u32,
Expand All @@ -22,12 +24,14 @@ pub struct Event {

pub venue: String,

#[serde_as(as = "NoneAsEmptyString")]
pub map_link: Option<String>,

pub title: String,

pub speaker: String,

#[serde_as(as = "NoneAsEmptyString")]
pub pronouns: Option<String>,

pub description: String,
Expand Down

0 comments on commit c4ccb3e

Please sign in to comment.