datasources 0.1.5

Async datasource interfaces, middleware, registry, and test doubles
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::collections::HashMap;

pub fn load(path: &str) -> HashMap<String, String> {
    std::fs::read_to_string(path)
        .map(|text| parse(&text))
        .unwrap_or_default()
}

pub fn parse(text: &str) -> HashMap<String, String> {
    text.lines()
        .filter_map(|raw| match raw.trim_start().split_once('=') {
            Some((key, value)) if !key.starts_with('#') && !key.trim().is_empty() => {
                Some((key.trim().to_string(), value.to_string()))
            }
            _ => None,
        })
        .collect()
}