Struct noosphere_cli::paths::SpherePaths
source · pub struct SpherePaths { /* private fields */ }Expand description
SpherePaths record the critical paths within a sphere workspace as rendered to a typical file system. It is used to ensure that we read from and write to consistent locations when rendering and updating a sphere as files on disk.
NOTE: We use hashes to represent internal paths for a couple of reasons, both related to Windows filesystem limitations:
- Windows filesystem, in the worst case, only allows 260 character-long paths
- Windows does not allow various characters (e.g., ‘:’) in file paths, and there is no option to escape those characters
Hashing eliminates problem 2 and improves conditions so that we are more likely to avoid problem 1.
See: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry See also: https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
Implementations§
source§impl SpherePaths
impl SpherePaths
sourcepub async fn initialize(root: &Path) -> Result<Self>
pub async fn initialize(root: &Path) -> Result<Self>
Initialize SpherePaths for a given root path. This has the effect of creating the “private” directory hierarchy (starting from SPHERE_DIRECTORY inside the root).
sourcepub fn discover(from: Option<&Path>) -> Option<Self>
pub fn discover(from: Option<&Path>) -> Option<Self>
Attempt to discover an existing workspace root by traversing ancestor directories until one is found that contains a SPHERE_DIRECTORY.
sourcepub fn version(&self) -> &Path
pub fn version(&self) -> &Path
The path to the root version file within the local SPHERE_DIRECTORY
sourcepub fn identity(&self) -> &Path
pub fn identity(&self) -> &Path
The path to the root identity file within the local SPHERE_DIRECTORY
sourcepub fn depth(&self) -> &Path
pub fn depth(&self) -> &Path
The path to the root depth file within the local SPHERE_DIRECTORY
sourcepub fn root(&self) -> &Path
pub fn root(&self) -> &Path
The path to the workspace root directory, which contains a SPHERE_DIRECTORY
sourcepub fn sphere(&self) -> &Path
pub fn sphere(&self) -> &Path
The path to the SPHERE_DIRECTORY within the workspace root
sourcepub fn peers(&self) -> &Path
pub fn peers(&self) -> &Path
The path the directory within the SPHERE_DIRECTORY that contains rendered peer spheres
sourcepub fn slug(&self, slug: &str) -> Result<PathBuf>
pub fn slug(&self, slug: &str) -> Result<PathBuf>
Given a slug, get a path where we may write a reverse-symlink to a file system file that is a rendered equivalent of the content that can be found at that slug. The slug’s UTF-8 bytes are base64-encoded so that certain characters that are allowed in slugs (e.g., ‘/’) do not prevent us from creating the symlink.
sourcepub fn peer_hard_link(&self, memo_cid: &Cid) -> PathBuf
pub fn peer_hard_link(&self, memo_cid: &Cid) -> PathBuf
Given a Cid for a peer’s memo, get a path to a file where the content referred to by that memo ought to be written.
Trait Implementations§
source§impl Clone for SpherePaths
impl Clone for SpherePaths
source§fn clone(&self) -> SpherePaths
fn clone(&self) -> SpherePaths
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more