Skip to main content

stellar_xdr/generated/
transaction_meta_v2.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// TransactionMetaV2 is an XDR Struct defined as:
5///
6/// ```text
7/// struct TransactionMetaV2
8/// {
9///     LedgerEntryChanges txChangesBefore; // tx level changes before operations
10///                                         // are applied if any
11///     OperationMeta operations<>;         // meta for each operation
12///     LedgerEntryChanges txChangesAfter;  // tx level changes after operations are
13///                                         // applied if any
14/// };
15/// ```
16///
17#[cfg_attr(feature = "alloc", derive(Default))]
18#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
19#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
20#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
21#[cfg_attr(
22    all(feature = "serde", feature = "alloc"),
23    serde_with::serde_as,
24    derive(serde::Serialize, serde::Deserialize),
25    serde(rename_all = "snake_case")
26)]
27#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
28pub struct TransactionMetaV2 {
29    pub tx_changes_before: LedgerEntryChanges,
30    pub operations: VecM<OperationMeta>,
31    pub tx_changes_after: LedgerEntryChanges,
32}
33
34impl ReadXdr for TransactionMetaV2 {
35    #[cfg(feature = "std")]
36    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
37        r.with_limited_depth(|r| {
38            Ok(Self {
39                tx_changes_before: LedgerEntryChanges::read_xdr(r)?,
40                operations: VecM::<OperationMeta>::read_xdr(r)?,
41                tx_changes_after: LedgerEntryChanges::read_xdr(r)?,
42            })
43        })
44    }
45}
46
47impl WriteXdr for TransactionMetaV2 {
48    #[cfg(feature = "std")]
49    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
50        w.with_limited_depth(|w| {
51            self.tx_changes_before.write_xdr(w)?;
52            self.operations.write_xdr(w)?;
53            self.tx_changes_after.write_xdr(w)?;
54            Ok(())
55        })
56    }
57}