sample_config/lib.rs
1#![doc = include_str!("../README.md")]
2
3mod implementations;
4
5pub use sample_config_macros::SampleConfig;
6
7/// The type of the sample config output.
8#[derive(Debug, PartialEq, Eq, Clone, Copy)]
9pub enum OutputType {
10 /// A value is put out.
11 Value,
12 /// Fields are put out (a struct or arrays).
13 Fields,
14}
15
16/// Generate sample configs for Rust data constructs automatically using an
17/// example instance.
18pub trait SampleConfig {
19 /// Whether this data construct produces a value (e.g. String) or fields
20 /// (e.g. a struct).
21 const SAMPLE_OUTPUT_TYPE: OutputType;
22
23 /// Generate a string containing the sample config in Yaml format.
24 #[cfg(feature = "yaml")]
25 fn generate_sample_yaml(&self) -> String;
26
27 /// Generate a string containing the sample config in JSON format.
28 #[cfg(feature = "json")]
29 fn generate_sample_json(&self) -> String;
30}