Skip to main content

ConfigStore

Trait ConfigStore 

Source
pub trait ConfigStore: Send + Sync {
    // Required methods
    fn read(&self, path: &Path) -> Result<Option<String>, ConfigStoreError>;
    fn write(&self, path: &Path, content: &str) -> Result<(), ConfigStoreError>;
}
Expand description

Abstracts filesystem access for config file operations.

Args:

  • path - The path to the config file.

Usage:

let content = store.read(Path::new("~/.auths/config.toml"))?;
store.write(Path::new("~/.auths/config.toml"), "content")?;

Required Methods§

Source

fn read(&self, path: &Path) -> Result<Option<String>, ConfigStoreError>

Read the config file content. Returns None if the file does not exist.

Source

fn write(&self, path: &Path, content: &str) -> Result<(), ConfigStoreError>

Write content to the config file, creating parent dirs as needed.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§