Add header helpers for BM
This commit is contained in:
parent
e346f56a8e
commit
2e7621d2bd
3 changed files with 35 additions and 1 deletions
32
src/module/bm/header.rs
Normal file
32
src/module/bm/header.rs
Normal file
|
@ -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<String>) -> 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<String> {
|
||||
headerhelpers::tags::data::get_tags_from_header(header)
|
||||
}
|
||||
|
|
@ -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>,
|
||||
}
|
||||
|
|
|
@ -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<String>) -> FHD {
|
||||
pub fn build_tag_array(tags: Vec<String>) -> FHD {
|
||||
let texttags = tags.into_iter().map(|t| FHD::Text(t.clone())).collect();
|
||||
FHD::Array { values: Box::new(texttags) }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue