stellar_xdr/generated/
liquidity_pool_entry_constant_product.rs1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4#[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 LiquidityPoolEntryConstantProduct {
31 pub params: LiquidityPoolConstantProductParameters,
32 #[cfg_attr(
33 all(feature = "serde", feature = "alloc"),
34 serde_as(as = "NumberOrString")
35 )]
36 pub reserve_a: i64,
37 #[cfg_attr(
38 all(feature = "serde", feature = "alloc"),
39 serde_as(as = "NumberOrString")
40 )]
41 pub reserve_b: i64,
42 #[cfg_attr(
43 all(feature = "serde", feature = "alloc"),
44 serde_as(as = "NumberOrString")
45 )]
46 pub total_pool_shares: i64,
47 #[cfg_attr(
48 all(feature = "serde", feature = "alloc"),
49 serde_as(as = "NumberOrString")
50 )]
51 pub pool_shares_trust_line_count: i64,
52}
53
54impl ReadXdr for LiquidityPoolEntryConstantProduct {
55 #[cfg(feature = "std")]
56 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
57 r.with_limited_depth(|r| {
58 Ok(Self {
59 params: LiquidityPoolConstantProductParameters::read_xdr(r)?,
60 reserve_a: i64::read_xdr(r)?,
61 reserve_b: i64::read_xdr(r)?,
62 total_pool_shares: i64::read_xdr(r)?,
63 pool_shares_trust_line_count: i64::read_xdr(r)?,
64 })
65 })
66 }
67}
68
69impl WriteXdr for LiquidityPoolEntryConstantProduct {
70 #[cfg(feature = "std")]
71 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
72 w.with_limited_depth(|w| {
73 self.params.write_xdr(w)?;
74 self.reserve_a.write_xdr(w)?;
75 self.reserve_b.write_xdr(w)?;
76 self.total_pool_shares.write_xdr(w)?;
77 self.pool_shares_trust_line_count.write_xdr(w)?;
78 Ok(())
79 })
80 }
81}