Skip to main content

stellar_xdr/generated/
create_passive_sell_offer_op.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// CreatePassiveSellOfferOp is an XDR Struct defined as:
5///
6/// ```text
7/// struct CreatePassiveSellOfferOp
8/// {
9///     Asset selling; // A
10///     Asset buying;  // B
11///     int64 amount;  // amount taker gets
12///     Price price;   // cost of A in terms of B
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 CreatePassiveSellOfferOp {
28    pub selling: Asset,
29    pub buying: Asset,
30    #[cfg_attr(
31        all(feature = "serde", feature = "alloc"),
32        serde_as(as = "NumberOrString")
33    )]
34    pub amount: i64,
35    pub price: Price,
36}
37
38impl ReadXdr for CreatePassiveSellOfferOp {
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                selling: Asset::read_xdr(r)?,
44                buying: Asset::read_xdr(r)?,
45                amount: i64::read_xdr(r)?,
46                price: Price::read_xdr(r)?,
47            })
48        })
49    }
50}
51
52impl WriteXdr for CreatePassiveSellOfferOp {
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.selling.write_xdr(w)?;
57            self.buying.write_xdr(w)?;
58            self.amount.write_xdr(w)?;
59            self.price.write_xdr(w)?;
60            Ok(())
61        })
62    }
63}