pub struct WorkspaceClient { /* private fields */ }Expand description
Workspace management client.
Provides async thread-safe CRUD operations for document persistence. All operations are async and can be safely called from multiple tasks.
§Thread Safety
The client is fully thread-safe and can be cloned cheaply
(it uses Arc internally).
Implementations§
Source§impl WorkspaceClient
impl WorkspaceClient
Sourcepub fn with_events(self, events: EventEmitter) -> Self
pub fn with_events(self, events: EventEmitter) -> Self
Create with event emitter.
Sourcepub fn with_config(self, config: WorkspaceClientConfig) -> Self
pub fn with_config(self, config: WorkspaceClientConfig) -> Self
Create with configuration.
Sourcepub async fn save(&self, doc: &PersistedDocument) -> Result<()>
pub async fn save(&self, doc: &PersistedDocument) -> Result<()>
Sourcepub async fn load(&self, doc_id: &str) -> Result<Option<PersistedDocument>>
pub async fn load(&self, doc_id: &str) -> Result<Option<PersistedDocument>>
Load a document from the workspace.
Returns Ok(None) if the document doesn’t exist.
§Errors
Returns an error if the workspace read fails.
Sourcepub async fn remove(&self, doc_id: &str) -> Result<bool>
pub async fn remove(&self, doc_id: &str) -> Result<bool>
Remove a document from the workspace.
Returns Ok(true) if the document was removed, Ok(false) if it didn’t exist.
§Errors
Returns an error if the workspace write fails.
Sourcepub async fn list(&self) -> Result<Vec<DocumentInfo>>
pub async fn list(&self) -> Result<Vec<DocumentInfo>>
Sourcepub async fn get_document_info(
&self,
doc_id: &str,
) -> Result<Option<DocumentInfo>>
pub async fn get_document_info( &self, doc_id: &str, ) -> Result<Option<DocumentInfo>>
Sourcepub async fn batch_remove(&self, doc_ids: &[&str]) -> Result<usize>
pub async fn batch_remove(&self, doc_ids: &[&str]) -> Result<usize>
Remove multiple documents from the workspace.
Returns the number of documents successfully removed.
§Errors
Returns an error if the workspace write fails.
Sourcepub async fn clear(&self) -> Result<usize>
pub async fn clear(&self) -> Result<usize>
Clear all documents from the workspace.
Returns the number of documents removed.
§Errors
Returns an error if the workspace write fails.
Sourcepub async fn stats(&self) -> Result<WorkspaceStats>
pub async fn stats(&self) -> Result<WorkspaceStats>
Get workspace statistics.
Trait Implementations§
Source§impl Clone for WorkspaceClient
impl Clone for WorkspaceClient
Source§fn clone(&self) -> WorkspaceClient
fn clone(&self) -> WorkspaceClient
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 WorkspaceClient
impl !RefUnwindSafe for WorkspaceClient
impl Send for WorkspaceClient
impl Sync for WorkspaceClient
impl Unpin for WorkspaceClient
impl UnsafeUnpin for WorkspaceClient
impl !UnwindSafe for WorkspaceClient
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> 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