fn do_save(cfg: Option<ChildStatusConfig>) -> Result<(), std::io::Error> {
        let cfg_file;
        unsafe {
            match CONFIG_FILE.clone() {
                Some(cfg) => cfg_file = cfg,
                None => {
                    // If a configuration file wasn't specified, nothing has to
                    // be done.
                    return Ok(());
                }
            }
        }

        debug!("Saving child status");
        let mut status_cfg = match cfg {
            Some(cfg) => cfg,
            None => ChildStatusConfig {
                status: HashMap::new(),
            },
        };

        instances().iter().for_each(|nexus| {
            nexus.children.iter().for_each(|child| {
                status_cfg.status.insert(child.name.clone(), child.state());
            });
        });

        match serde_yaml::to_string(&status_cfg) {
            Ok(s) => {
                let mut cfg_file = File::create(cfg_file)?;
                cfg_file.write_all(s.as_bytes())
            }
            Err(_) => Err(std::io::Error::new(
                std::io::ErrorKind::Other,
                "failed to serialize status config",
            )),
        }
    }
/// Save the status of all children to the configuration file.
Save the status of all children to the configuration file.
Save the status of all children to the configuration file .
fn do_save(cfg: Option<ChildStatusConfig>) -> Result<(), std::io::Error> {
        let cfg_file;
        unsafe {
            match CONFIG_FILE.clone() {
                Some(cfg) => cfg_file = cfg,
                None => {
                    // If a configuration file wasn't specified, nothing has to
                    // be done.
                    return Ok(());
                }
            }
        }
        debug!("Saving child status");
        let mut status_cfg = match cfg {
            Some(cfg) => cfg,
            None => ChildStatusConfig {
                status: HashMap::new(),
            },
        };
        instances().iter().for_each(|nexus| {
            nexus.children.iter().for_each(|child| {
                status_cfg.status.insert(child.name.clone(), child.state());
            });
        });
        match serde_yaml::to_string(&status_cfg) {
            Ok(s) => {
                let mut cfg_file = File::create(cfg_file)?;
                cfg_file.write_all(s.as_bytes())
            }
            Err(_) => Err(std::io::Error::new(
                std::io::ErrorKind::Other,
                "failed to serialize status config",
            )),
        }
    }
fn do_save ( cfg : Option < ChildStatusConfig > ) -> Result < ( ) , std :: io :: Error > { let cfg_file ; unsafe { match CONFIG_FILE . clone ( ) { Some ( cfg ) => cfg_file = cfg , None => { // If a configuration file wasn't specified, nothing has to // be done. return Ok ( ( ) ) ; } } } debug ! ( " " ) ; let mut status_cfg = match cfg { Some ( cfg ) => cfg , None => ChildStatusConfig { status : HashMap :: new ( ) , } , } ; instances ( ) . iter ( ) . for_each ( | nexus | { nexus . children . iter ( ) . for_each ( | child | { status_cfg . status . insert ( child . name . clone ( ) , child . state ( ) ) ; } ) ; } ) ; match serde_yaml :: to_string ( & status_cfg ) { Ok ( s ) => { let mut cfg_file = File :: create ( cfg_file ) ? ; cfg_file . write_all ( s . as_bytes ( ) ) } Err ( _ ) => Err ( std :: io :: Error :: new ( std :: io :: ErrorKind :: Other , " " , ) ) , } }
Save the status of all children to the configuration file.
Save the status of all children to the configuration file .
cfg
Option<ChildStatusConfig>