1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#![doc = include_str!("../README.md")]

mod implementations;

pub use sample_config_macros::SampleConfig;

/// The type of the sample config output.
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum OutputType {
	/// A value is put out.
	Value,
	/// Fields are put out (a struct or arrays).
	Fields,
}

/// Generate sample configs for Rust data constructs automatically using an
/// example instance.
pub trait SampleConfig {
	/// Whether this data construct produces a value (e.g. String) or fields
	/// (e.g. a struct).
	const SAMPLE_OUTPUT_TYPE: OutputType;

	/// Generate a string containing the sample config in Yaml format.
	#[cfg(feature = "yaml")]
	fn generate_sample_yaml(&self) -> String;
}