Expand description
§databoard
Implementation of a hierarchical key-value-store with the possibility to do a remapping from a level up to its parent level.
The following restrictions apply:
- Each level can have exactly one parent.
- There is no remapping down the hierarchy.
- The remapping is evaluated recursively up the levels.
You can do the remapping either
- fully automatic,
- fully manual or
- do an automatic remapping with manual overrides.
For controlling the access in the hierarchy there are two kinds of special keys:
- keys prefixed with an
@redirect to the top leveldataboardof the hierarchy. - keys prefixed with an
_restrict the access to the currentdataboard.
§Usage
A standalone databoard:
use databoard::Databoard;
// instantiation of a default Databoard
let databoard = Databoard::new();
// setting a value returns a `Result` of the previous content, in this case a `None`.
let old = databoard.set("test", 42).unwrap();
// getting the value may fail, so it returns a `Result`,
let value = databoard.get::<i32>("test").unwrap();
// deleting the value returns a `Result` of the previous content, in this case `42`.
let value = databoard.delete::<i32>("test").unwrap();
Hierarchical usage:
use databoard::{Databoard, RemappingList};
let top_level = Databoard::new();
// this creates a databoard with automatic remapping to parent
let level1 = Databoard::with_parent(top_level.clone());
// some remapping rules
let mut remappings = RemappingList::default();
remappings.add("test", "{test}");
remappings.add("other_test", "{test}");
// this creates a databoard with manual remapping to parent using the defined remapping rules
let level2 = Databoard::with(Some(level1.clone()), Some(remappings), false);
// sets the value in the top `databoard`
top_level.set("test", 42).unwrap();
// but it can also be accessed from the two other levels
let value1: i32 = level1.get("test").unwrap();
let value2: i32 = level2.get("other_test").unwrap();§License
Licensed with the fair use “NGMC” license, see license file
§Contribution
Any contribution intentionally submitted for inclusion in the work by you, shall be licensed with the same “NGMC” license, without any additional terms or conditions.
Structs§
- Databoard
- A thread safe data board.
- Entry
Read Guard - Read-Locked entry guard. Until this value is dropped, a read lock is held on the entry.
- Entry
Write Guard - Write-Locked entry guard. Until this value is dropped, a write lock is held on the entry.
- Remapping
List - A mutable remapping list.
Enums§
- Error
- Things that may go wrong using the
Databoard. - Remapping
Target - Target of a remapping entry
Functions§
- check_
board_ pointer - Returns the literal of the
Databoardpointer if it is one. - check_
local_ key - Returns the literal of the current/local
Databoardkey if it is one. - check_
local_ pointer - Returns the literal of the current/local
Databoardpointer if it is one. - check_
top_ level_ key - Returns the literal of the top level
Databoardkey if it is one. - check_
top_ level_ pointer - Returns the literal of the top level
Databoardpointer if it is one. - is_
board_ pointer - Checks whether the given key is a pointer into a
Databoard. - is_
const_ assignment - Returns
trueif a key is not a board pointer but a constant assignment , otherwisefalse - is_
local_ pointer - Checks whether the given key is a pointer into current/local
Databoard. - is_
top_ level_ pointer - Checks whether the given key is a pointer into top level
Databoard. - strip_
board_ pointer - Returns Some(literal) of the
Databoardpointer if it is one, otherwiseNone. - strip_
local_ pointer - Returns Some(literal) of the current/local
Databoardpointer if it is one, otherwiseNone. The leading_is removed from the literal. - strip_
top_ level_ pointer - Returns Some(literal) of the top level
Databoardpointer if it is one, otherwiseNone. The leading@is removed from the literal.