From 8cffdddab2506cc539b4e1496d586ac1e5b9f270 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 31 Oct 2015 12:13:21 +0100 Subject: [PATCH] Split header spec into smaller functions --- src/module/bm/header.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/module/bm/header.rs b/src/module/bm/header.rs index 33d4c0b6..273e131e 100644 --- a/src/module/bm/header.rs +++ b/src/module/bm/header.rs @@ -1,15 +1,18 @@ use storage::file::FileHeaderSpec as FHS; pub fn get_spec() -> FHS { - FHS::Map { - keys: vec![ - FHS::Key { name: "URL", value_type: Box::new(FHS::Text) }, - FHS::Key { name: "TAGS", - value_type: Box::new(FHS::Array { - allowed_types: vec![FHS::Text] - }), - }, - ], - } + FHS::Map { keys: vec![ url_key(), tags_key() ] } +} + +fn url_key() -> FHS { + FHS::Key { name: "URL", value_type: Box::new(FHS::Text) } +} + +fn tags_key() -> FHS { + FHS::Key { name: "TAGS", value_type: Box::new(text_array()) } +} + +fn text_array() -> FHS { + FHS::Array { allowed_types: vec![FHS::Text] } }