Skip to main content

stellar_xdr/generated/
liabilities.rs

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