Added documentation
This commit is contained in:
parent
7d0a371311
commit
9f5c040893
@ -83,6 +83,30 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get the type of file to be opened based on its extension. Currently
|
||||
/// supported file types are:
|
||||
/// * JSON - `.json` extension
|
||||
/// * Yaml - `.yml` or `.yaml` extensions
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// - `path` - Path of the file to be determined
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// let file_json = std::path::Path::new("file.json");
|
||||
/// assert_eq!(lang_evolve_core::settings::utils::SettingsType::Json,
|
||||
/// lang_evolve_core::settings::utils::get_file_type(&file_json).unwrap());
|
||||
///
|
||||
/// let file_yaml = std::path::Path::new("file.yaml");
|
||||
/// assert_eq!(lang_evolve_core::settings::utils::SettingsType::Yaml,
|
||||
/// lang_evolve_core::settings::utils::get_file_type(&file_yaml).unwrap());
|
||||
///
|
||||
/// let file_yml = std::path::Path::new("file.yml");
|
||||
/// assert_eq!(lang_evolve_core::settings::utils::SettingsType::Yaml,
|
||||
/// lang_evolve_core::settings::utils::get_file_type(&file_yml).unwrap());
|
||||
/// ```
|
||||
pub fn get_file_type(path: &Path) -> Result<SettingsType> {
|
||||
let extension = match path.extension() {
|
||||
None => {
|
||||
|
Loading…
Reference in New Issue
Block a user