[][src]Struct config_struct::EnumOptions

pub struct EnumOptions {
    pub format: Option<Format>,
    pub enum_name: String,
    pub all_variants_const: Option<String>,
    pub derived_traits: Vec<String>,
    pub first_variant_is_default: bool,
    pub impl_display: bool,
    pub impl_from_str: bool,
    pub serde_support: SerdeSupport,
    pub use_serde_derive_crate: bool,
    pub create_dirs: bool,
    pub write_only_if_changed: bool,
}

Options for configuring the generation of a struct.

Fields

format: Option<Format>

The format of the source data.

Defaults to None which will cause it to be inferred from the file type.

enum_name: String

The name of the resulting enum.

Defaults to "Key".

all_variants_const: Option<String>

The name of the const slice containing all variants. For example, if you specify Some("ALL"), then MyEnum::ALL will contain all variants of the enum.

If you specify None then no constant will be generated.

Defaults to Some("ALL").

derived_traits: Vec<String>

A list of traits for the struct to derive.

Defaults to ["Debug", "Clone", "Copy", "PartialEq", "Eq", "PartialOrd", "Ord", "Hash"]

(Note that the serde_support option below may add to this list.)

first_variant_is_default: bool

Whether to implement the Default trait for this enum. If true then the default value will be the first variant specified.

Defaults to true.

impl_display: bool

Whether to implement the Display trait for this enum. This requires the Debug trait to be implemented.

Defaults to true.

impl_from_str: bool

Whether to implement the FromStr trait for this enum. This requires the all_variants_const to be set to something other than None.

Defaults to true.

serde_support: SerdeSupport

Shorthand for generating the Serialize and Deserialize traits.

Defaults to No.

use_serde_derive_crate: bool

The recommended way to derive Serialize and Deserialize is via the serde crate's derive feature.

If you instead need to use the old method of including the serde_derive crate, set this flag to true.

create_dirs: bool

Whether or not to create the parent directories of the output file, if they don't exist.

Defaults to true.

write_only_if_changed: bool

Whether to check if the destination file would be changed before writing output.

This is to avoid unnecessary writes from marking the destination file as changed (which could, for example, trigger a process which is watching for changes). This option only works with the create_* functions.

Defaults to true.

Methods

impl EnumOptions[src]

pub fn serde_default() -> Self[src]

The default options plus serde support. This includes Serialize/Deserialize traits, plus helpers functions to load the config.

use config_struct::{EnumOptions, SerdeSupport};

let options = EnumOptions::serde_default();

assert_eq!(options, EnumOptions {
    serde_support: SerdeSupport::Yes,
    .. EnumOptions::default()
});

Trait Implementations

impl Clone for EnumOptions[src]

impl Debug for EnumOptions[src]

impl Default for EnumOptions[src]

Defaults to ["Debug", "Clone", "Copy", "PartialEq", "Eq", "PartialOrd", "Ord", "Hash"]

fn default() -> Self[src]

use config_struct::*;

let default_options = EnumOptions {
    format: None,
    enum_name: "Key".to_owned(),
    all_variants_const: Some("ALL".to_owned()),
    derived_traits: vec![
        "Debug".to_owned(),
        "Clone".to_owned(),
        "Copy".to_owned(),
        "PartialEq".to_owned(),
        "Eq".to_owned(),
        "PartialOrd".to_owned(),
        "Ord".to_owned(),
        "Hash".to_owned(),
    ],
    first_variant_is_default: true,
    impl_display: true,
    impl_from_str: true,
    serde_support: SerdeSupport::No,
    use_serde_derive_crate: false,
    create_dirs: true,
    write_only_if_changed: true,
};
assert_eq!(default_options, EnumOptions::default());

impl Eq for EnumOptions[src]

impl PartialEq<EnumOptions> for EnumOptions[src]

impl StructuralEq for EnumOptions[src]

impl StructuralPartialEq for EnumOptions[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.