arti-client: Add expand_keystore_dir function.

Part of #891
This commit is contained in:
Gabriela Moldovan 2023-06-23 20:01:29 +01:00
parent 67db6e3127
commit c93fac997e
1 changed files with 13 additions and 0 deletions

View File

@ -258,6 +258,8 @@ fn serde_default_keystore_dir() -> Option<Option<CfgPath>> {
Some(default_keystore_dir())
}
// TODO: the expand_* functions are very repetitive. Maybe we can generate them using a macro
// instead?
impl StorageConfig {
/// Try to expand `state_dir` to be a path buffer.
pub(crate) fn expand_state_dir(&self) -> Result<PathBuf, ConfigBuildError> {
@ -277,6 +279,17 @@ impl StorageConfig {
problem: e.to_string(),
})
}
/// Try to expand `keystore_dir` to be a path buffer.
pub(crate) fn expand_keystore_dir(&self) -> Result<Option<PathBuf>, ConfigBuildError> {
self.keystore_dir
.as_ref()
.map(|dir| dir.path())
.transpose()
.map_err(|e| ConfigBuildError::Invalid {
field: "keystore_dir".to_owned(),
problem: e.to_string(),
})
}
/// Return the FS permissions to use for state and cache directories.
pub(crate) fn permissions(&self) -> &Mistrust {
&self.permissions