pub struct SphereWriter { /* private fields */ }Expand description
A SphereWriter encapsulates most file system operations to a workspace. It enables batch operations to be performed via domain-specific verbs. Some of its implementation will vary based on JobKind due to the asymmetric structural representation of root and peer spheres when rendered to a filesystem.
Implementations§
Source§impl SphereWriter
impl SphereWriter
Sourcepub fn new(kind: JobKind, paths: Arc<SpherePaths>) -> Self
pub fn new(kind: JobKind, paths: Arc<SpherePaths>) -> Self
Construct a SphereWriter with the given JobKind and initialized SpherePaths.
Sourcepub fn mount(&self) -> &Path
pub fn mount(&self) -> &Path
The path to the directory where content and peers will be rendered to
Sourcepub fn base(&self) -> &Path
pub fn base(&self) -> &Path
The path to the root directory associated with this sphere, varying based on JobKind
Sourcepub fn private(&self) -> &Path
pub fn private(&self) -> &Path
The path to the directory containing “private” structural information
Sourcepub fn paths(&self) -> &SpherePaths
pub fn paths(&self) -> &SpherePaths
A reference to the SpherePaths in use by this SphereWriter
Sourcepub async fn write_link_record(&self) -> Result<()>
pub async fn write_link_record(&self) -> Result<()>
Write the [LinkRecord] to an appropriate location on disk (a noop for JobKinds that do not have a [LinkRecord])
Sourcepub async fn write_identity_and_version(
&self,
identity: &Did,
version: &Cid,
) -> Result<()>
pub async fn write_identity_and_version( &self, identity: &Did, version: &Cid, ) -> Result<()>
Write the identity and version to an appropriate location on disk
Sourcepub fn content_hard_link<R>(
&self,
slug: &str,
file: &SphereFile<R>,
) -> Result<PathBuf>
pub fn content_hard_link<R>( &self, slug: &str, file: &SphereFile<R>, ) -> Result<PathBuf>
Resolves the path to the hard link-equivalent file that contains the content for this slug. A SphereFile is required because we need a [MemoIpld] in the case of rendering root, and we need the Cid of that [MemoIpld] when rendering a peer. Both are conveniently bundled by a SphereFile.
Sourcepub async fn remove_content(&self, slug: &str) -> Result<()>
pub async fn remove_content(&self, slug: &str) -> Result<()>
Remove a link from the filesystem for a given slug
Sourcepub async fn write_content<R>(
&self,
slug: &str,
file: &mut SphereFile<R>,
) -> Result<()>where
R: AsyncFileBody,
pub async fn write_content<R>(
&self,
slug: &str,
file: &mut SphereFile<R>,
) -> Result<()>where
R: AsyncFileBody,
Write content to the file system for a given slug
Sourcepub async fn unlink_peer(&self, petname: &str) -> Result<()>
pub async fn unlink_peer(&self, petname: &str) -> Result<()>
Remove a symlink to a peer by petname
Trait Implementations§
Source§impl Clone for SphereWriter
impl Clone for SphereWriter
Source§fn clone(&self) -> SphereWriter
fn clone(&self) -> SphereWriter
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 SphereWriter
impl RefUnwindSafe for SphereWriter
impl Send for SphereWriter
impl Sync for SphereWriter
impl Unpin for SphereWriter
impl UnwindSafe for SphereWriter
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