Skip to main content

stellar_xdr/generated/
config_setting_contract_compute_v0.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// ConfigSettingContractComputeV0 is an XDR Struct defined as:
5///
6/// ```text
7/// struct ConfigSettingContractComputeV0
8/// {
9///     // Maximum instructions per ledger
10///     int64 ledgerMaxInstructions;
11///     // Maximum instructions per transaction
12///     int64 txMaxInstructions;
13///     // Cost of 10000 instructions
14///     int64 feeRatePerInstructionsIncrement;
15///
16///     // Memory limit per transaction. Unlike instructions, there is no fee
17///     // for memory, just the limit.
18///     uint32 txMemoryLimit;
19/// };
20/// ```
21///
22#[cfg_attr(feature = "alloc", derive(Default))]
23#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
24#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
25#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
26#[cfg_attr(
27    all(feature = "serde", feature = "alloc"),
28    serde_with::serde_as,
29    derive(serde::Serialize, serde::Deserialize),
30    serde(rename_all = "snake_case")
31)]
32#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
33pub struct ConfigSettingContractComputeV0 {
34    #[cfg_attr(
35        all(feature = "serde", feature = "alloc"),
36        serde_as(as = "NumberOrString")
37    )]
38    pub ledger_max_instructions: i64,
39    #[cfg_attr(
40        all(feature = "serde", feature = "alloc"),
41        serde_as(as = "NumberOrString")
42    )]
43    pub tx_max_instructions: i64,
44    #[cfg_attr(
45        all(feature = "serde", feature = "alloc"),
46        serde_as(as = "NumberOrString")
47    )]
48    pub fee_rate_per_instructions_increment: i64,
49    pub tx_memory_limit: u32,
50}
51
52impl ReadXdr for ConfigSettingContractComputeV0 {
53    #[cfg(feature = "std")]
54    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
55        r.with_limited_depth(|r| {
56            Ok(Self {
57                ledger_max_instructions: i64::read_xdr(r)?,
58                tx_max_instructions: i64::read_xdr(r)?,
59                fee_rate_per_instructions_increment: i64::read_xdr(r)?,
60                tx_memory_limit: u32::read_xdr(r)?,
61            })
62        })
63    }
64}
65
66impl WriteXdr for ConfigSettingContractComputeV0 {
67    #[cfg(feature = "std")]
68    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
69        w.with_limited_depth(|w| {
70            self.ledger_max_instructions.write_xdr(w)?;
71            self.tx_max_instructions.write_xdr(w)?;
72            self.fee_rate_per_instructions_increment.write_xdr(w)?;
73            self.tx_memory_limit.write_xdr(w)?;
74            Ok(())
75        })
76    }
77}