Skip to main content

stellar_xdr/generated/
change_trust_op.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// ChangeTrustOp is an XDR Struct defined as:
5///
6/// ```text
7/// struct ChangeTrustOp
8/// {
9///     ChangeTrustAsset line;
10///
11///     // if limit is set to 0, deletes the trust line
12///     int64 limit;
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 ChangeTrustOp {
28    pub line: ChangeTrustAsset,
29    #[cfg_attr(
30        all(feature = "serde", feature = "alloc"),
31        serde_as(as = "NumberOrString")
32    )]
33    pub limit: i64,
34}
35
36impl ReadXdr for ChangeTrustOp {
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                line: ChangeTrustAsset::read_xdr(r)?,
42                limit: i64::read_xdr(r)?,
43            })
44        })
45    }
46}
47
48impl WriteXdr for ChangeTrustOp {
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.line.write_xdr(w)?;
53            self.limit.write_xdr(w)?;
54            Ok(())
55        })
56    }
57}