Centralised ~/.cipherstash/ profile file management.
The core type is [ProfileStore], a directory-scoped JSON file store that
handles reading, writing, and deleting profile data on disk.
Example
use stack_profile::ProfileStore;
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize)]
struct MyConfig {
name: String,
}
# fn main() -> Result<(), stack_profile::ProfileError> {
let store = ProfileStore::default();
store.save("my-config.json", &MyConfig { name: "example".into() })?;
let config: MyConfig = store.load("my-config.json")?;
# Ok(())
# }
For sensitive files, use [ProfileStore::save_with_mode] to restrict permissions:
# use stack_profile::ProfileStore;
# use serde::{Serialize, Deserialize};
# #[derive(Serialize, Deserialize)]
# struct Secret { key: String }
# fn main() -> Result<(), stack_profile::ProfileError> {
let store = ProfileStore::default();
store.save_with_mode("secret.json", &Secret { key: "shhh".into() }, 0o600)?;
# Ok(())
# }