Skip to main content

stellar_xdr/generated/
survey_request_message.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// SurveyRequestMessage is an XDR Struct defined as:
5///
6/// ```text
7/// struct SurveyRequestMessage
8/// {
9///     NodeID surveyorPeerID;
10///     NodeID surveyedPeerID;
11///     uint32 ledgerNum;
12///     Curve25519Public encryptionKey;
13///     SurveyMessageCommandType commandType;
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 SurveyRequestMessage {
29    pub surveyor_peer_id: NodeId,
30    pub surveyed_peer_id: NodeId,
31    pub ledger_num: u32,
32    pub encryption_key: Curve25519Public,
33    pub command_type: SurveyMessageCommandType,
34}
35
36impl ReadXdr for SurveyRequestMessage {
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                surveyor_peer_id: NodeId::read_xdr(r)?,
42                surveyed_peer_id: NodeId::read_xdr(r)?,
43                ledger_num: u32::read_xdr(r)?,
44                encryption_key: Curve25519Public::read_xdr(r)?,
45                command_type: SurveyMessageCommandType::read_xdr(r)?,
46            })
47        })
48    }
49}
50
51impl WriteXdr for SurveyRequestMessage {
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.surveyor_peer_id.write_xdr(w)?;
56            self.surveyed_peer_id.write_xdr(w)?;
57            self.ledger_num.write_xdr(w)?;
58            self.encryption_key.write_xdr(w)?;
59            self.command_type.write_xdr(w)?;
60            Ok(())
61        })
62    }
63}