cc-core 0.2.1

A core library for configuration, MySQL and Redis connection management
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use cc_core::ConfigBuilder;

fn main() -> anyhow::Result<()> {
    // 从文件加载
    let config = ConfigBuilder::from_file("config/config.toml")?.build()?;

    if let Some(mysql_config) = config.mysql("default") {
        println!("MySQL: {}:{}", mysql_config.host, mysql_config.port);
    }

    if let Some(redis_config) = config.redis("default") {
        println!("Redis: {}", redis_config.url);
    }

    Ok(())
}