gazetta_core/model/meta.rs
1// Copyright (C) 2015 Steven Allen
2//
3// This file is part of gazetta.
4//
5// This program is free software: you can redistribute it and/or modify it under the terms of the
6// GNU General Public License as published by the Free Software Foundation version 3 of the
7// License.
8//
9// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
11// the GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License along with this program. If
14// not, see <http://www.gnu.org/licenses/>.
15//
16
17use crate::yaml;
18
19pub trait Meta: Sized {
20 fn from_yaml(yaml: yaml::Hash) -> Result<Self, &'static str>;
21}
22
23impl Meta for yaml::Hash {
24 fn from_yaml(yaml: yaml::Hash) -> Result<Self, &'static str> {
25 Ok(yaml)
26 }
27}
28
29impl Meta for () {
30 fn from_yaml(_: yaml::Hash) -> Result<Self, &'static str> {
31 Ok(())
32 }
33}