valid_toml/enums/warning.rs
1/* Copyright 2016 Joshua Gentry
2 *
3 * Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
4 * http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
5 * <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
6 * option. This file may not be copied, modified, or distributed
7 * except according to those terms.
8 */
9use std::fmt::{Display, Formatter, Error};
10
11//*************************************************************************************************
12/// Defines the possible warnings.
13#[derive(Debug)]
14pub enum Warning
15{
16 //---------------------------------------------------------------------------------------------
17 /// An optional value was not found. The default value will be used instead.
18 Missing(String),
19
20 //---------------------------------------------------------------------------------------------
21 /// An value was read from the TOML file that does not contain a definition. Includes the
22 /// name of the item.
23 Undefined(String)
24}
25
26impl Display for Warning
27{
28 //*********************************************************************************************
29 /// Display a nice message for the warning.
30 fn fmt(
31 &self,
32 fmt : &mut Formatter
33 ) -> Result<(), Error>
34 {
35 match *self
36 {
37 Warning::Missing(ref name) => write!(fmt, "{} is not defined, using the default value.", name),
38 Warning::Undefined(ref name) => write!(fmt, "{} is not a known ID and will be ignored.", name)
39 }
40 }
41}