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