fp_bindgen/serializable/
time.rs

1use super::Serializable;
2use crate::types::{CargoDependency, CustomType, Type, TypeIdent};
3use std::collections::{BTreeMap, BTreeSet};
4
5impl Serializable for time::OffsetDateTime {
6    fn ident() -> TypeIdent {
7        TypeIdent::from("OffsetDateTime")
8    }
9
10    fn ty() -> Type {
11        Type::Custom(CustomType {
12            ident: Self::ident(),
13            rs_ty: "time::OffsetDateTime".to_owned(),
14            rs_dependencies: BTreeMap::from([(
15                "time",
16                CargoDependency {
17                    version: Some("0.3"),
18                    features: BTreeSet::from(["serde-well-known"]),
19                    ..Default::default()
20                },
21            )]),
22            serde_attrs: vec![r#"with = "time::serde::rfc3339""#.to_owned()],
23            ts_ty: "string".to_owned(),
24            ts_declaration: None,
25        })
26    }
27}
28
29impl Serializable for time::PrimitiveDateTime {
30    fn ident() -> TypeIdent {
31        TypeIdent::from("PrimitiveDateTime")
32    }
33
34    fn ty() -> Type {
35        Type::Custom(CustomType {
36            ident: Self::ident(),
37            rs_ty: "time::PrimitiveDateTime".to_owned(),
38            rs_dependencies: BTreeMap::from([(
39                "time",
40                CargoDependency {
41                    version: Some("0.3"),
42                    features: BTreeSet::from(["serde-well-known"]),
43                    ..Default::default()
44                },
45            )]),
46            serde_attrs: vec![r#"with = "time::serde::rfc3339""#.to_owned()],
47            ts_ty: "string".to_owned(),
48            ts_declaration: None,
49        })
50    }
51}