pub struct MessageSyncService { /* private fields */ }Expand description
Message synchronization service
Implementations§
Source§impl MessageSyncService
impl MessageSyncService
Sourcepub async fn get_all_messages(&self, entity_id: &str) -> AppResult<SyncResponse>
pub async fn get_all_messages(&self, entity_id: &str) -> AppResult<SyncResponse>
Get all messages for an entity (contact, group, project, org, channel) This is the entry point for sync requests from other peers
Sourcepub async fn receive_message(
&self,
message: CRDTMessage,
) -> AppResult<ReceiveResult>
pub async fn receive_message( &self, message: CRDTMessage, ) -> AppResult<ReceiveResult>
Handle incoming message - detect out-of-order and missing dependencies
Sourcepub async fn send_message(
&self,
entity_id: String,
entity_type: EntityType,
content: MessageContent,
reply_to_id: Option<String>,
) -> AppResult<CRDTMessage>
pub async fn send_message( &self, entity_id: String, entity_type: EntityType, content: MessageContent, reply_to_id: Option<String>, ) -> AppResult<CRDTMessage>
Send a new message - assigns vector clock and Lamport timestamp
Sourcepub async fn request_sync(
&self,
entity_id: &str,
from_peer_id: &str,
) -> AppResult<SyncRequest>
pub async fn request_sync( &self, entity_id: &str, from_peer_id: &str, ) -> AppResult<SyncRequest>
Request sync from a peer - send our vector clock and get missing messages
Sourcepub async fn handle_sync_response(
&self,
response: SyncResponse,
) -> AppResult<SyncResult>
pub async fn handle_sync_response( &self, response: SyncResponse, ) -> AppResult<SyncResult>
Handle sync response - integrate received messages
Sourcepub async fn get_sync_state(
&self,
entity_id: &str,
) -> AppResult<EntitySyncState>
pub async fn get_sync_state( &self, entity_id: &str, ) -> AppResult<EntitySyncState>
Get sync state for an entity
Sourcepub async fn get_messages(&self, entity_id: &str) -> AppResult<Vec<CRDTMessage>>
pub async fn get_messages(&self, entity_id: &str) -> AppResult<Vec<CRDTMessage>>
Get all messages in causal order for an entity
Sourcepub async fn needs_sync(
&self,
entity_id: &str,
remote_clock: &VectorClock,
) -> bool
pub async fn needs_sync( &self, entity_id: &str, remote_clock: &VectorClock, ) -> bool
Check if we need to request a sync (missing messages)
pub async fn delete_message( &self, entity_id: &str, message_id: &str, ) -> AppResult<bool>
pub async fn edit_message( &self, entity_id: &str, message_id: &str, new_text: String, ) -> AppResult<u64>
pub async fn add_reaction( &self, entity_id: &str, message_id: &str, emoji: String, peer_id: String, ) -> AppResult<()>
pub async fn remove_reaction( &self, entity_id: &str, message_id: &str, emoji: String, peer_id: String, ) -> AppResult<()>
pub async fn get_reactions( &self, entity_id: &str, message_id: &str, ) -> AppResult<Vec<Reaction>>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for MessageSyncService
impl !RefUnwindSafe for MessageSyncService
impl Send for MessageSyncService
impl Sync for MessageSyncService
impl Unpin for MessageSyncService
impl !UnwindSafe for MessageSyncService
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