Skip to main content

stellar_xdr/generated/
scp_statement_confirm.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// ScpStatementConfirm is an XDR NestedStruct defined as:
5///
6/// ```text
7/// struct
8///         {
9///             SCPBallot ballot;   // b
10///             uint32 nPrepared;   // p.n
11///             uint32 nCommit;     // c.n
12///             uint32 nH;          // h.n
13///             Hash quorumSetHash; // D
14///         }
15/// ```
16///
17#[cfg_attr(feature = "alloc", derive(Default))]
18#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
19#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
20#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
21#[cfg_attr(
22    all(feature = "serde", feature = "alloc"),
23    serde_with::serde_as,
24    derive(serde::Serialize, serde::Deserialize),
25    serde(rename_all = "snake_case")
26)]
27#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
28pub struct ScpStatementConfirm {
29    pub ballot: ScpBallot,
30    pub n_prepared: u32,
31    pub n_commit: u32,
32    pub n_h: u32,
33    pub quorum_set_hash: Hash,
34}
35
36impl ReadXdr for ScpStatementConfirm {
37    #[cfg(feature = "std")]
38    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
39        r.with_limited_depth(|r| {
40            Ok(Self {
41                ballot: ScpBallot::read_xdr(r)?,
42                n_prepared: u32::read_xdr(r)?,
43                n_commit: u32::read_xdr(r)?,
44                n_h: u32::read_xdr(r)?,
45                quorum_set_hash: Hash::read_xdr(r)?,
46            })
47        })
48    }
49}
50
51impl WriteXdr for ScpStatementConfirm {
52    #[cfg(feature = "std")]
53    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
54        w.with_limited_depth(|w| {
55            self.ballot.write_xdr(w)?;
56            self.n_prepared.write_xdr(w)?;
57            self.n_commit.write_xdr(w)?;
58            self.n_h.write_xdr(w)?;
59            self.quorum_set_hash.write_xdr(w)?;
60            Ok(())
61        })
62    }
63}