1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use base64uuid::Base64Uuid;
#[cfg(feature = "fp-bindgen")]
use fp_bindgen::prelude::Serializable;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use time::OffsetDateTime;
use typed_builder::TypedBuilder;
#[derive(Clone, Deserialize, Eq, PartialEq, Serialize, Debug, TypedBuilder)]
#[cfg_attr(
feature = "fp-bindgen",
derive(Serializable),
fp(rust_module = "fiberplane_models::events")
)]
#[non_exhaustive]
#[serde(rename_all = "camelCase")]
pub struct Event {
pub id: Base64Uuid,
pub title: String,
pub labels: HashMap<String, Option<String>>,
#[serde(with = "time::serde::rfc3339")]
pub occurrence_time: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
pub created_at: OffsetDateTime,
#[serde(with = "time::serde::rfc3339")]
pub updated_at: OffsetDateTime,
}
#[derive(Clone, Default, Deserialize, Eq, PartialEq, Serialize, Debug, TypedBuilder)]
#[cfg_attr(
feature = "fp-bindgen",
derive(Serializable),
fp(rust_module = "fiberplane_models::events")
)]
#[non_exhaustive]
#[serde(rename_all = "camelCase")]
pub struct NewEvent {
#[builder(setter(into))]
pub title: String,
#[builder(default, setter(into, strip_option))]
#[serde(default)]
pub labels: Option<HashMap<String, Option<String>>>,
#[builder(default, setter(into))]
#[serde(default, with = "time::serde::rfc3339::option")]
pub time: Option<OffsetDateTime>,
}