Skip to main content

nominal_api_conjure/conjure/objects/api/
timestamp.rs

1/// Deprecated for new APIs. Use google.protobuf.Timestamp for absolute instants in proto APIs.
2///
3/// This legacy nanosecond precision timestamp type is represented by an epoch time in seconds and a nanosecond offset.
4/// The nanosecond offset is from the start of the epoch second, so must be less than 1 billion.
5#[derive(
6    Debug,
7    Clone,
8    conjure_object::serde::Serialize,
9    conjure_object::serde::Deserialize,
10    PartialEq,
11    Eq,
12    PartialOrd,
13    Ord,
14    Hash,
15    Copy,
16    conjure_object::log_safety::derive::LogSafe
17)]
18#[serde(crate = "conjure_object::serde")]
19#[conjure_object::private::staged_builder::staged_builder]
20#[builder(crate = conjure_object::private::staged_builder, update, inline)]
21pub struct Timestamp {
22    #[serde(rename = "seconds")]
23    #[assert_is_safe]
24    seconds: conjure_object::SafeLong,
25    #[serde(rename = "nanos")]
26    #[assert_is_safe]
27    nanos: conjure_object::SafeLong,
28}
29impl Timestamp {
30    /// Constructs a new instance of the type.
31    #[inline]
32    pub fn new(
33        seconds: conjure_object::SafeLong,
34        nanos: conjure_object::SafeLong,
35    ) -> Self {
36        Self::builder().seconds(seconds).nanos(nanos).build()
37    }
38    #[inline]
39    pub fn seconds(&self) -> conjure_object::SafeLong {
40        self.seconds
41    }
42    #[inline]
43    pub fn nanos(&self) -> conjure_object::SafeLong {
44        self.nanos
45    }
46}