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 moreAuto Trait Implementations§
impl Freeze for SpherePaths
impl RefUnwindSafe for SpherePaths
impl Send for SpherePaths
impl Sync for SpherePaths
impl Unpin for SpherePaths
impl UnwindSafe for SpherePaths
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FitForCBox for T
impl<T> FitForCBox for T
type CBoxWrapped = Box_<T>
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more