diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 2157c19e..e5d6e9b2 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -320,6 +320,12 @@ pub struct EntryHeader { pub type EntryResult = RResult; +#[derive(Debug, Clone, PartialEq, Eq)] +enum Token { + Key(String), + Index(usize), +} + /** * Wrapper type around file header (TOML) object */ @@ -440,6 +446,19 @@ impl EntryHeader { pub fn read(&self, spec: &str) -> Result> { unimplemented!() } + + fn tokenize(spec: &str) -> Result> { + use std::str::FromStr; + + spec.split(".") + .map(|s| { + usize::from_str(s) + .map(Token::Index) + .or_else(|_| Ok(Token::Key(String::from(s)))) + }) + .collect() + } + } fn build_default_header() -> BTreeMap {