diff --git a/src/module/bm/header.rs b/src/module/bm/header.rs new file mode 100644 index 00000000..2d974749 --- /dev/null +++ b/src/module/bm/header.rs @@ -0,0 +1,32 @@ +use module::helpers::header as headerhelpers; +use storage::file::header::data::FileHeaderData as FHD; +use storage::file::header::spec::FileHeaderSpec as FHS; + +pub fn get_spec() -> FHS { + FHS::Map { + keys: vec![ + headerhelpers::tags::spec::url_key(), + headerhelpers::tags::spec::tags_key(), + ] + } +} + +pub fn build_header(url: String, tags: Vec) -> FHD { + FHD::Map { + keys: vec![ + FHD::Key { + name: String::from("URL"), + value: Box::new(FHD::Text(url.clone())) + }, + FHD::Key { + name: String::from("TAGS"), + value: Box::new(headerhelpers::tags::data::build_tag_array(tags)) + } + ] + } +} + +pub fn get_tags_from_header(header: &FHD) -> Vec { + headerhelpers::tags::data::get_tags_from_header(header) +} + diff --git a/src/module/bm/mod.rs b/src/module/bm/mod.rs index 6c102d9b..f463cf37 100644 --- a/src/module/bm/mod.rs +++ b/src/module/bm/mod.rs @@ -10,6 +10,8 @@ use storage::parser::FileHeaderParser; use storage::parser::Parser; use storage::json::parser::JsonHeaderParser; +mod header; + pub struct BM<'a> { rt: &'a Runtime<'a>, } diff --git a/src/module/helpers/header/tags.rs b/src/module/helpers/header/tags.rs index 85f49976..a78a2fb4 100644 --- a/src/module/helpers/header/tags.rs +++ b/src/module/helpers/header/tags.rs @@ -20,7 +20,7 @@ pub mod data { use std::ops::Deref; use storage::file::header::data::FileHeaderData as FHD; - pub fn build_tag_array(tags: &Vec) -> FHD { + pub fn build_tag_array(tags: Vec) -> FHD { let texttags = tags.into_iter().map(|t| FHD::Text(t.clone())).collect(); FHD::Array { values: Box::new(texttags) } }