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 shareable::SharedI64;

use item_value::ItemValue;
use notify::Notify;

//*************************************************************************************************
/// This object will provide the value of an item read from the TOML file.  It's value is
/// initialized to zero until the TOML file is actually loaded.
#[derive(Clone)]
pub struct I64Value
{
    //---------------------------------------------------------------------------------------------
    /// The data object that actually holds the value.
    value : SharedI64
}

impl I64Value
{
    //---------------------------------------------------------------------------------------------
    /// Create a new instance of the object.
    pub fn new() -> I64Value
    {
        I64Value {
            value  : SharedI64::new(0)
        }
    }

    //---------------------------------------------------------------------------------------------
    /// Returns the i64 value read from the TOML file.
    pub fn get(&self) -> i64
    {
        self.value.get()
    }
}

use std::fmt::{Debug, Display, Formatter, Error};

impl Debug for I64Value
{
    //*********************************************************************************************
    /// Implementation of Debug.
    fn fmt(
        &self,
        f : &mut Formatter
        ) -> Result<(), Error>
    {
        write!(f, "{:?}", self.get())
    }
}

impl Display for I64Value
{
    //*********************************************************************************************
    /// Implementation of Display.
    fn fmt(
        &self,
        f : &mut Formatter
        ) -> Result<(), Error>
    {
        write!(f, "{}", self.get())
    }
}

impl Notify for I64Value
{
    //---------------------------------------------------------------------------------------------
    /// This is called when the TOML file is read to set the value.
    fn send(
        &self,
        value : &ItemValue
        )
    {
        self.value.set(value.get_i64());
    }
}