Skip to main content

stellar_xdr/generated/
fee_bump_transaction_inner_tx.rs

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