Trait wildland_catlib::contracts::IForest
source · [−]pub trait IForest {
Show 13 methods
fn uuid(&self) -> Uuid;
fn owner(&self) -> Identity;
fn signers(&self) -> Signers;
fn data(&self) -> Vec<u8>;
fn add_signer(&mut self, signer: Identity) -> CatlibResult<bool>;
fn del_signer(&mut self, signer: Identity) -> CatlibResult<bool>;
fn containers(&self) -> CatlibResult<Vec<Container>>;
fn update(&mut self, data: Vec<u8>) -> CatlibResult<()>;
fn remove(&mut self) -> CatlibResult<bool>;
fn create_container(&self) -> CatlibResult<Container>;
fn create_bridge(
&self,
path: ContainerPath,
link_data: Vec<u8>
) -> CatlibResult<Bridge>;
fn find_bridge(&self, path: ContainerPath) -> CatlibResult<Bridge>;
fn find_containers(
&self,
paths: Vec<ContainerPath>,
include_subdirs: bool
) -> CatlibResult<Vec<Container>>;
}
Required Methods
sourcefn add_signer(&mut self, signer: Identity) -> CatlibResult<bool>
fn add_signer(&mut self, signer: Identity) -> CatlibResult<bool>
Add manifest Signer
Returns whether the value was newly inserted. That is:
- If the signer did not previously exist,
true
is returned. - If the signer already exists,
false
is returned.
Errors
Returns RustbreakError
cast on CatlibResult
upon failure to save to the database.
sourcefn del_signer(&mut self, signer: Identity) -> CatlibResult<bool>
fn del_signer(&mut self, signer: Identity) -> CatlibResult<bool>
Delete manifest Signer
Returns whether the value was already present. That is:
- If the signer did not previously exist,
false
is returned. - If the signer existed in the set,
true
is returned.
Errors
Returns RustbreakError
cast on CatlibResult
upon failure to save to the database.
sourcefn containers(&self) -> CatlibResult<Vec<Container>>
fn containers(&self) -> CatlibResult<Vec<Container>>
Return list of Forest Containers
Errors
Returns CatlibError::NoRecordsFound
if Forest has no Container
.
sourcefn update(&mut self, data: Vec<u8>) -> CatlibResult<()>
fn update(&mut self, data: Vec<u8>) -> CatlibResult<()>
Set Forest arbitrary data
Errors
Returns RustbreakError
cast on CatlibResult
upon failure to save to the database.
sourcefn remove(&mut self) -> CatlibResult<bool>
fn remove(&mut self) -> CatlibResult<bool>
Delete Forest from the database
WARN: The underlying objects are not removed recursively
Errors
Returns RustbreakError
cast on CatlibResult
upon failure to save to the database.
sourcefn create_container(&self) -> CatlibResult<Container>
fn create_container(&self) -> CatlibResult<Container>
Create an empty container, bound to the Forest.
To set container paths, use Container::add_path
Errors
Returns RustbreakError
cast on CatlibResult
upon failure to save to the database.
Example
let catlib = CatLib::default();
let forest = catlib.create_forest(
Identity([1; 32]),
HashSet::from([Identity([2; 32])]),
vec![],
).unwrap();
let mut container = forest.create_container().unwrap();
container.add_path("/foo/bar".to_string());
container.add_path("/bar/baz".to_string());
sourcefn create_bridge(
&self,
path: ContainerPath,
link_data: Vec<u8>
) -> CatlibResult<Bridge>
fn create_bridge(
&self,
path: ContainerPath,
link_data: Vec<u8>
) -> CatlibResult<Bridge>
Create a Bridge obect with arbitrary link data to another Forest.
The aforementioned link data will be defined by the D/FS module.
Errors
Returns RustbreakError
cast on CatlibResult
upon failure to save to the database.
Example
let catlib = CatLib::default();
let forest = catlib.create_forest(
Identity([1; 32]),
HashSet::from([Identity([2; 32])]),
vec![],
).unwrap();
forest.create_bridge("/other/forest".to_string(), vec![]);
sourcefn find_bridge(&self, path: ContainerPath) -> CatlibResult<Bridge>
fn find_bridge(&self, path: ContainerPath) -> CatlibResult<Bridge>
Return bridge that matches the given ContainerPath
.
Errors
- Returns
CatlibError::NoRecordsFound
if noBridge
was found. - Returns
CatlibError::MalformedDatabaseEntry
if more than oneBridge
was found.
sourcefn find_containers(
&self,
paths: Vec<ContainerPath>,
include_subdirs: bool
) -> CatlibResult<Vec<Container>>
fn find_containers(
&self,
paths: Vec<ContainerPath>,
include_subdirs: bool
) -> CatlibResult<Vec<Container>>
Retrieve Containers that match given ContainerPath
s.
If include_subdirs
is true
, then the ContainerPath
s are treated as Path prefixes
and not absolute paths.
Errors
- Returns
CatlibError::NoRecordsFound
if noContainer
was found.
Example
use wildland_catlib::CatLib;
use std::collections::HashSet;
use crate::wildland_catlib::*;
let catlib = CatLib::default(); let forest = catlib.create_forest( b“owner“.to_vec(), HashSet::from([b“signer“.to_vec()]), vec![], ).unwrap(); let mut container = forest.create_container().unwrap(); container.add_path(“/foo/bar”.to_string());
let containers = forest.find_containers(vec![“/foo/bar”.to_string()], false).unwrap();