Struct noosphere_cli::render::SphereWriter
source · 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 more