stellar_xdr/generated/
tx_set_component.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 TxSetComponent {
31 TxsetCompTxsMaybeDiscountedFee(TxSetComponentTxsMaybeDiscountedFee),
32}
33
34#[cfg(feature = "alloc")]
35impl Default for TxSetComponent {
36 fn default() -> Self {
37 Self::TxsetCompTxsMaybeDiscountedFee(TxSetComponentTxsMaybeDiscountedFee::default())
38 }
39}
40
41impl TxSetComponent {
42 const _VARIANTS: &[TxSetComponentType] = &[TxSetComponentType::TxsetCompTxsMaybeDiscountedFee];
43 pub const VARIANTS: [TxSetComponentType; 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] = &["TxsetCompTxsMaybeDiscountedFee"];
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::TxsetCompTxsMaybeDiscountedFee(_) => "TxsetCompTxsMaybeDiscountedFee",
67 }
68 }
69
70 #[must_use]
71 pub const fn discriminant(&self) -> TxSetComponentType {
72 #[allow(clippy::match_same_arms)]
73 match self {
74 Self::TxsetCompTxsMaybeDiscountedFee(_) => {
75 TxSetComponentType::TxsetCompTxsMaybeDiscountedFee
76 }
77 }
78 }
79
80 #[must_use]
81 pub const fn variants() -> [TxSetComponentType; Self::_VARIANTS.len()] {
82 Self::VARIANTS
83 }
84}
85
86impl Name for TxSetComponent {
87 #[must_use]
88 fn name(&self) -> &'static str {
89 Self::name(self)
90 }
91}
92
93impl Discriminant<TxSetComponentType> for TxSetComponent {
94 #[must_use]
95 fn discriminant(&self) -> TxSetComponentType {
96 Self::discriminant(self)
97 }
98}
99
100impl Variants<TxSetComponentType> for TxSetComponent {
101 fn variants() -> slice::Iter<'static, TxSetComponentType> {
102 Self::VARIANTS.iter()
103 }
104}
105
106impl Union<TxSetComponentType> for TxSetComponent {}
107
108impl ReadXdr for TxSetComponent {
109 #[cfg(feature = "std")]
110 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
111 r.with_limited_depth(|r| {
112 let dv: TxSetComponentType = <TxSetComponentType as ReadXdr>::read_xdr(r)?;
113 #[allow(clippy::match_same_arms, clippy::match_wildcard_for_single_variants)]
114 let v = match dv {
115 TxSetComponentType::TxsetCompTxsMaybeDiscountedFee => {
116 Self::TxsetCompTxsMaybeDiscountedFee(
117 TxSetComponentTxsMaybeDiscountedFee::read_xdr(r)?,
118 )
119 }
120 #[allow(unreachable_patterns)]
121 _ => return Err(Error::Invalid),
122 };
123 Ok(v)
124 })
125 }
126}
127
128impl WriteXdr for TxSetComponent {
129 #[cfg(feature = "std")]
130 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
131 w.with_limited_depth(|w| {
132 self.discriminant().write_xdr(w)?;
133 #[allow(clippy::match_same_arms)]
134 match self {
135 Self::TxsetCompTxsMaybeDiscountedFee(v) => v.write_xdr(w)?,
136 };
137 Ok(())
138 })
139 }
140}