rustywallet_address/
network.rs

1//! Network types for address generation.
2
3/// Supported blockchain networks.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum Network {
6    /// Bitcoin Mainnet
7    BitcoinMainnet,
8    /// Bitcoin Testnet
9    BitcoinTestnet,
10    /// Ethereum (network-agnostic)
11    Ethereum,
12}
13
14impl Network {
15    /// Returns true if this is a Bitcoin network.
16    #[inline]
17    pub fn is_bitcoin(&self) -> bool {
18        matches!(self, Network::BitcoinMainnet | Network::BitcoinTestnet)
19    }
20
21    /// Returns true if this is Ethereum.
22    #[inline]
23    pub fn is_ethereum(&self) -> bool {
24        matches!(self, Network::Ethereum)
25    }
26
27    /// Returns true if this is a testnet.
28    #[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}