stellar_xdr/generated/
contract_id.rs1#[allow(unused_imports, clippy::wildcard_imports)]
2use super::*;
3
4#[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 ContractId(pub Hash);
20
21impl From<ContractId> for Hash {
22 #[must_use]
23 fn from(x: ContractId) -> Self {
24 x.0
25 }
26}
27
28impl From<Hash> for ContractId {
29 #[must_use]
30 fn from(x: Hash) -> Self {
31 ContractId(x)
32 }
33}
34
35impl AsRef<Hash> for ContractId {
36 #[must_use]
37 fn as_ref(&self) -> &Hash {
38 &self.0
39 }
40}
41
42impl ReadXdr for ContractId {
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 = ContractId(i);
48 Ok(v)
49 })
50 }
51}
52
53impl WriteXdr for ContractId {
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}