Skip to main content

stellar_xdr/generated/
time_point.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// TimePoint is an XDR Typedef defined as:
5///
6/// ```text
7/// typedef uint64 TimePoint;
8/// ```
9///
10#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
11#[cfg_attr(feature = "alloc", derive(Default))]
12#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
13#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
14#[cfg_attr(
15    all(feature = "serde", feature = "alloc"),
16    serde_with::serde_as,
17    derive(serde::Serialize, serde::Deserialize),
18    serde(rename_all = "snake_case")
19)]
20#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
21#[derive(Debug)]
22pub struct TimePoint(
23    #[cfg_attr(
24        all(feature = "serde", feature = "alloc"),
25        serde_as(as = "NumberOrString")
26    )]
27    pub u64,
28);
29
30impl From<TimePoint> for u64 {
31    #[must_use]
32    fn from(x: TimePoint) -> Self {
33        x.0
34    }
35}
36
37impl From<u64> for TimePoint {
38    #[must_use]
39    fn from(x: u64) -> Self {
40        TimePoint(x)
41    }
42}
43
44impl AsRef<u64> for TimePoint {
45    #[must_use]
46    fn as_ref(&self) -> &u64 {
47        &self.0
48    }
49}
50
51impl ReadXdr for TimePoint {
52    #[cfg(feature = "std")]
53    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
54        r.with_limited_depth(|r| {
55            let i = u64::read_xdr(r)?;
56            let v = TimePoint(i);
57            Ok(v)
58        })
59    }
60}
61
62impl WriteXdr for TimePoint {
63    #[cfg(feature = "std")]
64    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
65        w.with_limited_depth(|w| self.0.write_xdr(w))
66    }
67}