async fn read_and_parse_file(path: &Path) -> Result<Self, ConfigError> {
        // find the extension of the file we're going to open. the extension of the file determines
        // the method in which we parse, i.e. "yaml" would be parsed as a YAML configuration file.
        let ext = path.extension().and_then(|e| e.to_str());

        // match based on if we read successfully and the extension of the file
        match (fs::read_to_string(path).await, ext) {
            // successfully read a yaml file
            (Ok(content), Some("yaml")) => {
                serde_yaml::from_str(&content).map_err(ConfigError::YamlParseError)
            }
            // successfully read a json file
            (Ok(content), Some("json")) => {
                serde_json::from_str(&content).map_err(ConfigError::JsonParseError)
            }

            // there was some sort of error reading the file so log as warning and continue
            // through rest of files
            (Err(e), _) => Err(ConfigError::IoError(e)),

            // weird and unexpected case. just dump variables to console
            (a, b) => {
                log::error!(
                    "unexpected case in match statement occurred, vardump: {:?} {:?}",
                    a,
                    b
                );
                Err(ConfigError::UnexpectedProblem)
            }
        }
    }
/// Opens a file and parses into a [AppConfig](Self). Returns Some if it is successful and None
/// if not. No success might be for various reasons (which are stderr logged).
///
/// How the file is parsed is determined by the extension of the file, i.e. *.yaml will be
/// parsed using a yaml parser, *.json will be parsed using a json parser.
Opens a file and parses into a [AppConfig](Self). Returns Some if it is successful and None
if not. No success might be for various reasons (which are stderr logged).


Opens a file and parses into a [ AppConfig ] ( Self ) . Returns Some if it is successful and None if not . No success might be for various reasons ( which are stderr logged ) .
async fn read_and_parse_file(path: &Path) -> Result<Self, ConfigError> {
        // find the extension of the file we're going to open. the extension of the file determines
        // the method in which we parse, i.e. "yaml" would be parsed as a YAML configuration file.
        let ext = path.extension().and_then(|e| e.to_str());
        // match based on if we read successfully and the extension of the file
        match (fs::read_to_string(path).await, ext) {
            // successfully read a yaml file
            (Ok(content), Some("yaml")) => {
                serde_yaml::from_str(&content).map_err(ConfigError::YamlParseError)
            }
            // successfully read a json file
            (Ok(content), Some("json")) => {
                serde_json::from_str(&content).map_err(ConfigError::JsonParseError)
            }
            // there was some sort of error reading the file so log as warning and continue
            // through rest of files
            (Err(e), _) => Err(ConfigError::IoError(e)),
            // weird and unexpected case. just dump variables to console
            (a, b) => {
                log::error!(
                    "unexpected case in match statement occurred, vardump: {:?} {:?}",
                    a,
                    b
                );
                Err(ConfigError::UnexpectedProblem)
            }
        }
    }
async fn read_and_parse_file ( path : & Path ) -> Result < Self , ConfigError > { // find the extension of the file we're going to open. the extension of the file determines // the method in which we parse, i.e. "yaml" would be parsed as a YAML configuration file. let ext = path . extension ( ) . and_then ( | e | e . to_str ( ) ) ; // match based on if we read successfully and the extension of the file match ( fs :: read_to_string ( path ) . await , ext ) { // successfully read a yaml file ( Ok ( content ) , Some ( " " ) ) => { serde_yaml :: from_str ( & content ) . map_err ( ConfigError :: YamlParseError ) } // successfully read a json file ( Ok ( content ) , Some ( " " ) ) => { serde_json :: from_str ( & content ) . map_err ( ConfigError :: JsonParseError ) } // there was some sort of error reading the file so log as warning and continue // through rest of files ( Err ( e ) , _ ) => Err ( ConfigError :: IoError ( e ) ) , // weird and unexpected case. just dump variables to console ( a , b ) => { log :: error ! ( " " a b ) ; Err ( ConfigError :: UnexpectedProblem ) } } }
Opens a file and parses into a [AppConfig](Self).
Opens a file and parses into a [ AppConfig ] ( Self ) .
path
&Path