Implement `paths` for `Profile`
Signed-off-by: xphoniex <xphoniex@users.noreply.github.com>
This commit is contained in:
parent
5847ad2ff1
commit
357fc79b41
|
|
@ -11,7 +11,7 @@
|
||||||
//! radicle.sock # Node control socket
|
//! radicle.sock # Node control socket
|
||||||
//!
|
//!
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::PathBuf;
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
|
@ -122,6 +122,11 @@ impl Profile {
|
||||||
.map(PathBuf::from)
|
.map(PathBuf::from)
|
||||||
.unwrap_or_else(|| self.home.join("node").join(node::DEFAULT_SOCKET_NAME))
|
.unwrap_or_else(|| self.home.join("node").join(node::DEFAULT_SOCKET_NAME))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get `Paths` of profile
|
||||||
|
pub fn paths(&self) -> Paths {
|
||||||
|
Paths { home: &self.home }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the path to the radicle home folder.
|
/// Get the path to the radicle home folder.
|
||||||
|
|
@ -137,3 +142,22 @@ pub fn home() -> Result<PathBuf, io::Error> {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct Paths<'a> {
|
||||||
|
home: &'a Path,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Paths<'_> {
|
||||||
|
pub fn storage(&self) -> PathBuf {
|
||||||
|
self.home.join("storage")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn keys(&self) -> PathBuf {
|
||||||
|
self.home.join("keys")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn node(&self) -> PathBuf {
|
||||||
|
self.home.join("node")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue