Skip to main content

stellar_xdr/generated/
transaction_history_entry.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// TransactionHistoryEntry is an XDR Struct defined as:
5///
6/// ```text
7/// struct TransactionHistoryEntry
8/// {
9///     uint32 ledgerSeq;
10///     TransactionSet txSet;
11///
12///     // when v != 0, txSet must be empty
13///     union switch (int v)
14///     {
15///     case 0:
16///         void;
17///     case 1:
18///         GeneralizedTransactionSet generalizedTxSet;
19///     }
20///     ext;
21/// };
22/// ```
23///
24#[cfg_attr(feature = "alloc", derive(Default))]
25#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
26#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
27#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
28#[cfg_attr(
29    all(feature = "serde", feature = "alloc"),
30    serde_with::serde_as,
31    derive(serde::Serialize, serde::Deserialize),
32    serde(rename_all = "snake_case")
33)]
34#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
35pub struct TransactionHistoryEntry {
36    pub ledger_seq: u32,
37    pub tx_set: TransactionSet,
38    pub ext: TransactionHistoryEntryExt,
39}
40
41impl ReadXdr for TransactionHistoryEntry {
42    #[cfg(feature = "std")]
43    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
44        r.with_limited_depth(|r| {
45            Ok(Self {
46                ledger_seq: u32::read_xdr(r)?,
47                tx_set: TransactionSet::read_xdr(r)?,
48                ext: TransactionHistoryEntryExt::read_xdr(r)?,
49            })
50        })
51    }
52}
53
54impl WriteXdr for TransactionHistoryEntry {
55    #[cfg(feature = "std")]
56    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
57        w.with_limited_depth(|w| {
58            self.ledger_seq.write_xdr(w)?;
59            self.tx_set.write_xdr(w)?;
60            self.ext.write_xdr(w)?;
61            Ok(())
62        })
63    }
64}