pub struct Document { /* private fields */ }Expand description
Encapsulates the Automerge AutoCommit and provides a generic interface,
s.t. we don’t need to worry about automerge internals elsewhere.
The interface allows us to apply changes to the CRDT in two ways:
- synchronization with other CRDTs through sync messages
- applying a delta (coming from an editor) directly
Furthermore there’s a way to retrieve and initialize the content.
Implementations§
Source§impl Document
impl Document
pub fn load(bytes: &[u8]) -> Self
pub fn save(&mut self) -> Vec<u8> ⓘ
pub fn save_incremental(&mut self) -> Vec<u8> ⓘ
pub fn actor_id(&self) -> String
pub fn receive_sync_message_log_patches( &mut self, message: AutomergeSyncMessage, peer_state: &mut SyncState, ) -> Vec<Patch>
pub fn generate_sync_message( &mut self, peer_state: &mut SyncState, ) -> Option<AutomergeSyncMessage>
pub fn apply_delta_to_doc( &mut self, delta: &TextDelta, file_path: &RelativePath, )
pub fn current_file_content(&self, file_path: &RelativePath) -> Result<String>
pub fn file_content_at( &self, file_path: &RelativePath, heads: &[ChangeHash], ) -> Result<String>
pub fn initialize_text(&mut self, text: &str, file_path: &RelativePath)
pub fn update_text( &mut self, desired_text: &str, file_path: &RelativePath, ) -> Option<TextDelta>
pub fn remove_file(&mut self, file_path: &RelativePath)
Sourcepub fn set_bytes(&mut self, bytes: &[u8], file_path: &RelativePath)
pub fn set_bytes(&mut self, bytes: &[u8], file_path: &RelativePath)
Used to set or update a binary file’s content.
pub fn files(&self) -> Vec<RelativePath>
pub fn file_exists(&self, file_path: &RelativePath) -> bool
pub fn get_heads(&mut self) -> Vec<ChangeHash>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Document
impl RefUnwindSafe for Document
impl Send for Document
impl Sync for Document
impl Unpin for Document
impl UnwindSafe for Document
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
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>
Converts
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>
Converts
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