Skip to main content

stellar_xdr/generated/
pool_id.rs

1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4/// PoolId is an XDR Typedef defined as:
5///
6/// ```text
7/// typedef Hash PoolID;
8/// ```
9///
10#[cfg_attr(feature = "serde", cfg_eval::cfg_eval)]
11#[cfg_attr(feature = "alloc", derive(Default))]
12#[derive(Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
13#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]
14#[cfg_attr(
15    all(feature = "serde", feature = "alloc"),
16    derive(serde_with::SerializeDisplay, serde_with::DeserializeFromStr)
17)]
18#[derive(Debug)]
19pub struct PoolId(pub Hash);
20
21impl From<PoolId> for Hash {
22    #[must_use]
23    fn from(x: PoolId) -> Self {
24        x.0
25    }
26}
27
28impl From<Hash> for PoolId {
29    #[must_use]
30    fn from(x: Hash) -> Self {
31        PoolId(x)
32    }
33}
34
35impl AsRef<Hash> for PoolId {
36    #[must_use]
37    fn as_ref(&self) -> &Hash {
38        &self.0
39    }
40}
41
42impl ReadXdr for PoolId {
43    #[cfg(feature = "std")]
44    fn read_xdr<R: Read>(r: &mut Limited<R>) -> Result<Self, Error> {
45        r.with_limited_depth(|r| {
46            let i = Hash::read_xdr(r)?;
47            let v = PoolId(i);
48            Ok(v)
49        })
50    }
51}
52
53impl WriteXdr for PoolId {
54    #[cfg(feature = "std")]
55    fn write_xdr<W: Write>(&self, w: &mut Limited<W>) -> Result<(), Error> {
56        w.with_limited_depth(|w| self.0.write_xdr(w))
57    }
58}