Struct config_struct::Options [−][src]
pub struct Options { pub struct_name: String, pub const_name: Option<String>, pub generate_const: bool, pub derived_traits: Vec<String>, pub generate_load_fns: bool, pub dynamic_loading: DynamicLoading, pub create_dirs: bool, pub default_float_size: FloatSize, pub default_int_size: IntSize, pub max_array_size: usize, }
Options for configuring the generation of a config struct.
Fields
struct_name: String
The name of the resulting struct. Defaults to "Config"
.
const_name: Option<String>
The name of the resulting const, if generated.
Defaults to the value of struct_name
in uppercase.
generate_const: bool
Whether or not to generate a const
instance of the struct.
Defaults to true
.
derived_traits: Vec<String>
A list of traits for the struct to derive. Defaults to ["Debug", "Clone", "Serialize", "Deserialize"]
Note: if you include Serialize
/Deserialize
, you must also include
the serde
and serde_derive
crates in the crate that uses the generated
config module.
generate_load_fns: bool
Whether or not to generate helper functions to load the struct at runtime.
Defaults to true
.
Note: if you enable the generation of dynamic loading functions, you must also include the relevant deserialization crate in the crate that uses the generated config module.
For example, if you generate a config based on "config.json", you must also
include extern crate serde_json
in your crate. Likewise with toml
,
ron
, and serde_yaml
for the other supported formats.
dynamic_loading: DynamicLoading
Whether the load functions, if generated, are dynamic, and when.
Defaults to DebugOnly
.
create_dirs: bool
Whether or not to create the parent directories of the output file, if
they don't exist. Defaults to true
.
default_float_size: FloatSize
The type of floating point values in the config, where the format does not make it explicit.
Defaults to F64
.
default_int_size: IntSize
The type of integer values in the config, where the format does not make it explicit.
Defaults to I64
.
max_array_size: usize
The maximum array size, over which array values in the config will be
represented as slices instead. If set to 0
, slices will always be used.
Defaults to 0
.
Methods
impl Options
[src]
impl Options
pub fn validate(&self) -> Result<(), OptionsError>
[src]
pub fn validate(&self) -> Result<(), OptionsError>
pub fn real_const_name(&self) -> String
[src]
pub fn real_const_name(&self) -> String
Trait Implementations
impl Debug for Options
[src]
impl Debug for Options
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Clone for Options
[src]
impl Clone for Options
fn clone(&self) -> Options
[src]
fn clone(&self) -> Options
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl PartialEq for Options
[src]
impl PartialEq for Options
fn eq(&self, other: &Options) -> bool
[src]
fn eq(&self, other: &Options) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Options) -> bool
[src]
fn ne(&self, other: &Options) -> bool
This method tests for !=
.
impl Eq for Options
[src]
impl Eq for Options
impl Default for Options
[src]
impl Default for Options
fn default() -> Self
[src]
fn default() -> Self
use config_struct::*; Options { struct_name: "Config".to_owned(), const_name: None, generate_const: true, derived_traits: vec![ "Debug".to_owned(), "Clone".to_owned(), "Serialize".to_owned(), "Deserialize".to_owned(), ], generate_load_fns: true, dynamic_loading: DynamicLoading::DebugOnly, create_dirs: true, default_float_size: FloatSize::F64, default_int_size: IntSize::I64, max_array_size: 0, };