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 async fn db(&self) -> Result<SphereDb<NativeStorage>>
pub async fn db(&self) -> Result<SphereDb<NativeStorage>>
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>
) -> Result<Self>
pub fn new( working_directory: &Path, custom_noosphere_directory: Option<&Path> ) -> 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.
Auto Trait Implementations§
impl !RefUnwindSafe for Workspace
impl Send for Workspace
impl Sync for Workspace
impl Unpin for Workspace
impl !UnwindSafe for Workspace
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
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FitForCBox for T
impl<T> FitForCBox for T
type CBoxWrapped = Box_<T>
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where &'a Self: for<'a> IntoIterator,
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>
§impl<T> ManuallyDropMut for T
impl<T> ManuallyDropMut for T
type Ret = ManuallyDrop<T>
fn manually_drop_mut<'__>(&'__ mut self) -> &'__ mut ManuallyDrop<T>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self, then passes self.as_mut() into the pipe
function.§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> References<RawCodec> for T
impl<T> References<RawCodec> for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut() only in debug builds, and is erased in release
builds.