From 9f5c04089386a4c134cfec78b4f2f27cf7f112b1 Mon Sep 17 00:00:00 2001 From: Lucien Cartier-Tilet Date: Fri, 27 Mar 2020 23:27:00 +0100 Subject: [PATCH] Added documentation --- src/settings/utils.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/settings/utils.rs b/src/settings/utils.rs index ece95b5..22129b7 100644 --- a/src/settings/utils.rs +++ b/src/settings/utils.rs @@ -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 { let extension = match path.extension() { None => {