Trait amethyst_config::Element [] [src]

pub trait Element: Sized {
    fn from_yaml(&ConfigMeta, &Yaml) -> Result<Self, ConfigError>;
    fn to_yaml(&self, &Path) -> Yaml;

    fn set_meta(&mut self, &ConfigMeta) { ... }
    fn meta(&self) -> Option<ConfigMeta> { ... }
    fn from_file_raw(meta: &ConfigMeta, path: &Path) -> Result<Self, ConfigError> { ... }
    fn from_file(path: &Path) -> Result<Self, ConfigError> { ... }
    fn write_file(&self) -> Result<()ConfigError> { ... }
}

Trait for fields inside of a configuration struct.

Required Methods

fn from_yaml(&ConfigMeta, &Yaml) -> Result<Self, ConfigError>

Convert yaml element into a rust type, Raises an error if it is not the yaml element expected

fn to_yaml(&self, &Path) -> Yaml

Converts rust type into a yaml element for writing Requires the path for external configs

Provided Methods

fn set_meta(&mut self, &ConfigMeta)

Sets the meta data of a config structure, only works on config structures

fn meta(&self) -> Option<ConfigMeta>

Returns meta data if it is a config structure

fn from_file_raw(meta: &ConfigMeta, path: &Path) -> Result<Self, ConfigError>

From a file relative to current config

fn from_file(path: &Path) -> Result<Self, ConfigError>

From a file relative to project

fn write_file(&self) -> Result<()ConfigError>

Recursively writes to files given the configuration's current context.

The default path for a root configuration file is "config/config.yml".

Note: This should never be called on a non-config! defined structure.

Implementors