valid_toml 0.0.2

Provides the ability to load a TOML file with validation.
Documentation
/* Copyright 2016 Joshua Gentry
 *
 * Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
 * http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
 * <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
 * option. This file may not be copied, modified, or distributed
 * except according to those terms.
 */
use toml::Value;

use enums::ExtractResult;
use item_value::ItemValue;

//*************************************************************************************************
/// Common trait implemented by the various structures that extract data from the TOML file.
pub trait ItemDef : 'static
{
    //*********************************************************************************************
    /// Returns the name of the item.
    fn name(&self) -> &str;

    //*********************************************************************************************
    /// Validate and extract the value from the TOML element.
    fn extract(
        &self,
        value : &Value
        ) -> ExtractResult;

    //*********************************************************************************************
    /// Returns true if the value is optional.
    fn is_optional(&self) -> bool;

    //*********************************************************************************************
    /// Returns the default value for the item if it exists, otherwise None.
    fn default(&self) -> Option<ItemValue>;
}