stellar_xdr/generated/
liquidity_pool_withdraw_result.rs1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
23#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
24#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
25#[cfg_attr(
26 all(feature = "serde", feature = "alloc"),
27 serde_with::serde_as,
28 derive(serde::Serialize, serde::Deserialize),
29 serde(rename_all = "snake_case")
30)]
31#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
32#[allow(clippy::large_enum_variant)]
33pub enum LiquidityPoolWithdrawResult {
34 Success,
35 Malformed,
36 NoTrust,
37 Underfunded,
38 LineFull,
39 UnderMinimum,
40 TrustlineFrozen,
41}
42
43#[cfg(feature = "alloc")]
44impl Default for LiquidityPoolWithdrawResult {
45 fn default() -> Self {
46 Self::Success
47 }
48}
49
50impl LiquidityPoolWithdrawResult {
51 const _VARIANTS: &[LiquidityPoolWithdrawResultCode] = &[
52 LiquidityPoolWithdrawResultCode::Success,
53 LiquidityPoolWithdrawResultCode::Malformed,
54 LiquidityPoolWithdrawResultCode::NoTrust,
55 LiquidityPoolWithdrawResultCode::Underfunded,
56 LiquidityPoolWithdrawResultCode::LineFull,
57 LiquidityPoolWithdrawResultCode::UnderMinimum,
58 LiquidityPoolWithdrawResultCode::TrustlineFrozen,
59 ];
60 pub const VARIANTS: [LiquidityPoolWithdrawResultCode; Self::_VARIANTS.len()] = {
61 let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
62 let mut i = 1;
63 while i < Self::_VARIANTS.len() {
64 arr[i] = Self::_VARIANTS[i];
65 i += 1;
66 }
67 arr
68 };
69 const _VARIANTS_STR: &[&str] = &[
70 "Success",
71 "Malformed",
72 "NoTrust",
73 "Underfunded",
74 "LineFull",
75 "UnderMinimum",
76 "TrustlineFrozen",
77 ];
78 pub const VARIANTS_STR: [&'static str; Self::_VARIANTS_STR.len()] = {
79 let mut arr = [Self::_VARIANTS_STR[0]; Self::_VARIANTS_STR.len()];
80 let mut i = 1;
81 while i < Self::_VARIANTS_STR.len() {
82 arr[i] = Self::_VARIANTS_STR[i];
83 i += 1;
84 }
85 arr
86 };
87
88 #[must_use]
89 pub const fn name(&self) -> &'static str {
90 match self {
91 Self::Success => "Success",
92 Self::Malformed => "Malformed",
93 Self::NoTrust => "NoTrust",
94 Self::Underfunded => "Underfunded",
95 Self::LineFull => "LineFull",
96 Self::UnderMinimum => "UnderMinimum",
97 Self::TrustlineFrozen => "TrustlineFrozen",
98 }
99 }
100
101 #[must_use]
102 pub const fn discriminant(&self) -> LiquidityPoolWithdrawResultCode {
103 #[allow(clippy::match_same_arms)]
104 match self {
105 Self::Success => LiquidityPoolWithdrawResultCode::Success,
106 Self::Malformed => LiquidityPoolWithdrawResultCode::Malformed,
107 Self::NoTrust => LiquidityPoolWithdrawResultCode::NoTrust,
108 Self::Underfunded => LiquidityPoolWithdrawResultCode::Underfunded,
109 Self::LineFull => LiquidityPoolWithdrawResultCode::LineFull,
110 Self::UnderMinimum => LiquidityPoolWithdrawResultCode::UnderMinimum,
111 Self::TrustlineFrozen => LiquidityPoolWithdrawResultCode::TrustlineFrozen,
112 }
113 }
114
115 #[must_use]
116 pub const fn variants() -> [LiquidityPoolWithdrawResultCode; Self::_VARIANTS.len()] {
117 Self::VARIANTS
118 }
119}
120
121impl Name for LiquidityPoolWithdrawResult {
122 #[must_use]
123 fn name(&self) -> &'static str {
124 Self::name(self)
125 }
126}
127
128impl Discriminant<LiquidityPoolWithdrawResultCode> for LiquidityPoolWithdrawResult {
129 #[must_use]
130 fn discriminant(&self) -> LiquidityPoolWithdrawResultCode {
131 Self::discriminant(self)
132 }
133}
134
135impl Variants<LiquidityPoolWithdrawResultCode> for LiquidityPoolWithdrawResult {
136 fn variants() -> slice::Iter<'static, LiquidityPoolWithdrawResultCode> {
137 Self::VARIANTS.iter()
138 }
139}
140
141impl Union<LiquidityPoolWithdrawResultCode> for LiquidityPoolWithdrawResult {}
142
143impl ReadXdr for LiquidityPoolWithdrawResult {
144 #[cfg(feature = "std")]
145 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
146 r.with_limited_depth(|r| {
147 let dv: LiquidityPoolWithdrawResultCode =
148 <LiquidityPoolWithdrawResultCode as ReadXdr>::read_xdr(r)?;
149 #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)]
150 let v = match dv {
151 LiquidityPoolWithdrawResultCode::Success => Self::Success,
152 LiquidityPoolWithdrawResultCode::Malformed => Self::Malformed,
153 LiquidityPoolWithdrawResultCode::NoTrust => Self::NoTrust,
154 LiquidityPoolWithdrawResultCode::Underfunded => Self::Underfunded,
155 LiquidityPoolWithdrawResultCode::LineFull => Self::LineFull,
156 LiquidityPoolWithdrawResultCode::UnderMinimum => Self::UnderMinimum,
157 LiquidityPoolWithdrawResultCode::TrustlineFrozen => Self::TrustlineFrozen,
158 #[allow(unreachable_patterns)]
159 _ => return Err(Error::Invalid),
160 };
161 Ok(v)
162 })
163 }
164}
165
166impl WriteXdr for LiquidityPoolWithdrawResult {
167 #[cfg(feature = "std")]
168 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
169 w.with_limited_depth(|w| {
170 self.discriminant().write_xdr(w)?;
171 #[allow(clippy::match_same_arms)]
172 match self {
173 Self::Success => ().write_xdr(w)?,
174 Self::Malformed => ().write_xdr(w)?,
175 Self::NoTrust => ().write_xdr(w)?,
176 Self::Underfunded => ().write_xdr(w)?,
177 Self::LineFull => ().write_xdr(w)?,
178 Self::UnderMinimum => ().write_xdr(w)?,
179 Self::TrustlineFrozen => ().write_xdr(w)?,
180 };
181 Ok(())
182 })
183 }
184}