diff --git a/libimagstore/src/error.rs b/libimagstore/src/error.rs index 1bbb6961..75ec0268 100644 --- a/libimagstore/src/error.rs +++ b/libimagstore/src/error.rs @@ -24,6 +24,7 @@ pub enum StoreErrorKind { EntryAlreadyBorrowed, EntryAlreadyExists, MalformedEntry, + HeaderPathSyntaxError, // maybe more } @@ -44,6 +45,7 @@ fn store_error_type_as_str(e: &StoreErrorKind) -> &'static str { &StoreErrorKind::EntryAlreadyBorrowed => "Entry is already borrowed", &StoreErrorKind::EntryAlreadyExists => "Entry already exists", &StoreErrorKind::MalformedEntry => "Entry has invalid formatting, missing header", + &StoreErrorKind::HeaderPathSyntaxError => "Syntax error in accessor string", } } diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 62518c95..2157c19e 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -362,6 +362,84 @@ impl EntryHeader { verify_header(&self.toml) } + /** + * Insert a header field by a string-spec + * + * ```ignore + * insert("something.in.a.field", Boolean(true)); + * ``` + * + * Inserts a Boolean in the section "something" -> "in" -> "a" -> "field" + * A JSON equivalent would be + * + * { + * something: { + * in: { + * a: { + * field: true + * } + * } + * } + * } + * + * Returns true if header field was set, false if there is already a value + */ + pub fn insert(&mut self, spec: &str, v: Value) -> Result { + unimplemented!() + } + + /** + * Set a header field by a string-spec + * + * ```ignore + * set("something.in.a.field", Boolean(true)); + * ``` + * + * Sets a Boolean in the section "something" -> "in" -> "a" -> "field" + * A JSON equivalent would be + * + * { + * something: { + * in: { + * a: { + * field: true + * } + * } + * } + * } + * + * If there is already a value at this place, this value will be overridden and the old value + * will be returned + */ + pub fn set(&mut self, spec: &str, v: Value) -> Result> { + unimplemented!() + } + + /** + * Read a header field by a string-spec + * + * ```ignore + * let value = read("something.in.a.field"); + * ``` + * + * Reads a Value in the section "something" -> "in" -> "a" -> "field" + * A JSON equivalent would be + * + * { + * something: { + * in: { + * a: { + * field: true + * } + * } + * } + * } + * + * If there is no a value at this place, None will be returned + */ + pub fn read(&self, spec: &str) -> Result> { + unimplemented!() + } } fn build_default_header() -> BTreeMap {