MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / parse_network

Function parse_network

ipc/cli/src/lib.rs:77–91  ·  view source on GitHub ↗

Parse the FVM network and set the global value.

(s: &str)

Source from the content-addressed store, hash-verified

75
76/// Parse the FVM network and set the global value.
77fn parse_network(s: &str) -> Result<Network, String> {
78 match s.to_lowercase().as_str() {
79 "main" | "mainnet" | "f" => Ok(Network::Mainnet),
80 "test" | "testnet" | "t" => Ok(Network::Testnet),
81 n => {
82 let n: u8 = n
83 .parse()
84 .map_err(|e| format!("expected 0 or 1 for network: {e}"))?;
85
86 let n = Network::from_u8(n).ok_or_else(|| format!("unexpected network: {s}"))?;
87
88 Ok(n)
89 }
90 }
91}
92
93fn dir_of(path: &str) -> PathBuf {
94 let p = Path::new(path);

Callers

nothing calls this directly

Calls 2

as_strMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected