Skip to main content

stellar_xdr/generated/
claimable_balance_entry.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// ClaimableBalanceEntry is an XDR Struct defined as:
5///
6/// ```text
7/// struct ClaimableBalanceEntry
8/// {
9///     // Unique identifier for this ClaimableBalanceEntry
10///     ClaimableBalanceID balanceID;
11///
12///     // List of claimants with associated predicate
13///     Claimant claimants<10>;
14///
15///     // Any asset including native
16///     Asset asset;
17///
18///     // Amount of asset
19///     int64 amount;
20///
21///     // reserved for future use
22///     union switch (int v)
23///     {
24///     case 0:
25///         void;
26///     case 1:
27///         ClaimableBalanceEntryExtensionV1 v1;
28///     }
29///     ext;
30/// };
31/// ```
32///
33#[cfg_attr(feature = "alloc", derive(Default))]
34#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
35#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
36#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
37#[cfg_attr(
38    all(feature = "serde", feature = "alloc"),
39    serde_with::serde_as,
40    derive(serde::Serialize, serde::Deserialize),
41    serde(rename_all = "snake_case")
42)]
43#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
44pub struct ClaimableBalanceEntry {
45    pub balance_id: ClaimableBalanceId,
46    pub claimants: VecM<Claimant, 10>,
47    pub asset: Asset,
48    #[cfg_attr(
49        all(feature = "serde", feature = "alloc"),
50        serde_as(as = "NumberOrString")
51    )]
52    pub amount: i64,
53    pub ext: ClaimableBalanceEntryExt,
54}
55
56impl ReadXdr for ClaimableBalanceEntry {
57    #[cfg(feature = "std")]
58    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
59        r.with_limited_depth(|r| {
60            Ok(Self {
61                balance_id: ClaimableBalanceId::read_xdr(r)?,
62                claimants: VecM::<Claimant, 10>::read_xdr(r)?,
63                asset: Asset::read_xdr(r)?,
64                amount: i64::read_xdr(r)?,
65                ext: ClaimableBalanceEntryExt::read_xdr(r)?,
66            })
67        })
68    }
69}
70
71impl WriteXdr for ClaimableBalanceEntry {
72    #[cfg(feature = "std")]
73    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
74        w.with_limited_depth(|w| {
75            self.balance_id.write_xdr(w)?;
76            self.claimants.write_xdr(w)?;
77            self.asset.write_xdr(w)?;
78            self.amount.write_xdr(w)?;
79            self.ext.write_xdr(w)?;
80            Ok(())
81        })
82    }
83}