Skip to main content

stellar_xdr/generated/
scp_statement_externalize.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// ScpStatementExternalize is an XDR NestedStruct defined as:
5///
6/// ```text
7/// struct
8///         {
9///             SCPBallot commit;         // c
10///             uint32 nH;                // h.n
11///             Hash commitQuorumSetHash; // D used before EXTERNALIZE
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 ScpStatementExternalize {
27    pub commit: ScpBallot,
28    pub n_h: u32,
29    pub commit_quorum_set_hash: Hash,
30}
31
32impl ReadXdr for ScpStatementExternalize {
33    #[cfg(feature = "std")]
34    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
35        r.with_limited_depth(|r| {
36            Ok(Self {
37                commit: ScpBallot::read_xdr(r)?,
38                n_h: u32::read_xdr(r)?,
39                commit_quorum_set_hash: Hash::read_xdr(r)?,
40            })
41        })
42    }
43}
44
45impl WriteXdr for ScpStatementExternalize {
46    #[cfg(feature = "std")]
47    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
48        w.with_limited_depth(|w| {
49            self.commit.write_xdr(w)?;
50            self.n_h.write_xdr(w)?;
51            self.commit_quorum_set_hash.write_xdr(w)?;
52            Ok(())
53        })
54    }
55}