Struct noosphere_cli::native::workspace::Workspace
source · pub struct Workspace { /* private fields */ }Expand description
A utility for discovering and initializing the well-known paths for a working copy of a sphere and relevant global Noosphere configuration
Implementations
sourceimpl Workspace
impl Workspace
sourcepub async fn read_local_content<S: BlockStore>(
&self,
pattern: Option<GlobMatcher>,
store: &mut S
) -> Result<Content>
pub async fn read_local_content<S: BlockStore>(
&self,
pattern: Option<GlobMatcher>,
store: &mut S
) -> Result<Content>
Read the local content of the workspace in its entirety, filtered by an optional glob pattern. The glob pattern is applied to the file path relative to the workspace. This includes files that have not yet been saved to the sphere. All files are chunked into blocks, and those blocks are persisted to the provided store. TODO(#105): We may want to change this to take an optional list of paths to consider, and allow the user to rely on their shell for glob filtering
sourcepub async fn get_local_content_changes<Sa: Store, Sb: Store>(
&self,
pattern: Option<GlobMatcher>,
db: &SphereDb<Sa>,
new_blocks: &mut Sb
) -> Result<Option<(Content, ContentChanges)>>
pub async fn get_local_content_changes<Sa: Store, Sb: Store>(
&self,
pattern: Option<GlobMatcher>,
db: &SphereDb<Sa>,
new_blocks: &mut Sb
) -> Result<Option<(Content, ContentChanges)>>
Produces a manifest of changes (added, updated and removed) derived from the current state of the workspace
sourcepub async fn render<S: Store>(&self, db: &mut SphereDb<S>) -> Result<()>
pub async fn render<S: Store>(&self, db: &mut SphereDb<S>) -> Result<()>
Reads the latest local version of the sphere and renders its contents to files in the workspace. Note that this will overwrite any existing files in the workspace.
sourcepub async fn infer_content_type(&self, extension: &str) -> Result<ContentType>
pub async fn infer_content_type(&self, extension: &str) -> Result<ContentType>
Given a file extension, infer its mime
sourcepub async fn infer_file_extension(
&self,
content_type: ContentType
) -> Option<String>
pub async fn infer_file_extension(
&self,
content_type: ContentType
) -> Option<String>
Given a mime, infer its file extension
sourcepub async fn get_ignored_patterns(&self) -> Result<GlobSet>
pub async fn get_ignored_patterns(&self) -> Result<GlobSet>
Produce a matcher that will match any path that should be ignored when considering the files that make up the local workspace
sourcepub fn root_path(&self) -> &PathBuf
pub fn root_path(&self) -> &PathBuf
The root directory containing the working copy of sphere files on disk, as well as the local sphere data
sourcepub fn sphere_path(&self) -> &PathBuf
pub fn sphere_path(&self) -> &PathBuf
The path to the sphere data folder within the working file tree
sourcepub fn blocks_path(&self) -> &PathBuf
pub fn blocks_path(&self) -> &PathBuf
The path to the block storage database within the working file tree
sourcepub fn noosphere_path(&self) -> &PathBuf
pub fn noosphere_path(&self) -> &PathBuf
The path to the folder that contains global Noosphere configuration and keys generated by the user
sourcepub fn keys_path(&self) -> &PathBuf
pub fn keys_path(&self) -> &PathBuf
The path to the folder containing user-generated keys when there is no secure option for generating them available
Path to the local authorization (the granted UCAN) for the key that is authorized to work on the sphere
sourcepub fn key_path(&self) -> &PathBuf
pub fn key_path(&self) -> &PathBuf
The path to the file containing the DID of the local key used to operate on the local sphere
sourcepub fn identity_path(&self) -> &PathBuf
pub fn identity_path(&self) -> &PathBuf
The path to the file containing the DID of the sphere that is being worked on in this local workspace
pub fn config_path(&self) -> &PathBuf
pub async fn get_local_gateway_url(&self) -> Result<Url>
Attempts to read the locally stored authorization that enables the key to operate on this sphere; the returned authorization may be represented as either a UCAN or the CID of a UCAN
sourcepub async fn get_local_db(&self) -> Result<SphereDb<NativeStore>>
pub async fn get_local_db(&self) -> Result<SphereDb<NativeStore>>
Produces a SphereDb<NativeStore> referring to the block storage
backing the sphere in the local workspace
sourcepub async fn get_local_key(&self) -> Result<Ed25519KeyMaterial>
pub async fn get_local_key(&self) -> Result<Ed25519KeyMaterial>
Get the key material (with both verification and signing capabilities) for the locally configured author key.
sourcepub async fn get_local_identity(&self) -> Result<Did>
pub async fn get_local_identity(&self) -> Result<Did>
Get the identity of the sphere being worked on in the local workspace as a DID string
sourcepub async fn get_key_did(&self, name: &str) -> Result<String>
pub async fn get_key_did(&self, name: &str) -> Result<String>
Look up the DID for the key by its name
sourcepub async fn is_root_empty(&self) -> Result<bool>
pub async fn is_root_empty(&self) -> Result<bool>
Returns true if there are no files in the configured root path
sourcepub async fn get_all_keys(&self) -> Result<BTreeMap<String, String>>
pub async fn get_all_keys(&self) -> Result<BTreeMap<String, String>>
Reads all the available keys and returns a map of their names to their DIDs
sourcepub async fn unambiguous_default_key_name(&self) -> Result<String>
pub async fn unambiguous_default_key_name(&self) -> Result<String>
If there is only one key to choose from, returns its name. Otherwise returns an error result.
sourcepub fn expect_local_directories(&self) -> Result<()>
pub fn expect_local_directories(&self) -> Result<()>
Asserts that all related directories for the suggested working file tree root are present
sourcepub fn expect_global_directories(&self) -> Result<()>
pub fn expect_global_directories(&self) -> Result<()>
Asserts that the global Noosphere directories are present
sourcepub async fn initialize_local_directories(&self) -> Result<()>
pub async fn initialize_local_directories(&self) -> Result<()>
Creates all the directories needed to start rendering a sphere in the configured working file tree root
sourcepub async fn initialize_global_directories(&self) -> Result<()>
pub async fn initialize_global_directories(&self) -> Result<()>
Creates the global Noosphere config and keys directories