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:

  1. Windows filesystem, in the worst case, only allows 260 character-long paths
  2. 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

source

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).

source

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.

source

pub fn version(&self) -> &Path

The path to the root version file within the local SPHERE_DIRECTORY

source

pub fn identity(&self) -> &Path

The path to the root identity file within the local SPHERE_DIRECTORY

source

pub fn depth(&self) -> &Path

The path to the root depth file within the local SPHERE_DIRECTORY

source

pub fn root(&self) -> &Path

The path to the workspace root directory, which contains a SPHERE_DIRECTORY

source

pub fn sphere(&self) -> &Path

The path to the SPHERE_DIRECTORY within the workspace root

source

pub fn peers(&self) -> &Path

The path the directory within the SPHERE_DIRECTORY that contains rendered peer spheres

source

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.

source

pub fn peer(&self, peer: &Did, version: &Cid) -> PathBuf

Given a peer Did and sphere version Cid, get a path where the that peer’s sphere at the given version ought to be rendered. The path will be unique and deterministic far a given combination of Did and Cid.

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.

Given a slug and a MemoIpld referring to some content in the local sphere, get a path to a file where the content referred to by the MemoIpld ought to be rendered (including file extension).

Similar to SpherePaths::root_hard_link but for a peer given by Did and sphere version Cid.

source

pub fn file(&self, base: &Path, slug: &str, memo: &MemoIpld) -> Result<PathBuf>

Given a base path, a slug and a MemoIpld, get the full file path (including inferred file extension) for a file that corresponds to the given MemoIpld.

Trait Implementations§

source§

impl Clone for SpherePaths

source§

fn clone(&self) -> SpherePaths

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for SpherePaths

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CompatExt for T

§

fn compat(self) -> Compat<T>

Applies the [Compat] adapter by value. Read more
§

fn compat_ref(&self) -> Compat<&T>

Applies the [Compat] adapter by shared reference. Read more
§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the [Compat] adapter by mutable reference. Read more
§

impl<T> FitForCBox for T

§

type CBoxWrapped = Box_<T>

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for Twhere T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ManuallyDropMut for T

§

type Ret = ManuallyDrop<T>

§

fn manually_drop_mut<'__>(&'__ mut self) -> &'__ mut ManuallyDrop<T>

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> References<RawCodec> for T

source§

fn references<R, E>(_c: RawCodec, _r: &mut R, _set: &mut E) -> Result<(), Error>where R: Read, E: Extend<Cid<64>>,

Scrape the references from an impl Read. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> UpcastAny for Twhere T: 'static,

§

fn upcast_any(&self) -> &(dyn Any + 'static)

§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<S> ConditionalSend for Swhere S: Send,

§

impl<S> ConditionalSync for Swhere S: Send + Sync,

§

impl<S> TargetConditionalSendSync for Swhere S: Send + Sync,

source§

impl<T> TryBundleSendSync for Twhere T: Send + Sync,

source§

impl<U> UcanStoreConditionalSend for Uwhere U: Send,

source§

impl<U> UcanStoreConditionalSendSync for Uwhere U: Send + Sync,