simple/simple.rs
1use aes_config::ConfigType;
2use serde::Deserialize;
3use std::fmt::Debug;
4
5#[derive(Deserialize, Debug)]
6struct Config {
7 port: u16,
8 name: String,
9}
10
11/*
12config.toml file:
13port=10086
14name="test"
15
16encrypt_config.toml file:
17qOOX56hXnadNC5uHU36IgB1i/2OKgfgXz4PmDYmy683qUewVqsg=
18*/
19
20fn main() {
21 let salt = "abcdefghijklmnopqrstuvwxyz123456".to_string();
22 let c = aes_config::ConfigInfo::new(
23 "examples/encrypt_config.toml".to_string(),
24 Some(salt),
25 ConfigType::TOML,
26 )
27 .unwrap();
28 println!("{:#?}", c.try_get_config::<Config>().unwrap());
29}