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§

Required Associated Constants§

Required Methods§

source

fn new(root_path: &Path) -> Self

source

fn dir(&self) -> &PathBuf

Provided Methods§

source

fn default_filename() -> &'static str

source

fn build_dir(root_path: &Path) -> PathBuf

source

fn has_data_dir() -> bool

source

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

source

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

source

fn load(root_path: &Path) -> Result<Self, CliStateError>

source

fn reset(&self, root_path: &Path) -> Result<PathBuf, CliStateError>

Recreate all the state directories

source

fn create_dirs(root_path: &Path) -> Result<PathBuf, CliStateError>

Create all the state directories

source

fn dir_as_string(&self) -> String

source

fn path(&self, name: impl AsRef<str>) -> PathBuf

source

fn overwrite( &self, name: impl AsRef<str>, config: <<Self as StateDirTrait>::Item as StateItemTrait>::Config ) -> Result<Self::Item, CliStateError>

source

fn create( &self, name: impl AsRef<str>, config: <<Self as StateDirTrait>::Item as StateItemTrait>::Config ) -> Result<Self::Item, CliStateError>

source

fn get(&self, name: impl AsRef<str>) -> Result<Self::Item, CliStateError>

source

fn list(&self) -> Result<Vec<Self::Item>, CliStateError>

source

fn list_items_names(&self) -> Result<Vec<String>, CliStateError>

source

fn is_item_path(&self, path: &PathBuf) -> Result<bool, CliStateError>

source

fn list_items_paths(&self) -> Result<Vec<PathBuf>, CliStateError>

source

fn delete(&self, name: impl AsRef<str>) -> Result<(), CliStateError>

source

fn default_path(&self) -> Result<PathBuf, CliStateError>

source

fn default(&self) -> Result<Self::Item, CliStateError>

source

fn set_default(&self, name: impl AsRef<str>) -> Result<(), CliStateError>

source

fn is_default(&self, name: impl AsRef<str>) -> Result<bool, CliStateError>

source

fn is_empty(&self) -> Result<bool, CliStateError>

source

fn exists(&self, name: impl AsRef<str>) -> bool

Object Safety§

This trait is not object safe.

Implementors§

source§

impl StateDirTrait for CredentialsState

§

type Item = CredentialState

source§

const DEFAULT_FILENAME: &'static str = "credential"

source§

const DIR_NAME: &'static str = "credentials"

source§

const HAS_DATA_DIR: bool = false

source§

impl StateDirTrait for IdentitiesState

§

type Item = IdentityState

source§

const DEFAULT_FILENAME: &'static str = "identity"

source§

const DIR_NAME: &'static str = "identities"

source§

const HAS_DATA_DIR: bool = true

source§

impl StateDirTrait for NodesState

§

type Item = NodeState

source§

const DEFAULT_FILENAME: &'static str = "node"

source§

const DIR_NAME: &'static str = "nodes"

source§

const HAS_DATA_DIR: bool = false

source§

impl StateDirTrait for ProjectsState

§

type Item = ProjectState

source§

const DEFAULT_FILENAME: &'static str = "project"

source§

const DIR_NAME: &'static str = "projects"

source§

const HAS_DATA_DIR: bool = false

source§

impl StateDirTrait for SpacesState

§

type Item = SpaceState

source§

const DEFAULT_FILENAME: &'static str = "space"

source§

const DIR_NAME: &'static str = "spaces"

source§

const HAS_DATA_DIR: bool = false

source§

impl StateDirTrait for TrustContextsState

§

type Item = TrustContextState

source§

const DEFAULT_FILENAME: &'static str = "trust_context"

source§

const DIR_NAME: &'static str = "trust_contexts"

source§

const HAS_DATA_DIR: bool = false

source§

impl StateDirTrait for UsersInfoState

§

type Item = UserInfoState

source§

const DEFAULT_FILENAME: &'static str = "user_info"

source§

const DIR_NAME: &'static str = "users_info"

source§

const HAS_DATA_DIR: bool = false

source§

impl StateDirTrait for VaultsState

§

type Item = VaultState

source§

const DEFAULT_FILENAME: &'static str = "vault"

source§

const DIR_NAME: &'static str = "vaults"

source§

const HAS_DATA_DIR: bool = true