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