stellar_xdr/generated/stellar_value.rs
1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// StellarValue is an XDR Struct defined as:
5///
6/// ```text
7/// struct StellarValue
8/// {
9/// Hash txSetHash; // transaction set to apply to previous ledger
10/// TimePoint closeTime; // network close time
11///
12/// // upgrades to apply to the previous ledger (usually empty)
13/// // this is a vector of encoded 'LedgerUpgrade' so that nodes can drop
14/// // unknown steps during consensus if needed.
15/// // see notes below on 'LedgerUpgrade' for more detail
16/// // max size is dictated by number of upgrade types (+ room for future)
17/// UpgradeType upgrades<6>;
18///
19/// // reserved for future use
20/// union switch (StellarValueType v)
21/// {
22/// case STELLAR_VALUE_BASIC:
23/// void;
24/// case STELLAR_VALUE_SIGNED:
25/// LedgerCloseValueSignature lcValueSignature;
26/// #ifdef CAP_0083
27/// case STELLAR_VALUE_EMPTY_TX_SET:
28/// struct
29/// {
30/// Hash txSetHash;
31/// Hash previousLedgerHash;
32/// uint32 previousLedgerVersion;
33/// LedgerCloseValueSignature lcValueSignature;
34/// } proposedValue;
35/// #endif
36/// }
37/// ext;
38/// };
39/// ```
40///
41#[cfg_attr(feature = "alloc", derive(Default))]
42#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
43#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
44#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
45#[cfg_attr(
46 all(feature = "serde", feature = "alloc"),
47 serde_with::serde_as,
48 derive(serde::Serialize, serde::Deserialize),
49 serde(rename_all = "snake_case")
50)]
51#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
52pub struct StellarValue {
53 pub tx_set_hash: Hash,
54 pub close_time: TimePoint,
55 pub upgrades: VecM<UpgradeType, 6>,
56 pub ext: StellarValueExt,
57}
58
59impl ReadXdr for StellarValue {
60 #[cfg(feature = "std")]
61 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
62 r.with_limited_depth(|r| {
63 Ok(Self {
64 tx_set_hash: Hash::read_xdr(r)?,
65 close_time: TimePoint::read_xdr(r)?,
66 upgrades: VecM::<UpgradeType, 6>::read_xdr(r)?,
67 ext: StellarValueExt::read_xdr(r)?,
68 })
69 })
70 }
71}
72
73impl WriteXdr for StellarValue {
74 #[cfg(feature = "std")]
75 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
76 w.with_limited_depth(|w| {
77 self.tx_set_hash.write_xdr(w)?;
78 self.close_time.write_xdr(w)?;
79 self.upgrades.write_xdr(w)?;
80 self.ext.write_xdr(w)?;
81 Ok(())
82 })
83 }
84}