pub struct Peermerge<T, U>{ /* private fields */ }
Expand description
Peermerge is the main abstraction and a store for multiple documents.
Implementations§
Source§impl<T, U> Peermerge<T, U>
impl<T, U> Peermerge<T, U>
Sourcepub async fn peer_ids(
&self,
document_id: &DocumentId,
) -> Result<Vec<PeerId>, PeermergeError>
pub async fn peer_ids( &self, document_id: &DocumentId, ) -> Result<Vec<PeerId>, PeermergeError>
Get all known peer ids in a document
Sourcepub fn default_peer_header(&self) -> NameDescription
pub fn default_peer_header(&self) -> NameDescription
Get my default peer header given to a new document
Sourcepub async fn peer_header(
&self,
document_id: &DocumentId,
peer_id: &PeerId,
) -> Result<Option<NameDescription>, PeermergeError>
pub async fn peer_header( &self, document_id: &DocumentId, peer_id: &PeerId, ) -> Result<Option<NameDescription>, PeermergeError>
Get the current peer header value in a new document
Sourcepub async fn set_state_event_sender(
&mut self,
state_event_sender: Option<UnboundedSender<StateEvent>>,
) -> Result<(), PeermergeError>
pub async fn set_state_event_sender( &mut self, state_event_sender: Option<UnboundedSender<StateEvent>>, ) -> Result<(), PeermergeError>
Add or change the state event sender. The sender can already be given when peermerge is created but sometimes it’s more convinient to set it later.
Sourcepub async fn transact<F, O>(
&self,
document_id: &DocumentId,
cb: F,
) -> Result<O, PeermergeError>
pub async fn transact<F, O>( &self, document_id: &DocumentId, cb: F, ) -> Result<O, PeermergeError>
Read from a document in a single transaction
Sourcepub async fn transact_mut<F, O>(
&mut self,
document_id: &DocumentId,
cb: F,
change_id: Option<Vec<u8>>,
) -> Result<O, PeermergeError>
pub async fn transact_mut<F, O>( &mut self, document_id: &DocumentId, cb: F, change_id: Option<Vec<u8>>, ) -> Result<O, PeermergeError>
Read and write to a document in a single transaction. change_id
is an optional
parameter that will be returned in the corresponding DocumentChanged StateEvent.
Sourcepub async fn watch(
&mut self,
document_id: &DocumentId,
ids: Option<Vec<ObjId>>,
) -> Result<(), PeermergeError>
pub async fn watch( &mut self, document_id: &DocumentId, ids: Option<Vec<ObjId>>, ) -> Result<(), PeermergeError>
Set watching to list of Automerge object ids so that DocumentChanged StateEvents are returned only from changes to those objects. None means sending events of all changes which is the default.
Sourcepub async fn reserve_object<O: AsRef<ObjId>>(
&mut self,
document_id: &DocumentId,
obj: O,
) -> Result<(), PeermergeError>
pub async fn reserve_object<O: AsRef<ObjId>>( &mut self, document_id: &DocumentId, obj: O, ) -> Result<(), PeermergeError>
Reserve a given object for only local changes, preventing any peers from making changes
to it at the same time before unreserve_object
has been called. Useful especially when
editing a text to avoid having to update remote changes to the field while typing.
Reserve is not persisted to storage.
Sourcepub async fn unreserve_object<O: AsRef<ObjId>>(
&mut self,
document_id: &DocumentId,
obj: O,
) -> Result<(), PeermergeError>
pub async fn unreserve_object<O: AsRef<ObjId>>( &mut self, document_id: &DocumentId, obj: O, ) -> Result<(), PeermergeError>
Un-reserve a given object previously reserved with reserve_object
.
Sourcepub async fn sharing_info(
&self,
document_id: &DocumentId,
) -> Result<DocumentSharingInfo, PeermergeError>
pub async fn sharing_info( &self, document_id: &DocumentId, ) -> Result<DocumentSharingInfo, PeermergeError>
Get sharing information about a document.
Sourcepub async fn document_secret(
&self,
document_id: &DocumentId,
) -> Result<Option<String>, PeermergeError>
pub async fn document_secret( &self, document_id: &DocumentId, ) -> Result<Option<String>, PeermergeError>
Get the document secret from a given document_id.
Sourcepub async fn reattach_secret(
&self,
document_id: &DocumentId,
) -> Result<String, PeermergeError>
pub async fn reattach_secret( &self, document_id: &DocumentId, ) -> Result<String, PeermergeError>
Get the reattach secret of a given document_id. Useful only for in-memory storage.
Sourcepub async fn protocol_ids(&self) -> Result<Vec<Vec<u8>>, PeermergeError>
pub async fn protocol_ids(&self) -> Result<Vec<Vec<u8>>, PeermergeError>
Get all connected protocol ids
Sourcepub async fn disconnect_protocol(
&mut self,
protocol_id: &[u8],
) -> Result<bool, PeermergeError>
pub async fn disconnect_protocol( &mut self, protocol_id: &[u8], ) -> Result<bool, PeermergeError>
Disconnect protocol by id, returns if protocol with id was found
Sourcepub async fn disconnect_all_protocols(
&mut self,
) -> Result<usize, PeermergeError>
pub async fn disconnect_all_protocols( &mut self, ) -> Result<usize, PeermergeError>
Disconnect all protocols, returns total number of protocols disconnected
Source§impl Peermerge<RandomAccessMemory, FeedMemoryPersistence>
impl Peermerge<RandomAccessMemory, FeedMemoryPersistence>
Sourcepub async fn new_memory(
options: PeermergeMemoryOptions,
) -> Result<Self, PeermergeError>
pub async fn new_memory( options: PeermergeMemoryOptions, ) -> Result<Self, PeermergeError>
Create a new memory Peermerge
Sourcepub async fn create_new_document_memory<F, O>(
&mut self,
options: CreateNewDocumentMemoryOptions,
init_cb: F,
change_id: Option<Vec<u8>>,
) -> Result<(DocumentInfo, O), PeermergeError>
pub async fn create_new_document_memory<F, O>( &mut self, options: CreateNewDocumentMemoryOptions, init_cb: F, change_id: Option<Vec<u8>>, ) -> Result<(DocumentInfo, O), PeermergeError>
Create a new document in-memory
Sourcepub async fn attach_document_memory(
&mut self,
options: AttachDocumentMemoryOptions,
) -> Result<DocumentInfo, PeermergeError>
pub async fn attach_document_memory( &mut self, options: AttachDocumentMemoryOptions, ) -> Result<DocumentInfo, PeermergeError>
Attach an existing document in-memory
Sourcepub async fn connect_protocol_memory<T>(
&mut self,
protocol_id: &[u8],
protocol: &mut FeedProtocol<T>,
) -> Result<(), PeermergeError>where
T: IO,
pub async fn connect_protocol_memory<T>(
&mut self,
protocol_id: &[u8],
protocol: &mut FeedProtocol<T>,
) -> Result<(), PeermergeError>where
T: IO,
Connect peer protocol in-memory
Source§impl Peermerge<RandomAccessDisk, FeedDiskPersistence>
impl Peermerge<RandomAccessDisk, FeedDiskPersistence>
Sourcepub async fn new_disk(
options: PeermergeDiskOptions,
) -> Result<Self, PeermergeError>
pub async fn new_disk( options: PeermergeDiskOptions, ) -> Result<Self, PeermergeError>
Create a new disk Peermerge
Sourcepub async fn document_infos_disk(
data_root_dir: &Path,
) -> Result<Option<Vec<DocumentInfo>>, PeermergeError>
pub async fn document_infos_disk( data_root_dir: &Path, ) -> Result<Option<Vec<DocumentInfo>>, PeermergeError>
Get information about possible documents stored to a given root directory
Sourcepub async fn open_disk(options: OpenDiskOptions) -> Result<Self, PeermergeError>
pub async fn open_disk(options: OpenDiskOptions) -> Result<Self, PeermergeError>
Open peermerge stored to disk
Sourcepub async fn create_new_document_disk<F, O>(
&mut self,
options: CreateNewDocumentDiskOptions,
init_cb: F,
change_id: Option<Vec<u8>>,
) -> Result<(DocumentInfo, O), PeermergeError>
pub async fn create_new_document_disk<F, O>( &mut self, options: CreateNewDocumentDiskOptions, init_cb: F, change_id: Option<Vec<u8>>, ) -> Result<(DocumentInfo, O), PeermergeError>
Create a new document on disk
Sourcepub async fn attach_document_disk(
&mut self,
options: AttachDocumentDiskOptions,
) -> Result<DocumentInfo, PeermergeError>
pub async fn attach_document_disk( &mut self, options: AttachDocumentDiskOptions, ) -> Result<DocumentInfo, PeermergeError>
Attach existing document to disk
Sourcepub async fn connect_protocol_disk<T>(
&mut self,
protocol_id: &[u8],
protocol: &mut FeedProtocol<T>,
) -> Result<(), PeermergeError>where
T: IO,
pub async fn connect_protocol_disk<T>(
&mut self,
protocol_id: &[u8],
protocol: &mut FeedProtocol<T>,
) -> Result<(), PeermergeError>where
T: IO,
Connect peer protocol to disk
Trait Implementations§
Auto Trait Implementations§
impl<T, U> Freeze for Peermerge<T, U>
impl<T, U> !RefUnwindSafe for Peermerge<T, U>
impl<T, U> Send for Peermerge<T, U>
impl<T, U> Sync for Peermerge<T, U>
impl<T, U> Unpin for Peermerge<T, U>
impl<T, U> !UnwindSafe for Peermerge<T, U>
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