stellar_xdr/generated/
liquidity_pool_entry_body.rs1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
25#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
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))]
34#[allow(clippy::large_enum_variant)]
35pub enum LiquidityPoolEntryBody {
36 LiquidityPoolConstantProduct(LiquidityPoolEntryConstantProduct),
37}
38
39#[cfg(feature = "alloc")]
40impl Default for LiquidityPoolEntryBody {
41 fn default() -> Self {
42 Self::LiquidityPoolConstantProduct(LiquidityPoolEntryConstantProduct::default())
43 }
44}
45
46impl LiquidityPoolEntryBody {
47 const _VARIANTS: &[LiquidityPoolType] = &[LiquidityPoolType::LiquidityPoolConstantProduct];
48 pub const VARIANTS: [LiquidityPoolType; Self::_VARIANTS.len()] = {
49 let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
50 let mut i = 1;
51 while i < Self::_VARIANTS.len() {
52 arr[i] = Self::_VARIANTS[i];
53 i += 1;
54 }
55 arr
56 };
57 const _VARIANTS_STR: &[&str] = &["LiquidityPoolConstantProduct"];
58 pub const VARIANTS_STR: [&'static str; Self::_VARIANTS_STR.len()] = {
59 let mut arr = [Self::_VARIANTS_STR[0]; Self::_VARIANTS_STR.len()];
60 let mut i = 1;
61 while i < Self::_VARIANTS_STR.len() {
62 arr[i] = Self::_VARIANTS_STR[i];
63 i += 1;
64 }
65 arr
66 };
67
68 #[must_use]
69 pub const fn name(&self) -> &'static str {
70 match self {
71 Self::LiquidityPoolConstantProduct(_) => "LiquidityPoolConstantProduct",
72 }
73 }
74
75 #[must_use]
76 pub const fn discriminant(&self) -> LiquidityPoolType {
77 #[allow(clippy::match_same_arms)]
78 match self {
79 Self::LiquidityPoolConstantProduct(_) => {
80 LiquidityPoolType::LiquidityPoolConstantProduct
81 }
82 }
83 }
84
85 #[must_use]
86 pub const fn variants() -> [LiquidityPoolType; Self::_VARIANTS.len()] {
87 Self::VARIANTS
88 }
89}
90
91impl Name for LiquidityPoolEntryBody {
92 #[must_use]
93 fn name(&self) -> &'static str {
94 Self::name(self)
95 }
96}
97
98impl Discriminant<LiquidityPoolType> for LiquidityPoolEntryBody {
99 #[must_use]
100 fn discriminant(&self) -> LiquidityPoolType {
101 Self::discriminant(self)
102 }
103}
104
105impl Variants<LiquidityPoolType> for LiquidityPoolEntryBody {
106 fn variants() -> slice::Iter<'static, LiquidityPoolType> {
107 Self::VARIANTS.iter()
108 }
109}
110
111impl Union<LiquidityPoolType> for LiquidityPoolEntryBody {}
112
113impl ReadXdr for LiquidityPoolEntryBody {
114 #[cfg(feature = "std")]
115 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
116 r.with_limited_depth(|r| {
117 let dv: LiquidityPoolType = <LiquidityPoolType as ReadXdr>::read_xdr(r)?;
118 #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)]
119 let v = match dv {
120 LiquidityPoolType::LiquidityPoolConstantProduct => {
121 Self::LiquidityPoolConstantProduct(LiquidityPoolEntryConstantProduct::read_xdr(
122 r,
123 )?)
124 }
125 #[allow(unreachable_patterns)]
126 _ => return Err(Error::Invalid),
127 };
128 Ok(v)
129 })
130 }
131}
132
133impl WriteXdr for LiquidityPoolEntryBody {
134 #[cfg(feature = "std")]
135 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
136 w.with_limited_depth(|w| {
137 self.discriminant().write_xdr(w)?;
138 #[allow(clippy::match_same_arms)]
139 match self {
140 Self::LiquidityPoolConstantProduct(v) => v.write_xdr(w)?,
141 };
142 Ok(())
143 })
144 }
145}