Struct noosphere_cli::workspace::Workspace
source · pub struct Workspace { /* private fields */ }Expand description
The Workspace is the kernel of the CLI. It implements it keeps state and implements routines that are common to most CLI commands.
Implementations§
source§impl Workspace
impl Workspace
sourcepub fn working_directory(&self) -> &Path
pub fn working_directory(&self) -> &Path
The current working directory as given to the Workspace when it was created
sourcepub async fn sphere_context(&self) -> Result<Arc<Mutex<CliSphereContext>>>
pub async fn sphere_context(&self) -> Result<Arc<Mutex<CliSphereContext>>>
Get a mutex-guarded reference to the SphereContext for the current workspace
sourcepub fn release_sphere_context(&mut self)
pub fn release_sphere_context(&mut self)
Release the internally-held SphereContext (if any), causing its related resources to be dropped (e.g., database locks). Accessing it via Workspace::sphere_context will initialize it again.
sourcepub async fn db(&self) -> Result<SphereDb<PlatformStorage>>
pub async fn db(&self) -> Result<SphereDb<PlatformStorage>>
Get an owned referenced to the SphereDb that backs the local sphere. Note that this will initialize the SphereContext if it has not been already.
sourcepub fn key_storage(&self) -> &InsecureKeyStorage
pub fn key_storage(&self) -> &InsecureKeyStorage
Get the [KeyStorage] that is supported on the current platform
Get the Author that is configured to work on the local sphere
sourcepub fn require_sphere_paths(&self) -> Result<&Arc<SpherePaths>>
pub fn require_sphere_paths(&self) -> Result<&Arc<SpherePaths>>
Same as Workspace::sphere_paths but returns an error result if the SpherePaths have not been initialized for this Workspace.
sourcepub fn sphere_paths(&self) -> Option<&Arc<SpherePaths>>
pub fn sphere_paths(&self) -> Option<&Arc<SpherePaths>>
Get the SpherePaths for this workspace, if they have been initialized and/or discovered.
sourcepub async fn sphere_identity(&self) -> Result<Did>
pub async fn sphere_identity(&self) -> Result<Did>
Gets the Did of the sphere
sourcepub async fn counterpart_identity(&self) -> Result<Did>
pub async fn counterpart_identity(&self) -> Result<Did>
Get the configured counterpart sphere’s identity (for a gateway, this is the client sphere ID; for a client, this is the gateway’s sphere ID)
sourcepub async fn gateway_url(&self) -> Result<Url>
pub async fn gateway_url(&self) -> Result<Url>
Get the configured gateway URL for the local workspace
sourcepub fn is_sphere_initialized(&self) -> bool
pub fn is_sphere_initialized(&self) -> bool
Returns true if the local sphere has been initialized
sourcepub fn ensure_sphere_initialized(&self) -> Result<()>
pub fn ensure_sphere_initialized(&self) -> Result<()>
Asserts that a local sphere has been intiialized
sourcepub fn ensure_sphere_uninitialized(&self) -> Result<()>
pub fn ensure_sphere_uninitialized(&self) -> Result<()>
Asserts that a local sphere has not been intiialized
sourcepub async fn describe_closest_sphere(
&self,
starting_from: Option<&Path>
) -> Result<Option<SphereDetails>>
pub async fn describe_closest_sphere( &self, starting_from: Option<&Path> ) -> Result<Option<SphereDetails>>
For a given location on disk, describe the closest sphere by traversing file system ancestors until a sphere is found (either the root workspace or one of the rendered peers within that workspace).
sourcepub async fn read_subconscious_flavor_profile_nickname(
&self,
identity: &Did,
version: &Link<MemoIpld>
) -> Result<Option<String>>
pub async fn read_subconscious_flavor_profile_nickname( &self, identity: &Did, version: &Link<MemoIpld> ) -> Result<Option<String>>
Reads a nickname from a blessed slug _profile_, which is used by
Subconscious (the first embedder of Noosphere) to store user profile
data as JSON.
sourcepub async fn render(&self, depth: Option<u32>, force_full: bool) -> Result<()>
pub async fn render(&self, depth: Option<u32>, force_full: bool) -> 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 fn initialize(&mut self, sphere_paths: SpherePaths) -> Result<()>
pub fn initialize(&mut self, sphere_paths: SpherePaths) -> Result<()>
Initialize a Workspace in place with a given set of SpherePaths.
sourcepub fn new(
working_directory: &Path,
custom_noosphere_directory: Option<&Path>,
storage_config: Option<StorageConfig>
) -> Result<Self>
pub fn new( working_directory: &Path, custom_noosphere_directory: Option<&Path>, storage_config: Option<StorageConfig> ) -> Result<Self>
Create a new (possibly uninitialized) Workspace for a given working directory and optional global configuration directory.
This constructor will attempt to discover the SpherePaths by traversing ancestors from the provided working directory. The Workspace will be considered initialized if SpherePaths are discovered, otherwise it will be considered uninitialized.
If no global configuration directory is specified, one will be automatically chosen based on the current platform:
- Linux: /home/
/.config/noosphere - MacOS: /Users/
/Library/Application Support/network.subconscious.noosphere - Windows: C:\Users<user>\AppData\Roaming\subconscious\noosphere\config
On Linux, an $XDG_CONFIG_HOME environment variable will be respected if set.
Additionally, a StorageConfig may be provided to configure the storage used by the opened sphere.