[−][src]Struct edres::StructOptions
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.
struct_name: StringThe 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: boolWhether 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"]
(Note that the serde_support option below may add to this
list.)
serde_support: SerdeSupportShorthand for generating the Serialize and Deserialize traits.
Defaults to No.
use_serde_derive_crate: boolThe 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.
generate_load_fns: boolWhether or not to generate helper functions to load the struct at runtime.
Defaults to true.
Note: These load functions depend on the Deserialize
trait, as well as the relevant serde library for the config
format.
So for example, if you generate a struct from config.json
then you will have to enable serde_support for the
Deserialize trait, and you will also have to include the
serde_json library in your crate.
dynamic_loading: DynamicLoadingWhether the load functions, if generated, are dynamic, and when.
Defaults to DebugOnly.
create_dirs: boolWhether or not to create the parent directories of the output file, if they don't exist.
Defaults to true.
write_only_if_changed: boolWhether 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.
default_float_size: FloatSizeThe type of floating point values in the config, where the format does not make it explicit.
Defaults to F64.
default_int_size: IntSizeThe type of integer values in the config, where the format does not make it explicit.
Defaults to I64.
max_array_size: usizeThe 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.
Implementations
impl StructOptions[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 edres::{StructOptions, SerdeSupport}; let options = StructOptions::serde_default(); assert_eq!(options, StructOptions { serde_support: SerdeSupport::Yes, generate_load_fns: true, .. StructOptions::default() });
Trait Implementations
impl Clone for StructOptions[src]
pub fn clone(&self) -> StructOptions[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Debug for StructOptions[src]
impl Default for StructOptions[src]
pub fn default() -> Self[src]
use edres::*; let default_options = StructOptions { format: None, struct_name: "Config".to_owned(), const_name: None, generate_const: true, derived_traits: vec![ "Debug".to_owned(), "Clone".to_owned(), ], serde_support: SerdeSupport::No, use_serde_derive_crate: false, generate_load_fns: false, dynamic_loading: DynamicLoading::DebugOnly, create_dirs: true, write_only_if_changed: true, default_float_size: FloatSize::F64, default_int_size: IntSize::I64, max_array_size: 0, }; assert_eq!(default_options, StructOptions::default());
impl Eq for StructOptions[src]
impl PartialEq<StructOptions> for StructOptions[src]
pub fn eq(&self, other: &StructOptions) -> bool[src]
pub fn ne(&self, other: &StructOptions) -> bool[src]
impl StructuralEq for StructOptions[src]
impl StructuralPartialEq for StructOptions[src]
Auto Trait Implementations
impl RefUnwindSafe for StructOptions
impl Send for StructOptions
impl Sync for StructOptions
impl Unpin for StructOptions
impl UnwindSafe for StructOptions
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,