rustywallet_address/
network.rs1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum Network {
6 BitcoinMainnet,
8 BitcoinTestnet,
10 Ethereum,
12}
13
14impl Network {
15 #[inline]
17 pub fn is_bitcoin(&self) -> bool {
18 matches!(self, Network::BitcoinMainnet | Network::BitcoinTestnet)
19 }
20
21 #[inline]
23 pub fn is_ethereum(&self) -> bool {
24 matches!(self, Network::Ethereum)
25 }
26
27 #[inline]
29 pub fn is_testnet(&self) -> bool {
30 matches!(self, Network::BitcoinTestnet)
31 }
32}
33
34impl std::fmt::Display for Network {
35 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36 match self {
37 Network::BitcoinMainnet => write!(f, "Bitcoin Mainnet"),
38 Network::BitcoinTestnet => write!(f, "Bitcoin Testnet"),
39 Network::Ethereum => write!(f, "Ethereum"),
40 }
41 }
42}