Skip to main content

stellar_xdr/generated/
set_options_op.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// SetOptionsOp is an XDR Struct defined as:
5///
6/// ```text
7/// struct SetOptionsOp
8/// {
9///     AccountID* inflationDest; // sets the inflation destination
10///
11///     uint32* clearFlags; // which flags to clear
12///     uint32* setFlags;   // which flags to set
13///
14///     // account threshold manipulation
15///     uint32* masterWeight; // weight of the master account
16///     uint32* lowThreshold;
17///     uint32* medThreshold;
18///     uint32* highThreshold;
19///
20///     string32* homeDomain; // sets the home domain
21///
22///     // Add, update or remove a signer for the account
23///     // signer is deleted if the weight is 0
24///     Signer* signer;
25/// };
26/// ```
27///
28#[cfg_attr(feature = "alloc", derive(Default))]
29#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
30#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
31#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
32#[cfg_attr(
33    all(feature = "serde", feature = "alloc"),
34    serde_with::serde_as,
35    derive(serde::Serialize, serde::Deserialize),
36    serde(rename_all = "snake_case")
37)]
38#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
39pub struct SetOptionsOp {
40    pub inflation_dest: Option<AccountId>,
41    pub clear_flags: Option<u32>,
42    pub set_flags: Option<u32>,
43    pub master_weight: Option<u32>,
44    pub low_threshold: Option<u32>,
45    pub med_threshold: Option<u32>,
46    pub high_threshold: Option<u32>,
47    pub home_domain: Option<String32>,
48    pub signer: Option<Signer>,
49}
50
51impl ReadXdr for SetOptionsOp {
52    #[cfg(feature = "std")]
53    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
54        r.with_limited_depth(|r| {
55            Ok(Self {
56                inflation_dest: Option::<AccountId>::read_xdr(r)?,
57                clear_flags: Option::<u32>::read_xdr(r)?,
58                set_flags: Option::<u32>::read_xdr(r)?,
59                master_weight: Option::<u32>::read_xdr(r)?,
60                low_threshold: Option::<u32>::read_xdr(r)?,
61                med_threshold: Option::<u32>::read_xdr(r)?,
62                high_threshold: Option::<u32>::read_xdr(r)?,
63                home_domain: Option::<String32>::read_xdr(r)?,
64                signer: Option::<Signer>::read_xdr(r)?,
65            })
66        })
67    }
68}
69
70impl WriteXdr for SetOptionsOp {
71    #[cfg(feature = "std")]
72    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
73        w.with_limited_depth(|w| {
74            self.inflation_dest.write_xdr(w)?;
75            self.clear_flags.write_xdr(w)?;
76            self.set_flags.write_xdr(w)?;
77            self.master_weight.write_xdr(w)?;
78            self.low_threshold.write_xdr(w)?;
79            self.med_threshold.write_xdr(w)?;
80            self.high_threshold.write_xdr(w)?;
81            self.home_domain.write_xdr(w)?;
82            self.signer.write_xdr(w)?;
83            Ok(())
84        })
85    }
86}