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