[][src]Function config_struct::create_enum_from_source

pub fn create_enum_from_source<S: AsRef<str>, P: AsRef<Path>>(
    source: S,
    destination: P,
    options: &EnumOptions
) -> Result<(), Error>

Generate a Rust module containing an enum definition based on a config string containing a map-like structure. The variants of the enum are based on the keys of the map.

The format of the config must be provided in the options.

Examples

use config_struct::{Format, StructOptions};

config_struct::create_struct_from_source(
    "number = 100  # This is valid TOML.",
    "src/config.rs",
    &StructOptions {
        format: Some(Format::Toml),
        ..Default::default()
    })?;