stellar_xdr/generated/
int256_parts.rs1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4#[cfg_attr(feature = "alloc", derive(Default))]
16#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
17#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
18#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
19#[cfg_attr(
20 all(feature = "serde", feature = "alloc"),
21 derive(serde_with::SerializeDisplay)
22)]
23pub struct Int256Parts {
24 pub hi_hi: i64,
25 pub hi_lo: u64,
26 pub lo_hi: u64,
27 pub lo_lo: u64,
28}
29
30impl ReadXdr for Int256Parts {
31 #[cfg(feature = "std")]
32 fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
33 r.with_limited_depth(|r| {
34 Ok(Self {
35 hi_hi: i64::read_xdr(r)?,
36 hi_lo: u64::read_xdr(r)?,
37 lo_hi: u64::read_xdr(r)?,
38 lo_lo: u64::read_xdr(r)?,
39 })
40 })
41 }
42}
43
44impl WriteXdr for Int256Parts {
45 #[cfg(feature = "std")]
46 fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
47 w.with_limited_depth(|w| {
48 self.hi_hi.write_xdr(w)?;
49 self.hi_lo.write_xdr(w)?;
50 self.lo_hi.write_xdr(w)?;
51 self.lo_lo.write_xdr(w)?;
52 Ok(())
53 })
54 }
55}
56#[cfg(all(feature = "serde", feature = "alloc"))]
57impl<'de> serde::Deserialize<'de> for Int256Parts {
58 fn deserialize<D>(deserializer: D) -> core::result::Result<Self, D::Error>
59 where
60 D: serde::Deserializer<'de>,
61 {
62 use serde::Deserialize;
63 #[derive(Deserialize)]
64 struct Int256Parts {
65 hi_hi: i64,
66 hi_lo: u64,
67 lo_hi: u64,
68 lo_lo: u64,
69 }
70 #[derive(Deserialize)]
71 #[serde(untagged)]
72 enum Int256PartsOrString<'a> {
73 Str(&'a str),
74 String(String),
75 Int256Parts(Int256Parts),
76 }
77 match Int256PartsOrString::deserialize(deserializer)? {
78 Int256PartsOrString::Str(s) => s.parse().map_err(serde::de::Error::custom),
79 Int256PartsOrString::String(s) => s.parse().map_err(serde::de::Error::custom),
80 Int256PartsOrString::Int256Parts(Int256Parts {
81 hi_hi,
82 hi_lo,
83 lo_hi,
84 lo_lo,
85 }) => Ok(self::Int256Parts {
86 hi_hi,
87 hi_lo,
88 lo_hi,
89 lo_lo,
90 }),
91 }
92 }
93}