stellar_xdr/generated/ledger_entry.rs
1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// LedgerEntry is an XDR Struct defined as:
5///
6/// ```text
7/// struct LedgerEntry
8/// {
9/// uint32 lastModifiedLedgerSeq; // ledger the LedgerEntry was last changed
10///
11/// union switch (LedgerEntryType type)
12/// {
13/// case ACCOUNT:
14/// AccountEntry account;
15/// case TRUSTLINE:
16/// TrustLineEntry trustLine;
17/// case OFFER:
18/// OfferEntry offer;
19/// case DATA:
20/// DataEntry data;
21/// case CLAIMABLE_BALANCE:
22/// ClaimableBalanceEntry claimableBalance;
23/// case LIQUIDITY_POOL:
24/// LiquidityPoolEntry liquidityPool;
25/// case CONTRACT_DATA:
26/// ContractDataEntry contractData;
27/// case CONTRACT_CODE:
28/// ContractCodeEntry contractCode;
29/// case CONFIG_SETTING:
30/// ConfigSettingEntry configSetting;
31/// case TTL:
32/// TTLEntry ttl;
33/// }
34/// data;
35///
36/// // reserved for future use
37/// union switch (int v)
38/// {
39/// case 0:
40/// void;
41/// case 1:
42/// LedgerEntryExtensionV1 v1;
43/// }
44/// ext;
45/// };
46/// ```
47///
48#[cfg_attr(feature = "alloc", derive(Default))]
49#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
50#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
51#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
52#[cfg_attr(
53 all(feature = "serde", feature = "alloc"),
54 serde_with::serde_as,
55 derive(serde::Serialize, serde::Deserialize),
56 serde(rename_all = "snake_case")
57)]
58#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
59pub struct LedgerEntry {
60 pub last_modified_ledger_seq: u32,
61 pub data: LedgerEntryData,
62 pub ext: LedgerEntryExt,
63}
64
65impl ReadXdr for LedgerEntry {
66 #[cfg(feature = "std")]
67 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
68 r.with_limited_depth(|r| {
69 Ok(Self {
70 last_modified_ledger_seq: u32::read_xdr(r)?,
71 data: LedgerEntryData::read_xdr(r)?,
72 ext: LedgerEntryExt::read_xdr(r)?,
73 })
74 })
75 }
76}
77
78impl WriteXdr for LedgerEntry {
79 #[cfg(feature = "std")]
80 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
81 w.with_limited_depth(|w| {
82 self.last_modified_ledger_seq.write_xdr(w)?;
83 self.data.write_xdr(w)?;
84 self.ext.write_xdr(w)?;
85 Ok(())
86 })
87 }
88}