fn fill_logdef<'de, D>(deserializer: D) -> Result<Vec<Search>, D::Error>
where
    D: Deserializer<'de>,
{
    // get the YAML `Value` from serde. See https://docs.serde.rs/serde_yaml/enum.Value.html
    let yaml_value: Value = Deserialize::deserialize(deserializer)?;

    // transform this value into our struct
    let vec_yaml: Result<Vec<Search>, _> =
        serde_yaml::from_value(yaml_value).map_err(de::Error::custom);
    if vec_yaml.is_err() {
        return vec_yaml;
    }
    let mut vec_search = vec_yaml.unwrap();

    // this vector wil hold new logfiles from the list returned from the script execution
    let mut vec_loglist: Vec<Search> = Vec::new();

    for search in &vec_search {
        match &search.logfile.path {
            // we found a logfile tag: just copy everything to the new structure
            LogSource::LogFile(_) => continue,

            // we found a logslist tag: get the list of files, and for each one, copy everything
            LogSource::LogList(cmd) => {
                // get list of files from command or script
                let files = cmd.get_file_list().map_err(de::Error::custom)?;

                // create Search structure with the files we found, and a clone of all tags
                for file in &files {
                    // clone search structure
                    let mut cloned_search = search.clone();

                    // assign file instead of list
                    cloned_search.logfile.path = LogSource::LogFile(file.to_path_buf());

                    // now use this structure and add it to config_pathbuf
                    vec_loglist.push(cloned_search);
                }
            }

            // we found a logcommand tag: get the list of files using bash -c or cmd.exe /B, and for each one, copy everything
            LogSource::LogCommand(cmd) => {
                // get list of files from command or script
                let files = cmd.get_file_list().map_err(de::Error::custom)?;

                // create Search structure with the files we found, and a clone of all tags
                for file in &files {
                    // clone search structure
                    let mut cloned_search = search.clone();

                    // assign file instead of list
                    cloned_search.logfile.path = LogSource::LogFile(file.to_path_buf());

                    // now use this structure and add it to config_pathbuf
                    vec_loglist.push(cloned_search);
                }
            }
        }
    }

    // add all those new logfiles we found
    vec_search.extend(vec_loglist);

    // keep only valid logfiles, not logsources
    vec_search.retain(|x| x.logfile.path.is_path());
    Ok(vec_search)
}
/// Replace the `logsource` YAML tag with the result of the script command
Replace the `logsource` YAML tag with the result of the script command
Replace the ` logsource ` YAML tag with the result of the script command
fn fill_logdef<'de, D>(deserializer: D) -> Result<Vec<Search>, D::Error>
where
    D: Deserializer<'de>,
{
    // get the YAML `Value` from serde. See https://docs.serde.rs/serde_yaml/enum.Value.html
    let yaml_value: Value = Deserialize::deserialize(deserializer)?;
    // transform this value into our struct
    let vec_yaml: Result<Vec<Search>, _> =
        serde_yaml::from_value(yaml_value).map_err(de::Error::custom);
    if vec_yaml.is_err() {
        return vec_yaml;
    }
    let mut vec_search = vec_yaml.unwrap();
    // this vector wil hold new logfiles from the list returned from the script execution
    let mut vec_loglist: Vec<Search> = Vec::new();
    for search in &vec_search {
        match &search.logfile.path {
            // we found a logfile tag: just copy everything to the new structure
            LogSource::LogFile(_) => continue,
            // we found a logslist tag: get the list of files, and for each one, copy everything
            LogSource::LogList(cmd) => {
                // get list of files from command or script
                let files = cmd.get_file_list().map_err(de::Error::custom)?;
                // create Search structure with the files we found, and a clone of all tags
                for file in &files {
                    // clone search structure
                    let mut cloned_search = search.clone();
                    // assign file instead of list
                    cloned_search.logfile.path = LogSource::LogFile(file.to_path_buf());
                    // now use this structure and add it to config_pathbuf
                    vec_loglist.push(cloned_search);
                }
            }
            // we found a logcommand tag: get the list of files using bash -c or cmd.exe /B, and for each one, copy everything
            LogSource::LogCommand(cmd) => {
                // get list of files from command or script
                let files = cmd.get_file_list().map_err(de::Error::custom)?;
                // create Search structure with the files we found, and a clone of all tags
                for file in &files {
                    // clone search structure
                    let mut cloned_search = search.clone();
                    // assign file instead of list
                    cloned_search.logfile.path = LogSource::LogFile(file.to_path_buf());
                    // now use this structure and add it to config_pathbuf
                    vec_loglist.push(cloned_search);
                }
            }
        }
    }
    // add all those new logfiles we found
    vec_search.extend(vec_loglist);
    // keep only valid logfiles, not logsources
    vec_search.retain(|x| x.logfile.path.is_path());
    Ok(vec_search)
}
fn fill_logdef < ' de , D > ( deserializer : D ) -> Result < Vec < Search > , D :: Error > where D : Deserializer < ' de > , { // get the YAML `Value` from serde. See https://docs.serde.rs/serde_yaml/enum.Value.html let yaml_value : Value = Deserialize :: deserialize ( deserializer ) ? ; // transform this value into our struct let vec_yaml : Result < Vec < Search > , _ > = serde_yaml :: from_value ( yaml_value ) . map_err ( de :: Error :: custom ) ; if vec_yaml . is_err ( ) { return vec_yaml ; } let mut vec_search = vec_yaml . unwrap ( ) ; // this vector wil hold new logfiles from the list returned from the script execution let mut vec_loglist : Vec < Search > = Vec :: new ( ) ; for search in & vec_search { match & search . logfile . path { // we found a logfile tag: just copy everything to the new structure LogSource :: LogFile ( _ ) => continue , // we found a logslist tag: get the list of files, and for each one, copy everything LogSource :: LogList ( cmd ) => { // get list of files from command or script let files = cmd . get_file_list ( ) . map_err ( de :: Error :: custom ) ? ; // create Search structure with the files we found, and a clone of all tags for file in & files { // clone search structure let mut cloned_search = search . clone ( ) ; // assign file instead of list cloned_search . logfile . path = LogSource :: LogFile ( file . to_path_buf ( ) ) ; // now use this structure and add it to config_pathbuf vec_loglist . push ( cloned_search ) ; } } // we found a logcommand tag: get the list of files using bash -c or cmd.exe /B, and for each one, copy everything LogSource :: LogCommand ( cmd ) => { // get list of files from command or script let files = cmd . get_file_list ( ) . map_err ( de :: Error :: custom ) ? ; // create Search structure with the files we found, and a clone of all tags for file in & files { // clone search structure let mut cloned_search = search . clone ( ) ; // assign file instead of list cloned_search . logfile . path = LogSource :: LogFile ( file . to_path_buf ( ) ) ; // now use this structure and add it to config_pathbuf vec_loglist . push ( cloned_search ) ; } } } } // add all those new logfiles we found vec_search . extend ( vec_loglist ) ; // keep only valid logfiles, not logsources vec_search . retain ( | x | x . logfile . path . is_path ( ) ) ; Ok ( vec_search ) }
Replace the `logsource` YAML tag with the result of the script command
Replace the ` logsource ` YAML tag with the result of the script command
deserializer
D
deserializer
D