Trait ockam_api::cli_state::traits::StateDirTrait
source · pub trait StateDirTrait: Sized + Send + Sync {
type Item: StateItemTrait;
const DEFAULT_FILENAME: &'static str;
const DIR_NAME: &'static str;
const HAS_DATA_DIR: bool;
Show 26 methods
// Required methods
fn new(root_path: &Path) -> Self;
fn dir(&self) -> &PathBuf;
// Provided methods
fn default_filename() -> &'static str { ... }
fn build_dir(root_path: &Path) -> PathBuf { ... }
fn has_data_dir() -> bool { ... }
fn init<'life0, 'async_trait>(
root_path: &'life0 Path
) -> Pin<Box<dyn Future<Output = Result<Self, CliStateError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn migrate<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 Path
) -> Pin<Box<dyn Future<Output = Result<(), CliStateError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn load(root_path: &Path) -> Result<Self, CliStateError> { ... }
fn reset(&self, root_path: &Path) -> Result<PathBuf, CliStateError> { ... }
fn create_dirs(root_path: &Path) -> Result<PathBuf, CliStateError> { ... }
fn dir_as_string(&self) -> String { ... }
fn path(&self, name: impl AsRef<str>) -> PathBuf { ... }
fn overwrite(
&self,
name: impl AsRef<str>,
config: <<Self as StateDirTrait>::Item as StateItemTrait>::Config
) -> Result<Self::Item, CliStateError> { ... }
fn create(
&self,
name: impl AsRef<str>,
config: <<Self as StateDirTrait>::Item as StateItemTrait>::Config
) -> Result<Self::Item, CliStateError> { ... }
fn get(&self, name: impl AsRef<str>) -> Result<Self::Item, CliStateError> { ... }
fn list(&self) -> Result<Vec<Self::Item>, CliStateError> { ... }
fn list_items_names(&self) -> Result<Vec<String>, CliStateError> { ... }
fn is_item_path(&self, path: &PathBuf) -> Result<bool, CliStateError> { ... }
fn list_items_paths(&self) -> Result<Vec<PathBuf>, CliStateError> { ... }
fn delete(&self, name: impl AsRef<str>) -> Result<(), CliStateError> { ... }
fn default_path(&self) -> Result<PathBuf, CliStateError> { ... }
fn default(&self) -> Result<Self::Item, CliStateError> { ... }
fn set_default(&self, name: impl AsRef<str>) -> Result<(), CliStateError> { ... }
fn is_default(&self, name: impl AsRef<str>) -> Result<bool, CliStateError> { ... }
fn is_empty(&self) -> Result<bool, CliStateError> { ... }
fn exists(&self, name: impl AsRef<str>) -> bool { ... }
}Expand description
Represents the directory of a type of state. This directory contains a list of items, uniquely
identified by a name, and represented by the same Item type.
One item can be set as the “default” item, which is used in some CLI commands when no
argument is provided for that type of Item.
Required Associated Types§
type Item: StateItemTrait
Required Associated Constants§
const DEFAULT_FILENAME: &'static str
const DIR_NAME: &'static str
const HAS_DATA_DIR: bool
Required Methods§
Provided Methods§
fn default_filename() -> &'static str
fn build_dir(root_path: &Path) -> PathBuf
fn has_data_dir() -> bool
sourcefn init<'life0, 'async_trait>(
root_path: &'life0 Path
) -> Pin<Box<dyn Future<Output = Result<Self, CliStateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn init<'life0, 'async_trait>( root_path: &'life0 Path ) -> Pin<Box<dyn Future<Output = Result<Self, CliStateError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Load the root configuration and migrate each entry if necessary
sourcefn migrate<'life0, 'life1, 'async_trait>(
&'life0 self,
_path: &'life1 Path
) -> Pin<Box<dyn Future<Output = Result<(), CliStateError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn migrate<'life0, 'life1, 'async_trait>( &'life0 self, _path: &'life1 Path ) -> Pin<Box<dyn Future<Output = Result<(), CliStateError>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Do not run any migration by default
fn load(root_path: &Path) -> Result<Self, CliStateError>
sourcefn reset(&self, root_path: &Path) -> Result<PathBuf, CliStateError>
fn reset(&self, root_path: &Path) -> Result<PathBuf, CliStateError>
Recreate all the state directories
sourcefn create_dirs(root_path: &Path) -> Result<PathBuf, CliStateError>
fn create_dirs(root_path: &Path) -> Result<PathBuf, CliStateError>
Create all the state directories
fn dir_as_string(&self) -> String
fn path(&self, name: impl AsRef<str>) -> PathBuf
fn overwrite( &self, name: impl AsRef<str>, config: <<Self as StateDirTrait>::Item as StateItemTrait>::Config ) -> Result<Self::Item, CliStateError>
fn create( &self, name: impl AsRef<str>, config: <<Self as StateDirTrait>::Item as StateItemTrait>::Config ) -> Result<Self::Item, CliStateError>
fn get(&self, name: impl AsRef<str>) -> Result<Self::Item, CliStateError>
fn list(&self) -> Result<Vec<Self::Item>, CliStateError>
fn list_items_names(&self) -> Result<Vec<String>, CliStateError>
fn is_item_path(&self, path: &PathBuf) -> Result<bool, CliStateError>
fn list_items_paths(&self) -> Result<Vec<PathBuf>, CliStateError>
fn delete(&self, name: impl AsRef<str>) -> Result<(), CliStateError>
fn default_path(&self) -> Result<PathBuf, CliStateError>
fn default(&self) -> Result<Self::Item, CliStateError>
fn set_default(&self, name: impl AsRef<str>) -> Result<(), CliStateError>
fn is_default(&self, name: impl AsRef<str>) -> Result<bool, CliStateError>
fn is_empty(&self) -> Result<bool, CliStateError>
fn exists(&self, name: impl AsRef<str>) -> bool
Object Safety§
This trait is not object safe.