Move key generating to top-level spec helpers

This commit is contained in:
Matthias Beyer 2015-12-05 18:26:31 +01:00
parent dad856ff2a
commit 6e0d0058b0
2 changed files with 20 additions and 6 deletions

View file

@ -4,17 +4,14 @@
pub mod spec { pub mod spec {
use storage::file::FileHeaderSpec as FHS; use storage::file::FileHeaderSpec as FHS;
use module::helpers::spec::{named_text, named_text_array};
pub fn url_key() -> FHS { pub fn url_key() -> FHS {
FHS::Key { name: String::from("URL"), value_type: Box::new(FHS::Text) } named_text("URL")
} }
pub fn tags_key() -> FHS { pub fn tags_key() -> FHS {
FHS::Key { name: String::from("TAGS"), value_type: Box::new(text_array()) } named_text_array("TAGS")
}
pub fn text_array() -> FHS {
FHS::Array { allowed_types: vec![FHS::Text] }
} }
} }

View file

@ -1,2 +1,19 @@
pub mod header; pub mod header;
pub mod utils; pub mod utils;
pub mod spec {
use storage::file::FileHeaderSpec as FHS;
pub fn named_text(name: &str) -> FHS {
FHS::Key { name: String::from(name), value_type: Box::new(FHS::Text) }
}
pub fn named_text_array(name: &str) -> FHS {
FHS::Key { name: String::from(name), value_type: Box::new(text_array()) }
}
pub fn text_array() -> FHS {
FHS::Array { allowed_types: vec![FHS::Text] }
}
}