Trait wildland_corex::IContainer
source · [−]pub trait IContainer {
fn uuid(&self) -> Uuid;
fn forest(&self) -> Result<Forest, CatlibError>;
fn paths(&self) -> HashSet<String, RandomState>;
fn add_path(&mut self, path: String) -> Result<Container, CatlibError>;
fn del_path(&mut self, path: String) -> Result<Container, CatlibError>;
fn storages(&self) -> Result<Vec<Storage, Global>, CatlibError>;
fn create_storage(
&self,
template_uuid: Option<Uuid>,
data: Vec<u8, Global>
) -> Result<Storage, CatlibError>;
}
Required Methods
sourcefn forest(&self) -> Result<Forest, CatlibError>
fn forest(&self) -> Result<Forest, CatlibError>
Return Forest
that contains the Container
.
Errors
- Returns
CatlibError::NoRecordsFound
if noForest
was found. - Returns
CatlibError::MalformedDatabaseEntry
if more than oneForest
was found.
sourcefn add_path(&mut self, path: String) -> Result<Container, CatlibError>
fn add_path(&mut self, path: String) -> Result<Container, CatlibError>
Add a path to the Container.
Returns self to allow chain method exection.
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("/bar/baz2".to_string()).unwrap()
.add_path("/baz/qux1".to_string()).unwrap()
.add_path("/baz/qux2".to_string()).unwrap();
sourcefn del_path(&mut self, path: String) -> Result<Container, CatlibError>
fn del_path(&mut self, path: String) -> Result<Container, CatlibError>
Delete a path from the Container.
Returns self to allow chain method exection.
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("/bar/baz2".to_string()).unwrap()
.del_path("/baz/qux1".to_string()).unwrap()
.del_path("/baz/qux2".to_string()).unwrap();
sourcefn storages(&self) -> Result<Vec<Storage, Global>, CatlibError>
fn storages(&self) -> Result<Vec<Storage, Global>, CatlibError>
Return list of Forest Storage
s.
Errors
Returns CatlibError::NoRecordsFound
if Forest has no Storage
.
sourcefn create_storage(
&self,
template_uuid: Option<Uuid>,
data: Vec<u8, Global>
) -> Result<Storage, CatlibError>
fn create_storage(
&self,
template_uuid: Option<Uuid>,
data: Vec<u8, Global>
) -> Result<Storage, CatlibError>
Create a Storage
, bound to the Container
.
template_uuid
is an arbitrary, optional, String
that is later used to find
Container
s and Storage
s using CatLib::find_storages_with_template
and
CatLib::find_containers_with_template
.
data
represents arbitrary data that is defined and used by the DF/S 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();
let mut container = forest.create_container().unwrap();
container.add_path("/foo/bar".to_string());
container.create_storage(Some(Uuid::from_u128(1)), vec![]).unwrap();