Skip to main content

stellar_xdr/generated/
auth_cert.rs

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