Skip to main content

stellar_xdr/generated/
allow_trust_op.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// AllowTrustOp is an XDR Struct defined as:
5///
6/// ```text
7/// struct AllowTrustOp
8/// {
9///     AccountID trustor;
10///     AssetCode asset;
11///
12///     // One of 0, AUTHORIZED_FLAG, or AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG
13///     uint32 authorize;
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 AllowTrustOp {
29    pub trustor: AccountId,
30    pub asset: AssetCode,
31    pub authorize: u32,
32}
33
34impl ReadXdr for AllowTrustOp {
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                trustor: AccountId::read_xdr(r)?,
40                asset: AssetCode::read_xdr(r)?,
41                authorize: u32::read_xdr(r)?,
42            })
43        })
44    }
45}
46
47impl WriteXdr for AllowTrustOp {
48    #[cfg(feature = "std")]
49    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
50        w.with_limited_depth(|w| {
51            self.trustor.write_xdr(w)?;
52            self.asset.write_xdr(w)?;
53            self.authorize.write_xdr(w)?;
54            Ok(())
55        })
56    }
57}