1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use super::common::{load_config, retrieve_config_value};

#[allow(dead_code)]
pub enum TableSchemaDesign {
    Schemafull,
    Schemaless,
}

pub fn retrieve_folder_path(config_file: Option<&str>) -> Option<String> {
    let config = load_config(config_file);

    if let Some(config) = config {
        retrieve_config_value(&config, "core", "path")
    } else {
        None
    }
}

#[allow(dead_code)]
pub fn retrieve_table_schema_design(config_file: Option<&str>) -> Option<TableSchemaDesign> {
    let config = load_config(config_file);

    let schema_str = if let Some(config) = config {
        retrieve_config_value(&config, "core", "schema")
    } else {
        None
    };

    match schema_str {
        Some(schema_str) => parse_table_schema_design(schema_str),
        _ => None,
    }
}

fn parse_table_schema_design(schema_str: String) -> Option<TableSchemaDesign> {
    match schema_str.to_lowercase().as_str() {
        "full" => Some(TableSchemaDesign::Schemafull),
        "less" => Some(TableSchemaDesign::Schemaless),
        _ => None,
    }
}