Skip to main content

stellar_xdr/generated/
create_claimable_balance_op.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// CreateClaimableBalanceOp is an XDR Struct defined as:
5///
6/// ```text
7/// struct CreateClaimableBalanceOp
8/// {
9///     Asset asset;
10///     int64 amount;
11///     Claimant claimants<10>;
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 CreateClaimableBalanceOp {
27    pub asset: Asset,
28    #[cfg_attr(
29        all(feature = "serde", feature = "alloc"),
30        serde_as(as = "NumberOrString")
31    )]
32    pub amount: i64,
33    pub claimants: VecM<Claimant, 10>,
34}
35
36impl ReadXdr for CreateClaimableBalanceOp {
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                asset: Asset::read_xdr(r)?,
42                amount: i64::read_xdr(r)?,
43                claimants: VecM::<Claimant, 10>::read_xdr(r)?,
44            })
45        })
46    }
47}
48
49impl WriteXdr for CreateClaimableBalanceOp {
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.asset.write_xdr(w)?;
54            self.amount.write_xdr(w)?;
55            self.claimants.write_xdr(w)?;
56            Ok(())
57        })
58    }
59}