Crate wildland_catlib
source ·Expand description
Catalog client library
This library is used by Wildland Core to allow persistent storage for Wildland manifests that describe Wildland entities such as Containers, Storages, Bridges etc.
The library acts as a database client depending on the database backend used. The current version of CatLib stores manifests in a local single-file nosql, unstructured database. Location of the database file depends on the platform where the application runs, these are:
Linux: /home/alice/.config/catlib
Windows: C:\Users\Alice\AppData\Roaming\com.wildland.Cargo\catlib
macOS: /Users/Alice/Library/Application Support/com.wildland.Cargo/catlib
Entities relationship
+------------+ +------------+
| Forest | -------> | Bridge |
+------------+ +------------+
|
| +-------------+
+-----> | Container |
+-------------+
|
| +-----------+
+-----> | Storage |
+-----------+
Example usage
let forest_owner = Identity([1; 32]);
let signer = Identity([2; 32]);
let catlib = CatLib::default();
let forest = catlib.create_forest(
forest_owner,
HashSet::from([signer]),
vec![],
).unwrap();
let storage_template = StorageTemplate::try_new(
"FoundationStorage",
HashMap::from([
(
"field1".to_owned(),
"Some value with container name: {{ CONTAINER_NAME }}".to_owned(),
),
(
"parameter in key: {{ OWNER }}".to_owned(),
"enum: {{ ACCESS_MODE }}".to_owned(),
),
("uuid".to_owned(), "{{ CONTAINER_UUID }}".to_owned()),
("paths".to_owned(), "{{ PATHS }}".to_owned()),
]),
)
.unwrap();
let path = "/some/path".to_owned();
let container = forest.lock().unwrap().create_container("container name".to_owned(), &storage_template, path).unwrap();
container.lock().unwrap().add_path("/foo/bar".to_string());
container.lock().unwrap().add_path("/bar/baz".to_string());