Skip to main content

DocReplicator

Struct DocReplicator 

Source
pub struct DocReplicator { /* private fields */ }
Expand description

Document Replicator - manages CRDT documents with dual storage

Implementations§

Source§

impl DocReplicator

Source

pub async fn new(config: DocReplicatorConfig) -> Result<Self>

Create new DocReplicator

Source

pub async fn create_document( &self, name: &str, storage_mode: StorageMode, ) -> Result<DocumentId>

Create a new document

Source

pub async fn create_document_with_key( &self, name: &str, storage_mode: StorageMode, encryption_key: &[u8; 32], ) -> Result<DocumentId>

Create a new document with specific encryption key

If name looks like a UUID, it will be used as the document ID directly. Otherwise, a new UUID will be generated for the ID.

Source

pub async fn get_document( &self, doc_id: &str, ) -> Result<Option<Arc<Mutex<Doc>>>>

Get document (returns None if not found)

Source

pub async fn document_exists_in_files(&self, doc_id: &str) -> Result<bool>

Check if document exists in Files storage

Source

pub async fn document_exists_in_web(&self, doc_id: &str) -> Result<bool>

Check if document exists in Web storage

Source

pub async fn insert_text( &self, doc_id: &str, index: usize, text: &str, ) -> Result<()>

Insert text at position

Source

pub async fn delete_text( &self, doc_id: &str, index: usize, len: usize, ) -> Result<()>

Delete text in range

Source

pub async fn get_text(&self, doc_id: &str) -> Result<String>

Get text content of document

Source

pub async fn get_crdt_update(&self, doc_id: &str) -> Result<Vec<u8>>

Get CRDT update (full state from beginning)

This encodes ALL changes from the document’s creation, suitable for syncing to a new peer that doesn’t have any prior state.

Source

pub async fn apply_crdt_update(&self, doc_id: &str, update: &[u8]) -> Result<()>

Apply CRDT update from peer

Source

pub async fn get_files_blob(&self, doc_id: &str) -> Result<Option<Vec<u8>>>

Get encrypted blob from Files storage

Source

pub async fn get_web_blob(&self, doc_id: &str) -> Result<Option<Vec<u8>>>

Get plaintext blob from Web storage

Source

pub async fn get_encryption_key(&self, doc_id: &str) -> Result<[u8; 32]>

Get encryption key for document (fails for Web-only docs)

Source

pub async fn decrypt_with_key( &self, doc_id: &str, key: &[u8; 32], ) -> Result<Vec<u8>>

Decrypt document with specific key (for testing wrong key scenarios)

Source

pub async fn list_documents(&self) -> Result<Vec<String>>

List all document IDs

Source

pub async fn delete_document(&self, doc_id: &str) -> Result<()>

Delete a document and all associated data

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more