Struct wildland_corex::forest::Forest
source · pub struct Forest { /* private fields */ }
Implementations§
source§impl Forest
impl Forest
pub fn new( forest_manifest: Arc<dyn ForestManifest>, identity: ForestIdentity ) -> Self
sourcepub fn get_storage_templates(&self) -> CatlibResult<Vec<StorageTemplate>>
pub fn get_storage_templates(&self) -> CatlibResult<Vec<StorageTemplate>>
Returns vector of forest’s storage templates
pub fn save_storage_template( &self, storage_template: StorageTemplate ) -> CatlibResult<(Uuid, StorageTemplate)>
pub fn forest_manifest(&self) -> Arc<dyn ForestManifest>
pub fn identity(&self) -> &ForestIdentity
sourcepub fn create_container(
&self,
container_name: String,
storage_template: &StorageTemplate,
path: ContainerPath,
encrypted: bool,
metadata: Vec<u8>
) -> Result<Container, CoreXError>
pub fn create_container( &self, container_name: String, storage_template: &StorageTemplate, path: ContainerPath, encrypted: bool, metadata: Vec<u8> ) -> Result<Container, CoreXError>
Errors
Returns RedisError
cast on crate::catlib_service::error::CatlibResult
upon failure to save to the database.
Example
let catlib = GqlCatlib::new("http://localhost:8000/graphql/");
let forest = catlib.create_forest(
WildlandPubKey([1; 32]),
HashMap::from([(WildlandPubKey([2; 32]), "".into())]),
vec![],
).unwrap();
let forest = Forest::new(forest, ForestIdentity::new(0, SigningKeypair::try_from_bytes_slices([0;32], [0;32]).unwrap()));
let storage_template = StorageTemplate::new(
"template type",
ValidatedTemplateData(
serde_json::to_value(&HashMap::from([
(
"field1".to_owned(),
"Some value with container name: {{ CONTAINER_NAME }}".to_owned(),
),
(
"parameter in key: {{ OWNER }}".to_owned(),
"enum: {{ ACCESS_MODE }}".to_owned(),
),
("uuid".to_owned(), "{{ CONTAINER_UUID }}".to_owned()),
("path".to_owned(), "{{ PATH }}".to_owned()),
])).unwrap()),
None
);
let path = "/some/path".into();
let container = forest.create_container("container name1".to_owned(), &storage_template, path, false, "".into()).unwrap();
pub fn find_containers( &self, filter: Option<CatlibContainerFilter> ) -> Result<Vec<Container>, CatlibError>
sourcepub fn add_device(
&mut self,
device: WildlandPubKey
) -> Result<bool, CatlibError>
pub fn add_device( &mut self, device: WildlandPubKey ) -> Result<bool, CatlibError>
Errors
Returns RedisError
cast on crate::catlib_service::error::CatlibResult
upon failure to save to the database.
sourcepub fn delete_device(&self, device: WildlandPubKey) -> Result<bool, CatlibError>
pub fn delete_device(&self, device: WildlandPubKey) -> Result<bool, CatlibError>
Errors
Returns RedisError
cast on crate::catlib_service::error::CatlibResult
upon failure to save to the database.
sourcepub fn devices(&mut self) -> Result<Devices, CatlibError>
pub fn devices(&mut self) -> Result<Devices, CatlibError>
Gets the current collection of the Forest’s devices.
Errors
Returns RedisError
cast on crate::catlib_service::error::CatlibResult
upon failure to sync to the database.
sourcepub fn remove(self) -> Result<bool, CatlibError>
pub fn remove(self) -> Result<bool, CatlibError>
Errors
Returns RedisError
cast on crate::catlib_service::error::CatlibResult
upon failure to save to the database.
pub fn owner(&self) -> WildlandPubKey
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Forest
impl Send for Forest
impl Sync for Forest
impl Unpin for Forest
impl !UnwindSafe for Forest
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more