chaincraft_rust/
types.rs

1//! Common type definitions
2
3use serde::{Deserialize, Serialize};
4use std::fmt;
5
6/// Block hash type
7#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
8pub struct BlockHash(pub String);
9
10impl fmt::Display for BlockHash {
11    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
12        write!(f, "{}", self.0)
13    }
14}
15
16/// Transaction hash type
17#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
18pub struct TxHash(pub String);
19
20impl fmt::Display for TxHash {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        write!(f, "{}", self.0)
23    }
24}
25
26/// Chain identifier
27#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
28pub struct ChainId(pub String);
29
30impl fmt::Display for ChainId {
31    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32        write!(f, "{}", self.0)
33    }
34}