stellar_xdr/generated/
claimant.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 Claimant {
31 ClaimantTypeV0(ClaimantV0),
32}
33
34#[cfg(feature = "alloc")]
35impl Default for Claimant {
36 fn default() -> Self {
37 Self::ClaimantTypeV0(ClaimantV0::default())
38 }
39}
40
41impl Claimant {
42 const _VARIANTS: &[ClaimantType] = &[ClaimantType::ClaimantTypeV0];
43 pub const VARIANTS: [ClaimantType; Self::_VARIANTS.len()] = {
44 let mut arr = [Self::_VARIANTS[0]; Self::_VARIANTS.len()];
45 let mut i = 1;
46 while i < Self::_VARIANTS.len() {
47 arr[i] = Self::_VARIANTS[i];
48 i += 1;
49 }
50 arr
51 };
52 const _VARIANTS_STR: &[&str] = &["ClaimantTypeV0"];
53 pub const VARIANTS_STR: [&'static str; Self::_VARIANTS_STR.len()] = {
54 let mut arr = [Self::_VARIANTS_STR[0]; Self::_VARIANTS_STR.len()];
55 let mut i = 1;
56 while i < Self::_VARIANTS_STR.len() {
57 arr[i] = Self::_VARIANTS_STR[i];
58 i += 1;
59 }
60 arr
61 };
62
63 #[must_use]
64 pub const fn name(&self) -> &'static str {
65 match self {
66 Self::ClaimantTypeV0(_) => "ClaimantTypeV0",
67 }
68 }
69
70 #[must_use]
71 pub const fn discriminant(&self) -> ClaimantType {
72 #[allow(clippy::match_same_arms)]
73 match self {
74 Self::ClaimantTypeV0(_) => ClaimantType::ClaimantTypeV0,
75 }
76 }
77
78 #[must_use]
79 pub const fn variants() -> [ClaimantType; Self::_VARIANTS.len()] {
80 Self::VARIANTS
81 }
82}
83
84impl Name for Claimant {
85 #[must_use]
86 fn name(&self) -> &'static str {
87 Self::name(self)
88 }
89}
90
91impl Discriminant<ClaimantType> for Claimant {
92 #[must_use]
93 fn discriminant(&self) -> ClaimantType {
94 Self::discriminant(self)
95 }
96}
97
98impl Variants<ClaimantType> for Claimant {
99 fn variants() -> slice::Iter<'static, ClaimantType> {
100 Self::VARIANTS.iter()
101 }
102}
103
104impl Union<ClaimantType> for Claimant {}
105
106impl ReadXdr for Claimant {
107 #[cfg(feature = "std")]
108 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
109 r.with_limited_depth(|r| {
110 let dv: ClaimantType = <ClaimantType as ReadXdr>::read_xdr(r)?;
111 #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)]
112 let v = match dv {
113 ClaimantType::ClaimantTypeV0 => Self::ClaimantTypeV0(ClaimantV0::read_xdr(r)?),
114 #[allow(unreachable_patterns)]
115 _ => return Err(Error::Invalid),
116 };
117 Ok(v)
118 })
119 }
120}
121
122impl WriteXdr for Claimant {
123 #[cfg(feature = "std")]
124 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
125 w.with_limited_depth(|w| {
126 self.discriminant().write_xdr(w)?;
127 #[allow(clippy::match_same_arms)]
128 match self {
129 Self::ClaimantTypeV0(v) => v.write_xdr(w)?,
130 };
131 Ok(())
132 })
133 }
134}