stellar_xdr/generated/
inflation_result_code.rs1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4#[cfg_attr(feature = "alloc", derive(Default))]
18#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
19#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
20#[cfg_attr(
21 all(feature = "serde", feature = "alloc"),
22 derive(serde::Serialize, serde::Deserialize),
23 serde(rename_all = "snake_case")
24)]
25#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
26#[repr(i32)]
27pub enum InflationResultCode {
28 #[cfg_attr(feature = "alloc", default)]
29 Success = 0,
30 NotTime = -1,
31}
32
33impl InflationResultCode {
34 const _VARIANTS: &[InflationResultCode] =
35 &[InflationResultCode::Success, InflationResultCode::NotTime];
36 pub const VARIANTS: [InflationResultCode; Self::_VARIANTS.len()] = {
37 let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
38 let mut i = 1;
39 while i < Self::_VARIANTS.len() {
40 arr[i] = Self::_VARIANTS[i];
41 i += 1;
42 }
43 arr
44 };
45 const _VARIANTS_STR: &[&str] = &["Success", "NotTime"];
46 pub const VARIANTS_STR: [&'static str; Self::_VARIANTS_STR.len()] = {
47 let mut arr = [Self::_VARIANTS_STR[0]; Self::_VARIANTS_STR.len()];
48 let mut i = 1;
49 while i < Self::_VARIANTS_STR.len() {
50 arr[i] = Self::_VARIANTS_STR[i];
51 i += 1;
52 }
53 arr
54 };
55
56 #[must_use]
57 pub const fn name(&self) -> &'static str {
58 match self {
59 Self::Success => "Success",
60 Self::NotTime => "NotTime",
61 }
62 }
63
64 #[must_use]
65 pub const fn variants() -> [InflationResultCode; Self::_VARIANTS.len()] {
66 Self::VARIANTS
67 }
68}
69
70impl Name for InflationResultCode {
71 #[must_use]
72 fn name(&self) -> &'static str {
73 Self::name(self)
74 }
75}
76
77impl Variants<InflationResultCode> for InflationResultCode {
78 fn variants() -> slice::Iter<'static, InflationResultCode> {
79 Self::VARIANTS.iter()
80 }
81}
82
83impl Enum for InflationResultCode {}
84
85impl fmt::Display for InflationResultCode {
86 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
87 f.write_str(self.name())
88 }
89}
90
91impl TryFrom<i32> for InflationResultCode {
92 type Error = Error;
93
94 fn try_from(i: i32) -> Result<Self, Error> {
95 let e = match i {
96 0 => InflationResultCode::Success,
97 -1 => InflationResultCode::NotTime,
98 #[allow(unreachable_patterns)]
99 _ => return Err(Error::Invalid),
100 };
101 Ok(e)
102 }
103}
104
105impl From<InflationResultCode> for i32 {
106 #[must_use]
107 fn from(e: InflationResultCode) -> Self {
108 e as Self
109 }
110}
111
112impl ReadXdr for InflationResultCode {
113 #[cfg(feature = "std")]
114 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
115 r.with_limited_depth(|r| {
116 let e = i32::read_xdr(r)?;
117 let v: Self = e.try_into()?;
118 Ok(v)
119 })
120 }
121}
122
123impl WriteXdr for InflationResultCode {
124 #[cfg(feature = "std")]
125 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
126 w.with_limited_depth(|w| {
127 let i: i32 = (*self).into();
128 i.write_xdr(w)
129 })
130 }
131}