cder 0.2.2

database seed generator that helps create and persist struct-typed instances based on serde-compatible yaml files
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use anyhow::Result;
use std::{env, fs, path::PathBuf};

/// Read seeds from specified file
pub fn read_file(filename: &str, base_dir: &str) -> Result<String> {
    let path = env::var("CARGO_MANIFEST_DIR")
        .map(PathBuf::from)
        .unwrap_or_default()
        .join(base_dir)
        .join(filename);

    fs::read_to_string(&path)
        .map_err(|err| anyhow::anyhow!("Can't open the file: {:?}\n   err: {}", path, err))
}