Skip to main content

stellar_xdr/generated/
sc_spec_udt_struct_v0.rs

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