pub fn network_definition(
    name: String,
) -> Result<HashMap<String, serde_json::Value>, anyhow::Error> {
    let mut res: HashMap<String, serde_json::Value> = serde_json::from_reader(
        std::fs::File::open(format!("testdata/networks/{}.json", name))?,
    )?;

    if let serde_json::Value::Object(config) = res.clone().get("config").unwrap() {
        let mut new_config = config.clone();
        new_config.insert(
            "name".to_string(),
            serde_json::Value::String(randstring(30)),
        );

        res.insert("config".to_string(), serde_json::Value::Object(new_config));
    }

    Ok(res)
}
// extract a network definiton from testdata. templates in a new name.
extract a network definiton from testdata. templates in a new name.
extract a network definiton from testdata . templates in a new name .
pub fn network_definition(
    name: String,
) -> Result<HashMap<String, serde_json::Value>, anyhow::Error> {
    let mut res: HashMap<String, serde_json::Value> = serde_json::from_reader(
        std::fs::File::open(format!("testdata/networks/{}.json", name))?,
    )?;
    if let serde_json::Value::Object(config) = res.clone().get("config").unwrap() {
        let mut new_config = config.clone();
        new_config.insert(
            "name".to_string(),
            serde_json::Value::String(randstring(30)),
        );
        res.insert("config".to_string(), serde_json::Value::Object(new_config));
    }
    Ok(res)
}
pub fn network_definition ( name : String , ) -> Result < HashMap < String , serde_json :: Value > , anyhow :: Error > { let mut res : HashMap < String , serde_json :: Value > = serde_json :: from_reader ( std :: fs :: File :: open ( format ! ( " " name ) ) ? , ) ? ; if let serde_json :: Value :: Object ( config ) = res . clone ( ) . get ( " " ) . unwrap ( ) { let mut new_config = config . clone ( ) ; new_config . insert ( " " . to_string ( ) , serde_json :: Value :: String ( randstring ( 30 ) ) , ) ; res . insert ( " " . to_string ( ) , serde_json :: Value :: Object ( new_config ) ) ; } Ok ( res ) }
extract a network definiton from testdata.
extract a network definiton from testdata .
name
String
name
String