pub trait IContainer {
    fn uuid(&self) -> Uuid;
    fn forest(&self) -> CatlibResult<Forest>;
    fn paths(&self) -> ContainerPaths;
    fn add_path(&mut self, path: ContainerPath) -> CatlibResult<Container>;
    fn del_path(&mut self, path: ContainerPath) -> CatlibResult<Container>;
    fn storages(&self) -> CatlibResult<Vec<Storage>>;
    fn create_storage(
        &self,
        template_uuid: Option<Uuid>,
        data: Vec<u8>
    ) -> CatlibResult<Storage>; }

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