1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
pub use crate::prelude::*;

pub use serde_yaml::Value as MetaValue;

#[derive(Debug, Default, Serialize, Clone)]
#[serde(transparent)]
pub struct EntryMeta {
    data: BTreeMap<String, MetaValue>,
}

/// Entry Meta-Data
///
/// Collection of all non-reserved data found from
/// the front-matter of an entry.
///
impl EntryMeta {
    pub fn insert<K, V>(&mut self, key: K, value: V)
    where
        K: Into<String>,
        V: Into<MetaValue>,
    {
        self.data.insert(key.into(), value.into());
    }

    pub fn get<K>(&self, key: &K) -> Option<&MetaValue>
    where
        K: AsRef<str>,
    {
        self.data.get(key.as_ref())
    }
}