1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
68#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
69#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
70#[cfg_attr(
71 all(feature = "serde", feature = "alloc"),
72 serde_with::serde_as,
73 derive(serde::Serialize, serde::Deserialize),
74 serde(rename_all = "snake_case")
75)]
76#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
77#[allow(clippy::large_enum_variant)]
78pub enum OperationResultTr {
79 CreateAccount(CreateAccountResult),
80 Payment(PaymentResult),
81 PathPaymentStrictReceive(PathPaymentStrictReceiveResult),
82 ManageSellOffer(ManageSellOfferResult),
83 CreatePassiveSellOffer(ManageSellOfferResult),
84 SetOptions(SetOptionsResult),
85 ChangeTrust(ChangeTrustResult),
86 AllowTrust(AllowTrustResult),
87 AccountMerge(AccountMergeResult),
88 Inflation(InflationResult),
89 ManageData(ManageDataResult),
90 BumpSequence(BumpSequenceResult),
91 ManageBuyOffer(ManageBuyOfferResult),
92 PathPaymentStrictSend(PathPaymentStrictSendResult),
93 CreateClaimableBalance(CreateClaimableBalanceResult),
94 ClaimClaimableBalance(ClaimClaimableBalanceResult),
95 BeginSponsoringFutureReserves(BeginSponsoringFutureReservesResult),
96 EndSponsoringFutureReserves(EndSponsoringFutureReservesResult),
97 RevokeSponsorship(RevokeSponsorshipResult),
98 Clawback(ClawbackResult),
99 ClawbackClaimableBalance(ClawbackClaimableBalanceResult),
100 SetTrustLineFlags(SetTrustLineFlagsResult),
101 LiquidityPoolDeposit(LiquidityPoolDepositResult),
102 LiquidityPoolWithdraw(LiquidityPoolWithdrawResult),
103 InvokeHostFunction(InvokeHostFunctionResult),
104 ExtendFootprintTtl(ExtendFootprintTtlResult),
105 RestoreFootprint(RestoreFootprintResult),
106}
107
108#[cfg(feature = "alloc")]
109impl Default for OperationResultTr {
110 fn default() -> Self {
111 Self::CreateAccount(CreateAccountResult::default())
112 }
113}
114
115impl OperationResultTr {
116 const _VARIANTS: &[OperationType] = &[
117 OperationType::CreateAccount,
118 OperationType::Payment,
119 OperationType::PathPaymentStrictReceive,
120 OperationType::ManageSellOffer,
121 OperationType::CreatePassiveSellOffer,
122 OperationType::SetOptions,
123 OperationType::ChangeTrust,
124 OperationType::AllowTrust,
125 OperationType::AccountMerge,
126 OperationType::Inflation,
127 OperationType::ManageData,
128 OperationType::BumpSequence,
129 OperationType::ManageBuyOffer,
130 OperationType::PathPaymentStrictSend,
131 OperationType::CreateClaimableBalance,
132 OperationType::ClaimClaimableBalance,
133 OperationType::BeginSponsoringFutureReserves,
134 OperationType::EndSponsoringFutureReserves,
135 OperationType::RevokeSponsorship,
136 OperationType::Clawback,
137 OperationType::ClawbackClaimableBalance,
138 OperationType::SetTrustLineFlags,
139 OperationType::LiquidityPoolDeposit,
140 OperationType::LiquidityPoolWithdraw,
141 OperationType::InvokeHostFunction,
142 OperationType::ExtendFootprintTtl,
143 OperationType::RestoreFootprint,
144 ];
145 pub const VARIANTS: [OperationType; Self::_VARIANTS.len()] = {
146 let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
147 let mut i = 1;
148 while i < Self::_VARIANTS.len() {
149 arr[i] = Self::_VARIANTS[i];
150 i += 1;
151 }
152 arr
153 };
154 const _VARIANTS_STR: &[&str] = &[
155 "CreateAccount",
156 "Payment",
157 "PathPaymentStrictReceive",
158 "ManageSellOffer",
159 "CreatePassiveSellOffer",
160 "SetOptions",
161 "ChangeTrust",
162 "AllowTrust",
163 "AccountMerge",
164 "Inflation",
165 "ManageData",
166 "BumpSequence",
167 "ManageBuyOffer",
168 "PathPaymentStrictSend",
169 "CreateClaimableBalance",
170 "ClaimClaimableBalance",
171 "BeginSponsoringFutureReserves",
172 "EndSponsoringFutureReserves",
173 "RevokeSponsorship",
174 "Clawback",
175 "ClawbackClaimableBalance",
176 "SetTrustLineFlags",
177 "LiquidityPoolDeposit",
178 "LiquidityPoolWithdraw",
179 "InvokeHostFunction",
180 "ExtendFootprintTtl",
181 "RestoreFootprint",
182 ];
183 pub const VARIANTS_STR: [&'static str; Self::_VARIANTS_STR.len()] = {
184 let mut arr = [Self::_VARIANTS_STR[0]; Self::_VARIANTS_STR.len()];
185 let mut i = 1;
186 while i < Self::_VARIANTS_STR.len() {
187 arr[i] = Self::_VARIANTS_STR[i];
188 i += 1;
189 }
190 arr
191 };
192
193 #[must_use]
194 pub const fn name(&self) -> &'static str {
195 match self {
196 Self::CreateAccount(_) => "CreateAccount",
197 Self::Payment(_) => "Payment",
198 Self::PathPaymentStrictReceive(_) => "PathPaymentStrictReceive",
199 Self::ManageSellOffer(_) => "ManageSellOffer",
200 Self::CreatePassiveSellOffer(_) => "CreatePassiveSellOffer",
201 Self::SetOptions(_) => "SetOptions",
202 Self::ChangeTrust(_) => "ChangeTrust",
203 Self::AllowTrust(_) => "AllowTrust",
204 Self::AccountMerge(_) => "AccountMerge",
205 Self::Inflation(_) => "Inflation",
206 Self::ManageData(_) => "ManageData",
207 Self::BumpSequence(_) => "BumpSequence",
208 Self::ManageBuyOffer(_) => "ManageBuyOffer",
209 Self::PathPaymentStrictSend(_) => "PathPaymentStrictSend",
210 Self::CreateClaimableBalance(_) => "CreateClaimableBalance",
211 Self::ClaimClaimableBalance(_) => "ClaimClaimableBalance",
212 Self::BeginSponsoringFutureReserves(_) => "BeginSponsoringFutureReserves",
213 Self::EndSponsoringFutureReserves(_) => "EndSponsoringFutureReserves",
214 Self::RevokeSponsorship(_) => "RevokeSponsorship",
215 Self::Clawback(_) => "Clawback",
216 Self::ClawbackClaimableBalance(_) => "ClawbackClaimableBalance",
217 Self::SetTrustLineFlags(_) => "SetTrustLineFlags",
218 Self::LiquidityPoolDeposit(_) => "LiquidityPoolDeposit",
219 Self::LiquidityPoolWithdraw(_) => "LiquidityPoolWithdraw",
220 Self::InvokeHostFunction(_) => "InvokeHostFunction",
221 Self::ExtendFootprintTtl(_) => "ExtendFootprintTtl",
222 Self::RestoreFootprint(_) => "RestoreFootprint",
223 }
224 }
225
226 #[must_use]
227 pub const fn discriminant(&self) -> OperationType {
228 #[allow(clippy::match_same_arms)]
229 match self {
230 Self::CreateAccount(_) => OperationType::CreateAccount,
231 Self::Payment(_) => OperationType::Payment,
232 Self::PathPaymentStrictReceive(_) => OperationType::PathPaymentStrictReceive,
233 Self::ManageSellOffer(_) => OperationType::ManageSellOffer,
234 Self::CreatePassiveSellOffer(_) => OperationType::CreatePassiveSellOffer,
235 Self::SetOptions(_) => OperationType::SetOptions,
236 Self::ChangeTrust(_) => OperationType::ChangeTrust,
237 Self::AllowTrust(_) => OperationType::AllowTrust,
238 Self::AccountMerge(_) => OperationType::AccountMerge,
239 Self::Inflation(_) => OperationType::Inflation,
240 Self::ManageData(_) => OperationType::ManageData,
241 Self::BumpSequence(_) => OperationType::BumpSequence,
242 Self::ManageBuyOffer(_) => OperationType::ManageBuyOffer,
243 Self::PathPaymentStrictSend(_) => OperationType::PathPaymentStrictSend,
244 Self::CreateClaimableBalance(_) => OperationType::CreateClaimableBalance,
245 Self::ClaimClaimableBalance(_) => OperationType::ClaimClaimableBalance,
246 Self::BeginSponsoringFutureReserves(_) => OperationType::BeginSponsoringFutureReserves,
247 Self::EndSponsoringFutureReserves(_) => OperationType::EndSponsoringFutureReserves,
248 Self::RevokeSponsorship(_) => OperationType::RevokeSponsorship,
249 Self::Clawback(_) => OperationType::Clawback,
250 Self::ClawbackClaimableBalance(_) => OperationType::ClawbackClaimableBalance,
251 Self::SetTrustLineFlags(_) => OperationType::SetTrustLineFlags,
252 Self::LiquidityPoolDeposit(_) => OperationType::LiquidityPoolDeposit,
253 Self::LiquidityPoolWithdraw(_) => OperationType::LiquidityPoolWithdraw,
254 Self::InvokeHostFunction(_) => OperationType::InvokeHostFunction,
255 Self::ExtendFootprintTtl(_) => OperationType::ExtendFootprintTtl,
256 Self::RestoreFootprint(_) => OperationType::RestoreFootprint,
257 }
258 }
259
260 #[must_use]
261 pub const fn variants() -> [OperationType; Self::_VARIANTS.len()] {
262 Self::VARIANTS
263 }
264}
265
266impl Name for OperationResultTr {
267 #[must_use]
268 fn name(&self) -> &'static str {
269 Self::name(self)
270 }
271}
272
273impl Discriminant<OperationType> for OperationResultTr {
274 #[must_use]
275 fn discriminant(&self) -> OperationType {
276 Self::discriminant(self)
277 }
278}
279
280impl Variants<OperationType> for OperationResultTr {
281 fn variants() -> slice::Iter<'static, OperationType> {
282 Self::VARIANTS.iter()
283 }
284}
285
286impl Union<OperationType> for OperationResultTr {}
287
288impl ReadXdr for OperationResultTr {
289 #[cfg(feature = "std")]
290 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
291 r.with_limited_depth(|r| {
292 let dv: OperationType = <OperationType as ReadXdr>::read_xdr(r)?;
293 #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)]
294 let v = match dv {
295 OperationType::CreateAccount => {
296 Self::CreateAccount(CreateAccountResult::read_xdr(r)?)
297 }
298 OperationType::Payment => Self::Payment(PaymentResult::read_xdr(r)?),
299 OperationType::PathPaymentStrictReceive => {
300 Self::PathPaymentStrictReceive(PathPaymentStrictReceiveResult::read_xdr(r)?)
301 }
302 OperationType::ManageSellOffer => {
303 Self::ManageSellOffer(ManageSellOfferResult::read_xdr(r)?)
304 }
305 OperationType::CreatePassiveSellOffer => {
306 Self::CreatePassiveSellOffer(ManageSellOfferResult::read_xdr(r)?)
307 }
308 OperationType::SetOptions => Self::SetOptions(SetOptionsResult::read_xdr(r)?),
309 OperationType::ChangeTrust => Self::ChangeTrust(ChangeTrustResult::read_xdr(r)?),
310 OperationType::AllowTrust => Self::AllowTrust(AllowTrustResult::read_xdr(r)?),
311 OperationType::AccountMerge => Self::AccountMerge(AccountMergeResult::read_xdr(r)?),
312 OperationType::Inflation => Self::Inflation(InflationResult::read_xdr(r)?),
313 OperationType::ManageData => Self::ManageData(ManageDataResult::read_xdr(r)?),
314 OperationType::BumpSequence => Self::BumpSequence(BumpSequenceResult::read_xdr(r)?),
315 OperationType::ManageBuyOffer => {
316 Self::ManageBuyOffer(ManageBuyOfferResult::read_xdr(r)?)
317 }
318 OperationType::PathPaymentStrictSend => {
319 Self::PathPaymentStrictSend(PathPaymentStrictSendResult::read_xdr(r)?)
320 }
321 OperationType::CreateClaimableBalance => {
322 Self::CreateClaimableBalance(CreateClaimableBalanceResult::read_xdr(r)?)
323 }
324 OperationType::ClaimClaimableBalance => {
325 Self::ClaimClaimableBalance(ClaimClaimableBalanceResult::read_xdr(r)?)
326 }
327 OperationType::BeginSponsoringFutureReserves => {
328 Self::BeginSponsoringFutureReserves(
329 BeginSponsoringFutureReservesResult::read_xdr(r)?,
330 )
331 }
332 OperationType::EndSponsoringFutureReserves => Self::EndSponsoringFutureReserves(
333 EndSponsoringFutureReservesResult::read_xdr(r)?,
334 ),
335 OperationType::RevokeSponsorship => {
336 Self::RevokeSponsorship(RevokeSponsorshipResult::read_xdr(r)?)
337 }
338 OperationType::Clawback => Self::Clawback(ClawbackResult::read_xdr(r)?),
339 OperationType::ClawbackClaimableBalance => {
340 Self::ClawbackClaimableBalance(ClawbackClaimableBalanceResult::read_xdr(r)?)
341 }
342 OperationType::SetTrustLineFlags => {
343 Self::SetTrustLineFlags(SetTrustLineFlagsResult::read_xdr(r)?)
344 }
345 OperationType::LiquidityPoolDeposit => {
346 Self::LiquidityPoolDeposit(LiquidityPoolDepositResult::read_xdr(r)?)
347 }
348 OperationType::LiquidityPoolWithdraw => {
349 Self::LiquidityPoolWithdraw(LiquidityPoolWithdrawResult::read_xdr(r)?)
350 }
351 OperationType::InvokeHostFunction => {
352 Self::InvokeHostFunction(InvokeHostFunctionResult::read_xdr(r)?)
353 }
354 OperationType::ExtendFootprintTtl => {
355 Self::ExtendFootprintTtl(ExtendFootprintTtlResult::read_xdr(r)?)
356 }
357 OperationType::RestoreFootprint => {
358 Self::RestoreFootprint(RestoreFootprintResult::read_xdr(r)?)
359 }
360 #[allow(unreachable_patterns)]
361 _ => return Err(Error::Invalid),
362 };
363 Ok(v)
364 })
365 }
366}
367
368impl WriteXdr for OperationResultTr {
369 #[cfg(feature = "std")]
370 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
371 w.with_limited_depth(|w| {
372 self.discriminant().write_xdr(w)?;
373 #[allow(clippy::match_same_arms)]
374 match self {
375 Self::CreateAccount(v) => v.write_xdr(w)?,
376 Self::Payment(v) => v.write_xdr(w)?,
377 Self::PathPaymentStrictReceive(v) => v.write_xdr(w)?,
378 Self::ManageSellOffer(v) => v.write_xdr(w)?,
379 Self::CreatePassiveSellOffer(v) => v.write_xdr(w)?,
380 Self::SetOptions(v) => v.write_xdr(w)?,
381 Self::ChangeTrust(v) => v.write_xdr(w)?,
382 Self::AllowTrust(v) => v.write_xdr(w)?,
383 Self::AccountMerge(v) => v.write_xdr(w)?,
384 Self::Inflation(v) => v.write_xdr(w)?,
385 Self::ManageData(v) => v.write_xdr(w)?,
386 Self::BumpSequence(v) => v.write_xdr(w)?,
387 Self::ManageBuyOffer(v) => v.write_xdr(w)?,
388 Self::PathPaymentStrictSend(v) => v.write_xdr(w)?,
389 Self::CreateClaimableBalance(v) => v.write_xdr(w)?,
390 Self::ClaimClaimableBalance(v) => v.write_xdr(w)?,
391 Self::BeginSponsoringFutureReserves(v) => v.write_xdr(w)?,
392 Self::EndSponsoringFutureReserves(v) => v.write_xdr(w)?,
393 Self::RevokeSponsorship(v) => v.write_xdr(w)?,
394 Self::Clawback(v) => v.write_xdr(w)?,
395 Self::ClawbackClaimableBalance(v) => v.write_xdr(w)?,
396 Self::SetTrustLineFlags(v) => v.write_xdr(w)?,
397 Self::LiquidityPoolDeposit(v) => v.write_xdr(w)?,
398 Self::LiquidityPoolWithdraw(v) => v.write_xdr(w)?,
399 Self::InvokeHostFunction(v) => v.write_xdr(w)?,
400 Self::ExtendFootprintTtl(v) => v.write_xdr(w)?,
401 Self::RestoreFootprint(v) => v.write_xdr(w)?,
402 };
403 Ok(())
404 })
405 }
406}