Skip to main content

stellar_xdr/generated/
claim_offer_atom.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// ClaimOfferAtom is an XDR Struct defined as:
5///
6/// ```text
7/// struct ClaimOfferAtom
8/// {
9///     // emitted to identify the offer
10///     AccountID sellerID; // Account that owns the offer
11///     int64 offerID;
12///
13///     // amount and asset taken from the owner
14///     Asset assetSold;
15///     int64 amountSold;
16///
17///     // amount and asset sent to the owner
18///     Asset assetBought;
19///     int64 amountBought;
20/// };
21/// ```
22///
23#[cfg_attr(feature = "alloc", derive(Default))]
24#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
25#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
26#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
27#[cfg_attr(
28    all(feature = "serde", feature = "alloc"),
29    serde_with::serde_as,
30    derive(serde::Serialize, serde::Deserialize),
31    serde(rename_all = "snake_case")
32)]
33#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
34pub struct ClaimOfferAtom {
35    pub seller_id: AccountId,
36    #[cfg_attr(
37        all(feature = "serde", feature = "alloc"),
38        serde_as(as = "NumberOrString")
39    )]
40    pub offer_id: i64,
41    pub asset_sold: Asset,
42    #[cfg_attr(
43        all(feature = "serde", feature = "alloc"),
44        serde_as(as = "NumberOrString")
45    )]
46    pub amount_sold: i64,
47    pub asset_bought: Asset,
48    #[cfg_attr(
49        all(feature = "serde", feature = "alloc"),
50        serde_as(as = "NumberOrString")
51    )]
52    pub amount_bought: i64,
53}
54
55impl ReadXdr for ClaimOfferAtom {
56    #[cfg(feature = "std")]
57    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
58        r.with_limited_depth(|r| {
59            Ok(Self {
60                seller_id: AccountId::read_xdr(r)?,
61                offer_id: i64::read_xdr(r)?,
62                asset_sold: Asset::read_xdr(r)?,
63                amount_sold: i64::read_xdr(r)?,
64                asset_bought: Asset::read_xdr(r)?,
65                amount_bought: i64::read_xdr(r)?,
66            })
67        })
68    }
69}
70
71impl WriteXdr for ClaimOfferAtom {
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.seller_id.write_xdr(w)?;
76            self.offer_id.write_xdr(w)?;
77            self.asset_sold.write_xdr(w)?;
78            self.amount_sold.write_xdr(w)?;
79            self.asset_bought.write_xdr(w)?;
80            self.amount_bought.write_xdr(w)?;
81            Ok(())
82        })
83    }
84}