Skip to main content

stellar_xdr/generated/
transaction_result.rs

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