Skip to main content

stellar_xdr/generated/
contract_cost_param_entry.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// ContractCostParamEntry is an XDR Struct defined as:
5///
6/// ```text
7/// struct ContractCostParamEntry {
8///     // use `ext` to add more terms (e.g. higher order polynomials) in the future
9///     ExtensionPoint ext;
10///
11///     int64 constTerm;
12///     int64 linearTerm;
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 ContractCostParamEntry {
28    pub ext: ExtensionPoint,
29    #[cfg_attr(
30        all(feature = "serde", feature = "alloc"),
31        serde_as(as = "NumberOrString")
32    )]
33    pub const_term: i64,
34    #[cfg_attr(
35        all(feature = "serde", feature = "alloc"),
36        serde_as(as = "NumberOrString")
37    )]
38    pub linear_term: i64,
39}
40
41impl ReadXdr for ContractCostParamEntry {
42    #[cfg(feature = "std")]
43    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
44        r.with_limited_depth(|r| {
45            Ok(Self {
46                ext: ExtensionPoint::read_xdr(r)?,
47                const_term: i64::read_xdr(r)?,
48                linear_term: i64::read_xdr(r)?,
49            })
50        })
51    }
52}
53
54impl WriteXdr for ContractCostParamEntry {
55    #[cfg(feature = "std")]
56    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
57        w.with_limited_depth(|w| {
58            self.ext.write_xdr(w)?;
59            self.const_term.write_xdr(w)?;
60            self.linear_term.write_xdr(w)?;
61            Ok(())
62        })
63    }
64}