Skip to main content

stellar_xdr/generated/
soroban_address_credentials.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// SorobanAddressCredentials is an XDR Struct defined as:
5///
6/// ```text
7/// struct SorobanAddressCredentials
8/// {
9///     SCAddress address;
10///     int64 nonce;
11///     uint32 signatureExpirationLedger;    
12///     SCVal signature;
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 SorobanAddressCredentials {
28    pub address: ScAddress,
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 signature: ScVal,
36}
37
38impl ReadXdr for SorobanAddressCredentials {
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                address: ScAddress::read_xdr(r)?,
44                nonce: i64::read_xdr(r)?,
45                signature_expiration_ledger: u32::read_xdr(r)?,
46                signature: ScVal::read_xdr(r)?,
47            })
48        })
49    }
50}
51
52impl WriteXdr for SorobanAddressCredentials {
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.address.write_xdr(w)?;
57            self.nonce.write_xdr(w)?;
58            self.signature_expiration_ledger.write_xdr(w)?;
59            self.signature.write_xdr(w)?;
60            Ok(())
61        })
62    }
63}