Trait wildland_corex::IForest
source · [−]pub trait IForest {
Show 13 methods
fn uuid(&self) -> Uuid;
fn owner(&self) -> Identity;
fn signers(&self) -> HashSet<Identity, RandomState>;
fn data(&self) -> Vec<u8, Global>;
fn add_signer(&mut self, signer: Identity) -> Result<bool, CatlibError>;
fn del_signer(&mut self, signer: Identity) -> Result<bool, CatlibError>;
fn containers(&self) -> Result<Vec<Container, Global>, CatlibError>;
fn update(&mut self, data: Vec<u8, Global>) -> Result<(), CatlibError>;
fn remove(&mut self) -> Result<bool, CatlibError>;
fn create_container(&self) -> Result<Container, CatlibError>;
fn create_bridge(
&self,
path: String,
link_data: Vec<u8, Global>
) -> Result<Bridge, CatlibError>;
fn find_bridge(&self, path: String) -> Result<Bridge, CatlibError>;
fn find_containers(
&self,
paths: Vec<String, Global>,
include_subdirs: bool
) -> Result<Vec<Container, Global>, CatlibError>;
}
Required Methods
sourcefn signers(&self) -> HashSet<Identity, RandomState>
fn signers(&self) -> HashSet<Identity, RandomState>
Return list of manifests Signers
sourcefn add_signer(&mut self, signer: Identity) -> Result<bool, CatlibError>
fn add_signer(&mut self, signer: Identity) -> Result<bool, CatlibError>
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) -> Result<bool, CatlibError>
fn del_signer(&mut self, signer: Identity) -> Result<bool, CatlibError>
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) -> Result<Vec<Container, Global>, CatlibError>
fn containers(&self) -> Result<Vec<Container, Global>, CatlibError>
Return list of Forest Containers
Errors
Returns CatlibError::NoRecordsFound
if Forest has no Container
.
sourcefn update(&mut self, data: Vec<u8, Global>) -> Result<(), CatlibError>
fn update(&mut self, data: Vec<u8, Global>) -> Result<(), CatlibError>
Set Forest arbitrary data
Errors
Returns RustbreakError
cast on CatlibResult
upon failure to save to the database.
sourcefn remove(&mut self) -> Result<bool, CatlibError>
fn remove(&mut self) -> Result<bool, CatlibError>
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) -> Result<Container, CatlibError>
fn create_container(&self) -> Result<Container, CatlibError>
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: String,
link_data: Vec<u8, Global>
) -> Result<Bridge, CatlibError>
fn create_bridge(
&self,
path: String,
link_data: Vec<u8, Global>
) -> Result<Bridge, CatlibError>
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: String) -> Result<Bridge, CatlibError>
fn find_bridge(&self, path: String) -> Result<Bridge, CatlibError>
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<String, Global>,
include_subdirs: bool
) -> Result<Vec<Container, Global>, CatlibError>
fn find_containers(
&self,
paths: Vec<String, Global>,
include_subdirs: bool
) -> Result<Vec<Container, Global>, CatlibError>
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();