Skip to main content

stellar_xdr/generated/
persisted_scp_state_v1.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// PersistedScpStateV1 is an XDR Struct defined as:
5///
6/// ```text
7/// struct PersistedSCPStateV1
8/// {
9/// 	// Tx sets are saved separately
10/// 	SCPEnvelope scpEnvelopes<>;
11/// 	SCPQuorumSet quorumSets<>;
12/// };
13/// ```
14///
15#[cfg_attr(feature = "alloc", derive(Default))]
16#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
17#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
18#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
19#[cfg_attr(
20    all(feature = "serde", feature = "alloc"),
21    serde_with::serde_as,
22    derive(serde::Serialize, serde::Deserialize),
23    serde(rename_all = "snake_case")
24)]
25#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
26pub struct PersistedScpStateV1 {
27    pub scp_envelopes: VecM<ScpEnvelope>,
28    pub quorum_sets: VecM<ScpQuorumSet>,
29}
30
31impl ReadXdr for PersistedScpStateV1 {
32    #[cfg(feature = "std")]
33    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
34        r.with_limited_depth(|r| {
35            Ok(Self {
36                scp_envelopes: VecM::<ScpEnvelope>::read_xdr(r)?,
37                quorum_sets: VecM::<ScpQuorumSet>::read_xdr(r)?,
38            })
39        })
40    }
41}
42
43impl WriteXdr for PersistedScpStateV1 {
44    #[cfg(feature = "std")]
45    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
46        w.with_limited_depth(|w| {
47            self.scp_envelopes.write_xdr(w)?;
48            self.quorum_sets.write_xdr(w)?;
49            Ok(())
50        })
51    }
52}