Skip to main content

stellar_xdr/generated/
inner_transaction_result.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// InnerTransactionResult is an XDR Struct defined as:
5///
6/// ```text
7/// struct InnerTransactionResult
8/// {
9///     // Always 0. Here for binary compatibility.
10///     int64 feeCharged;
11///
12///     union switch (TransactionResultCode code)
13///     {
14///     // txFEE_BUMP_INNER_SUCCESS is not included
15///     case txSUCCESS:
16///     case txFAILED:
17///         OperationResult results<>;
18///     case txTOO_EARLY:
19///     case txTOO_LATE:
20///     case txMISSING_OPERATION:
21///     case txBAD_SEQ:
22///     case txBAD_AUTH:
23///     case txINSUFFICIENT_BALANCE:
24///     case txNO_ACCOUNT:
25///     case txINSUFFICIENT_FEE:
26///     case txBAD_AUTH_EXTRA:
27///     case txINTERNAL_ERROR:
28///     case txNOT_SUPPORTED:
29///     // txFEE_BUMP_INNER_FAILED is not included
30///     case txBAD_SPONSORSHIP:
31///     case txBAD_MIN_SEQ_AGE_OR_GAP:
32///     case txMALFORMED:
33///     case txSOROBAN_INVALID:
34///     case txFROZEN_KEY_ACCESSED:
35///         void;
36///     }
37///     result;
38///
39///     // reserved for future use
40///     union switch (int v)
41///     {
42///     case 0:
43///         void;
44///     }
45///     ext;
46/// };
47/// ```
48///
49#[cfg_attr(feature = "alloc", derive(Default))]
50#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
51#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
52#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
53#[cfg_attr(
54    all(feature = "serde", feature = "alloc"),
55    serde_with::serde_as,
56    derive(serde::Serialize, serde::Deserialize),
57    serde(rename_all = "snake_case")
58)]
59#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
60pub struct InnerTransactionResult {
61    #[cfg_attr(
62        all(feature = "serde", feature = "alloc"),
63        serde_as(as = "NumberOrString")
64    )]
65    pub fee_charged: i64,
66    pub result: InnerTransactionResultResult,
67    pub ext: InnerTransactionResultExt,
68}
69
70impl ReadXdr for InnerTransactionResult {
71    #[cfg(feature = "std")]
72    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
73        r.with_limited_depth(|r| {
74            Ok(Self {
75                fee_charged: i64::read_xdr(r)?,
76                result: InnerTransactionResultResult::read_xdr(r)?,
77                ext: InnerTransactionResultExt::read_xdr(r)?,
78            })
79        })
80    }
81}
82
83impl WriteXdr for InnerTransactionResult {
84    #[cfg(feature = "std")]
85    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
86        w.with_limited_depth(|w| {
87            self.fee_charged.write_xdr(w)?;
88            self.result.write_xdr(w)?;
89            self.ext.write_xdr(w)?;
90            Ok(())
91        })
92    }
93}