stellar_xdr/generated/
duration.rs1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4#[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 Duration(
23 #[cfg_attr(
24 all(feature = "serde", feature = "alloc"),
25 serde_as(as = "NumberOrString")
26 )]
27 pub u64,
28);
29
30impl From<Duration> for u64 {
31 #[must_use]
32 fn from(x: Duration) -> Self {
33 x.0
34 }
35}
36
37impl From<u64> for Duration {
38 #[must_use]
39 fn from(x: u64) -> Self {
40 Duration(x)
41 }
42}
43
44impl AsRef<u64> for Duration {
45 #[must_use]
46 fn as_ref(&self) -> &u64 {
47 &self.0
48 }
49}
50
51impl ReadXdr for Duration {
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 = Duration(i);
57 Ok(v)
58 })
59 }
60}
61
62impl WriteXdr for Duration {
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}