Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
Implement `paths` for `Profile`
xphoniex committed 3 years ago
commit 357fc79b41b6381266f81ab7e508bf4e85419816
parent 5847ad2ff194301d2415e27ffbc58644d9f054a3
1 file changed +25 -1
modified radicle/src/profile.rs
@@ -11,7 +11,7 @@
//!       radicle.sock                           # Node control socket
//!
use std::io;
-
use std::path::PathBuf;
+
use std::path::{Path, PathBuf};

use thiserror::Error;

@@ -122,6 +122,11 @@ impl Profile {
            .map(PathBuf::from)
            .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.
@@ -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")
+
    }
+
}