Skip to main content

stellar_xdr/generated/
claimant_type.rs

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