diff --git a/src/module/helpers/header/mod.rs b/src/module/helpers/header/mod.rs index 250decc2..04fdc834 100644 --- a/src/module/helpers/header/mod.rs +++ b/src/module/helpers/header/mod.rs @@ -1,13 +1,23 @@ -/* +/*! * Helpers for headers */ pub mod tags; +/** + * Utility helpers for header data + */ pub mod data { use std::ops::Deref; use storage::file::header::data::FileHeaderData as FHD; + /** + * Get an URL from a header, whereas the header has to have the following format: + * + * { ..., "URL": "", ... } + * + * Does no spec verification. + */ pub fn get_url_from_header(header: &FHD) -> Option { match header { &FHD::Map{keys: ref ks} => { diff --git a/src/module/helpers/header/tags.rs b/src/module/helpers/header/tags.rs index a78a2fb4..e2e390e0 100644 --- a/src/module/helpers/header/tags.rs +++ b/src/module/helpers/header/tags.rs @@ -1,30 +1,61 @@ -/* +/*! * Helpers for headers - Tags */ +/** + * Spec helpers for header-tags + */ pub mod spec { use storage::file::header::spec::FileHeaderSpec as FHS; use module::helpers::spec::{named_text, named_text_array}; + /** + * helper for a Header spec for + * + * { "URL": "" } + */ pub fn url_key() -> FHS { named_text("URL") } + /** + * helper for a Header spec for + * + * { "TAGS": [ "", ... ] } + */ pub fn tags_key() -> FHS { named_text_array("TAGS") } } +/** + * Data helpers for header-tags + */ pub mod data { use std::ops::Deref; use storage::file::header::data::FileHeaderData as FHD; + /** + * Use a Vec to build a Tag-Array: + * + * [ "", ... ] + */ 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) } } + /** + * Fetch tags from a header, whereas the header looks like this: + * + * { ..., + * "TAGS": [ "", ... ], + * ... + * } + * + * Does no spec verification. + */ pub fn get_tags_from_header(header: &FHD) -> Vec { let mut tags : Vec = vec![];