Skip to main content

stellar_xdr/generated/
sc_spec_event_v0.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// ScSpecEventV0 is an XDR Struct defined as:
5///
6/// ```text
7/// struct SCSpecEventV0
8/// {
9///     string doc<SC_SPEC_DOC_LIMIT>;
10///     string lib<80>;
11///     SCSymbol name;
12///     SCSymbol prefixTopics<2>;
13///     SCSpecEventParamV0 params<>;
14///     SCSpecEventDataFormat dataFormat;
15/// };
16/// ```
17///
18#[cfg_attr(feature = "alloc", derive(Default))]
19#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
20#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
21#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
22#[cfg_attr(
23    all(feature = "serde", feature = "alloc"),
24    serde_with::serde_as,
25    derive(serde::Serialize, serde::Deserialize),
26    serde(rename_all = "snake_case")
27)]
28#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
29pub struct ScSpecEventV0 {
30    pub doc: StringM<1024>,
31    pub lib: StringM<80>,
32    pub name: ScSymbol,
33    pub prefix_topics: VecM<ScSymbol, 2>,
34    pub params: VecM<ScSpecEventParamV0>,
35    pub data_format: ScSpecEventDataFormat,
36}
37
38impl ReadXdr for ScSpecEventV0 {
39    #[cfg(feature = "std")]
40    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
41        r.with_limited_depth(|r| {
42            Ok(Self {
43                doc: StringM::<1024>::read_xdr(r)?,
44                lib: StringM::<80>::read_xdr(r)?,
45                name: ScSymbol::read_xdr(r)?,
46                prefix_topics: VecM::<ScSymbol, 2>::read_xdr(r)?,
47                params: VecM::<ScSpecEventParamV0>::read_xdr(r)?,
48                data_format: ScSpecEventDataFormat::read_xdr(r)?,
49            })
50        })
51    }
52}
53
54impl WriteXdr for ScSpecEventV0 {
55    #[cfg(feature = "std")]
56    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
57        w.with_limited_depth(|w| {
58            self.doc.write_xdr(w)?;
59            self.lib.write_xdr(w)?;
60            self.name.write_xdr(w)?;
61            self.prefix_topics.write_xdr(w)?;
62            self.params.write_xdr(w)?;
63            self.data_format.write_xdr(w)?;
64            Ok(())
65        })
66    }
67}