proto/
lib.rs

1pub mod events;
2pub mod common {
3    tonic::include_proto!("common");
4
5    // pbjson generated code
6    include!(concat!(env!("OUT_DIR"), "/common.serde.rs"));
7
8    impl<T> From<chrono::DateTime<T>> for DateTime
9    where
10        T: chrono::TimeZone,
11        <T as chrono::TimeZone>::Offset: std::fmt::Display,
12    {
13        fn from(value: chrono::DateTime<T>) -> Self {
14            Self {
15                rfc3339: value.to_rfc3339(),
16            }
17        }
18    }
19
20    impl From<DateTime> for chrono::DateTime<chrono::Utc> {
21        fn from(value: DateTime) -> Self {
22            chrono::DateTime::parse_from_rfc3339(&value.rfc3339)
23                .unwrap()
24                .with_timezone(&chrono::Utc)
25        }
26    }
27
28    impl From<DateTime> for chrono::DateTime<chrono::FixedOffset> {
29        fn from(value: DateTime) -> Self {
30            chrono::DateTime::parse_from_rfc3339(&value.rfc3339).unwrap()
31        }
32    }
33
34    impl PaginationIn {
35        // We add this because proto3 doesn't support default values. In tests,
36        // we construct the protobuf object directly and we can't rely
37        // solely on the default populated in API deserialization.
38        pub fn limit(&self) -> usize {
39            if self.limit == 0 {
40                20
41            } else {
42                self.limit as usize
43            }
44        }
45
46        pub fn paginated_query_limit(&self) -> u64 {
47            (self.limit() + 1) as u64
48        }
49    }
50}
51
52pub mod scheduler_proto {
53    tonic::include_proto!("scheduler_proto");
54}
55
56pub mod dispatcher_proto {
57    tonic::include_proto!("dispatcher_proto");
58}
59
60pub mod trigger_proto {
61    tonic::include_proto!("trigger_proto");
62    include!(concat!(env!("OUT_DIR"), "/trigger_proto.serde.rs"));
63}
64
65pub mod run_proto {
66    tonic::include_proto!("run_proto");
67}
68
69pub mod attempt_proto {
70    tonic::include_proto!("attempt_proto");
71    include!(concat!(env!("OUT_DIR"), "/attempt_proto.serde.rs"));
72}
73
74pub const FILE_DESCRIPTOR_SET: &[u8] =
75    tonic::include_file_descriptor_set!("file_descriptor");