Skip to main content

stellar_xdr/generated/
ledger_header_history_entry.rs

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