mithril_common/entities/
mithril_network.rs1use std::str::FromStr;
2
3use crate::StdError;
4
5#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct MithrilNetwork(String);
8
9impl MithrilNetwork {
10 pub fn new(name: String) -> Self {
12 Self(name)
13 }
14
15 pub fn dummy() -> Self {
17 Self("dummy".to_string())
18 }
19
20 pub fn name(&self) -> &str {
22 &self.0
23 }
24}
25
26impl From<String> for MithrilNetwork {
27 fn from(name: String) -> Self {
28 MithrilNetwork::new(name)
29 }
30}
31
32impl From<&str> for MithrilNetwork {
33 fn from(name: &str) -> Self {
34 MithrilNetwork::new(name.to_string())
35 }
36}
37
38impl FromStr for MithrilNetwork {
39 type Err = StdError;
40
41 fn from_str(s: &str) -> Result<Self, Self::Err> {
42 Ok(MithrilNetwork::new(s.to_string()))
43 }
44}