Skip to main content

stellar_xdr/generated/
hash_id_preimage_soroban_authorization.rs

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