summaryrefslogtreecommitdiff
path: root/rust/proto/src/lib.rs
blob: 1a8199b56890335a23f775b19cee584472cfd593 (plain) (blame)
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
use chrono::{DateTime, Utc};
use std::ops::{Deref, DerefMut};

include!("gen/mod.rs");

//region ProtoTimestamp

pub struct ProtoTimestamp(pbjson_types::Timestamp);

impl Into<pbjson_types::Timestamp> for ProtoTimestamp {
    fn into(self) -> pbjson_types::Timestamp {
        self.0
    }
}

impl From<DateTime<Utc>> for ProtoTimestamp {
    fn from(dt: DateTime<Utc>) -> Self {
        ProtoTimestamp(dt.into())
    }
}

impl Deref for ProtoTimestamp {
    type Target = pbjson_types::Timestamp;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl DerefMut for ProtoTimestamp {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

//endregion