pub struct DocumentStore { /* private fields */ }Expand description
A document store for managing multiple CRDT documents.
Implementations§
Source§impl DocumentStore
impl DocumentStore
Sourcepub fn replica_id(&self) -> &str
pub fn replica_id(&self) -> &str
Get the replica ID.
Sourcepub fn create_text(&mut self, title: impl Into<String>) -> DocumentId
pub fn create_text(&mut self, title: impl Into<String>) -> DocumentId
Create a new text document.
Sourcepub fn create_rich_text(&mut self, title: impl Into<String>) -> DocumentId
pub fn create_rich_text(&mut self, title: impl Into<String>) -> DocumentId
Create a new rich text document.
Sourcepub fn create_json(&mut self, title: impl Into<String>) -> DocumentId
pub fn create_json(&mut self, title: impl Into<String>) -> DocumentId
Create a new JSON document.
Sourcepub fn get(&self, id: &DocumentId) -> Option<&Document>
pub fn get(&self, id: &DocumentId) -> Option<&Document>
Get a document by ID.
Sourcepub fn get_mut(&mut self, id: &DocumentId) -> Option<&mut Document>
pub fn get_mut(&mut self, id: &DocumentId) -> Option<&mut Document>
Get a mutable document by ID.
Sourcepub fn delete(&mut self, id: &DocumentId) -> Option<Document>
pub fn delete(&mut self, id: &DocumentId) -> Option<Document>
Delete a document.
Sourcepub fn contains(&self, id: &DocumentId) -> bool
pub fn contains(&self, id: &DocumentId) -> bool
Check if a document exists.
Sourcepub fn text_insert(
&mut self,
id: &DocumentId,
position: usize,
text: &str,
) -> Result<(), DbError>
pub fn text_insert( &mut self, id: &DocumentId, position: usize, text: &str, ) -> Result<(), DbError>
Insert text into a text document.
Sourcepub fn text_delete(
&mut self,
id: &DocumentId,
start: usize,
length: usize,
) -> Result<(), DbError>
pub fn text_delete( &mut self, id: &DocumentId, start: usize, length: usize, ) -> Result<(), DbError>
Delete text from a text document.
Sourcepub fn text_content(&self, id: &DocumentId) -> Result<String, DbError>
pub fn text_content(&self, id: &DocumentId) -> Result<String, DbError>
Get text content.
Sourcepub fn rich_text_insert(
&mut self,
id: &DocumentId,
position: usize,
text: &str,
) -> Result<(), DbError>
pub fn rich_text_insert( &mut self, id: &DocumentId, position: usize, text: &str, ) -> Result<(), DbError>
Insert text into a rich text document.
Sourcepub fn rich_text_bold(
&mut self,
id: &DocumentId,
start: usize,
end: usize,
) -> Result<(), DbError>
pub fn rich_text_bold( &mut self, id: &DocumentId, start: usize, end: usize, ) -> Result<(), DbError>
Apply bold formatting.
Sourcepub fn rich_text_italic(
&mut self,
id: &DocumentId,
start: usize,
end: usize,
) -> Result<(), DbError>
pub fn rich_text_italic( &mut self, id: &DocumentId, start: usize, end: usize, ) -> Result<(), DbError>
Apply italic formatting.
Sourcepub fn rich_text_html(&self, id: &DocumentId) -> Result<String, DbError>
pub fn rich_text_html(&self, id: &DocumentId) -> Result<String, DbError>
Get rich text as HTML.
Sourcepub fn json_set(
&mut self,
id: &DocumentId,
path: &str,
value: JsonValue,
) -> Result<(), DbError>
pub fn json_set( &mut self, id: &DocumentId, path: &str, value: JsonValue, ) -> Result<(), DbError>
Set a value in a JSON document.
Sourcepub fn json_get(
&self,
id: &DocumentId,
path: &str,
) -> Result<Option<&JsonValue>, DbError>
pub fn json_get( &self, id: &DocumentId, path: &str, ) -> Result<Option<&JsonValue>, DbError>
Get a value from a JSON document.
Sourcepub fn json_to_value(&self, id: &DocumentId) -> Result<Value, DbError>
pub fn json_to_value(&self, id: &DocumentId) -> Result<Value, DbError>
Get JSON document as serde_json::Value.
Sourcepub fn find_by_title(&self, title: &str) -> Option<&Document>
pub fn find_by_title(&self, title: &str) -> Option<&Document>
Find a document by title.
Sourcepub fn query(&self, options: &QueryOptions) -> Vec<&Document>
pub fn query(&self, options: &QueryOptions) -> Vec<&Document>
Query documents with options.
Sourcepub fn scan_prefix(&self, prefix: &str) -> Vec<&Document>
pub fn scan_prefix(&self, prefix: &str) -> Vec<&Document>
Prefix scan for titles.
Sourcepub fn take_changes(&mut self) -> Vec<StoreChange>
pub fn take_changes(&mut self) -> Vec<StoreChange>
Take pending changes for replication.
Sourcepub fn apply_changes(&mut self, changes: &[StoreChange])
pub fn apply_changes(&mut self, changes: &[StoreChange])
Apply changes from another replica.
Sourcepub fn document_ids(&self) -> impl Iterator<Item = &DocumentId> + '_
pub fn document_ids(&self) -> impl Iterator<Item = &DocumentId> + '_
Get all document IDs.
Trait Implementations§
Source§impl Clone for DocumentStore
impl Clone for DocumentStore
Source§fn clone(&self) -> DocumentStore
fn clone(&self) -> DocumentStore
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DocumentStore
impl RefUnwindSafe for DocumentStore
impl Send for DocumentStore
impl Sync for DocumentStore
impl Unpin for DocumentStore
impl UnwindSafe for DocumentStore
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
Mutably borrows from an owned value. Read more