mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-04-01 02:05:30 +00:00
* Start work on printing toml config with comments * WIP: toml_config: extract default values for fields * WIP: toml_config: handle single-level nested structs * WIP: toml_config: improve comment handling, std type trait impls * WIP: toml_config: add Private trait, improve comment handling, clean up * toml_config: fix default value bug; improve tests * Use toml_config in all applicable crates; add toml_config enum support * toml_config: improve comments * toml_config_derive: support enum comments * Improve config comments for udp, cli_helpers, common * Improve config comments * Add tests for Config struct TomlConfig implementations * Improve Config comments * Improve Config comments * ws, http: add config comments for tls cert and private key lines * small fixes to toml_config and toml_config_derive * Run cargo fmt * Fix typo in several config comments * Update README * Update README
46 lines
983 B
Rust
46 lines
983 B
Rust
use serde::Deserialize;
|
|
|
|
use toml_config::{gen_serialize_deserialize_test, TomlConfig};
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, TomlConfig, Deserialize)]
|
|
struct TestConfigInnerA {
|
|
/// Comment for a
|
|
a: String,
|
|
/// Comment for b
|
|
b: usize,
|
|
}
|
|
|
|
impl Default for TestConfigInnerA {
|
|
fn default() -> Self {
|
|
Self {
|
|
a: "Inner hello world".into(),
|
|
b: 100,
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Comment for TestConfig
|
|
#[derive(Clone, Debug, PartialEq, Eq, TomlConfig, Deserialize)]
|
|
struct TestConfig {
|
|
/// Comment for a that stretches over
|
|
/// multiple lines
|
|
a: String,
|
|
/// Comment for b
|
|
b: usize,
|
|
c: bool,
|
|
/// Comment for TestConfigInnerA
|
|
inner_a: TestConfigInnerA,
|
|
}
|
|
|
|
impl Default for TestConfig {
|
|
fn default() -> Self {
|
|
Self {
|
|
a: "Hello, world!".into(),
|
|
b: 100,
|
|
c: true,
|
|
inner_a: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
gen_serialize_deserialize_test!(TestConfig);
|