MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / parse_network

Function parse_network

ipc/cli/src/lib.rs:69–83  ·  view source on GitHub ↗

Parse the FVM network and set the global value.

(s: &str)

Source from the content-addressed store, hash-verified

67
68/// Parse the FVM network and set the global value.
69fn parse_network(s: &str) -> Result<Network, String> {
70 match s.to_lowercase().as_str() {
71 "main" | "mainnet" | "f" => Ok(Network::Mainnet),
72 "test" | "testnet" | "t" => Ok(Network::Testnet),
73 n => {
74 let n: u8 = n
75 .parse()
76 .map_err(|e| format!("expected 0 or 1 for network: {e}"))?;
77
78 let n = Network::from_u8(n).ok_or_else(|| format!("unexpected network: {s}"))?;
79
80 Ok(n)
81 }
82 }
83}

Callers

nothing calls this directly

Calls 2

as_strMethod · 0.80
parseMethod · 0.80

Tested by

no test coverage detected