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