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