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

Return UUID object identifier

Return Forest that contains the Container.

Errors

Return Container’s paths

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();

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();

Return list of Forest Storages.

Errors

Returns CatlibError::NoRecordsFound if Forest has no Storage.

Create a Storage, bound to the Container.

template_uuid is an arbitrary, optional, String that is later used to find Containers and Storages 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();

Implementors