Skip to main content

nominal_api/conjure/objects/api/
timestamp.rs

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