Skip to main content

stellar_xdr/generated/
manage_sell_offer_op.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// ManageSellOfferOp is an XDR Struct defined as:
5///
6/// ```text
7/// struct ManageSellOfferOp
8/// {
9///     Asset selling;
10///     Asset buying;
11///     int64 amount; // amount being sold. if set to 0, delete the offer
12///     Price price;  // price of thing being sold in terms of what you are buying
13///
14///     // 0=create a new offer, otherwise edit an existing offer
15///     int64 offerID;
16/// };
17/// ```
18///
19#[cfg_attr(feature = "alloc", derive(Default))]
20#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
21#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
22#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
23#[cfg_attr(
24    all(feature = "serde", feature = "alloc"),
25    serde_with::serde_as,
26    derive(serde::Serialize, serde::Deserialize),
27    serde(rename_all = "snake_case")
28)]
29#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
30pub struct ManageSellOfferOp {
31    pub selling: Asset,
32    pub buying: Asset,
33    #[cfg_attr(
34        all(feature = "serde", feature = "alloc"),
35        serde_as(as = "NumberOrString")
36    )]
37    pub amount: i64,
38    pub price: Price,
39    #[cfg_attr(
40        all(feature = "serde", feature = "alloc"),
41        serde_as(as = "NumberOrString")
42    )]
43    pub offer_id: i64,
44}
45
46impl ReadXdr for ManageSellOfferOp {
47    #[cfg(feature = "std")]
48    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
49        r.with_limited_depth(|r| {
50            Ok(Self {
51                selling: Asset::read_xdr(r)?,
52                buying: Asset::read_xdr(r)?,
53                amount: i64::read_xdr(r)?,
54                price: Price::read_xdr(r)?,
55                offer_id: i64::read_xdr(r)?,
56            })
57        })
58    }
59}
60
61impl WriteXdr for ManageSellOfferOp {
62    #[cfg(feature = "std")]
63    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
64        w.with_limited_depth(|w| {
65            self.selling.write_xdr(w)?;
66            self.buying.write_xdr(w)?;
67            self.amount.write_xdr(w)?;
68            self.price.write_xdr(w)?;
69            self.offer_id.write_xdr(w)?;
70            Ok(())
71        })
72    }
73}