pub struct MessagingService { /* private fields */ }Expand description
Plugin-internal service handle.
Implementations§
Source§impl MessagingService
impl MessagingService
Sourcepub fn open(
db_path: PathBuf,
peers: Arc<dyn PeerDirectory>,
control: Arc<dyn ControlSender>,
identity: Arc<dyn IdentitySecrets>,
) -> Result<Self>
pub fn open( db_path: PathBuf, peers: Arc<dyn PeerDirectory>, control: Arc<dyn ControlSender>, identity: Arc<dyn IdentitySecrets>, ) -> Result<Self>
Open the messaging database and bind the daemon-supplied ports.
Sourcepub fn subscribe(&self) -> Receiver<MessageEvent>
pub fn subscribe(&self) -> Receiver<MessageEvent>
Subscribe to the broadcast event stream. Each subscriber gets every future event until they drop the receiver.
Sourcepub fn storage(&self) -> &Arc<MessagingStorage>
pub fn storage(&self) -> &Arc<MessagingStorage>
Borrow the underlying storage handle (read-mostly use cases like
messages.history).
Sourcepub async fn list_conversations(&self) -> Result<Vec<ConversationSummary>>
pub async fn list_conversations(&self) -> Result<Vec<ConversationSummary>>
Snapshot of all conversations, sorted by most-recent activity.
Each summary’s name and x25519_pubkey are filled in from the
peer directory.
Sourcepub async fn record_local_send(
&self,
peer: NodeId,
message_id: [u8; 16],
body: String,
timestamp_ms: i64,
) -> Result<MessageRecord>
pub async fn record_local_send( &self, peer: NodeId, message_id: [u8; 16], body: String, timestamp_ms: i64, ) -> Result<MessageRecord>
Persist a freshly-sent local message in pending status.
Sourcepub async fn mark_sent(
&self,
peer: NodeId,
message_id: [u8; 16],
at_ms: i64,
) -> Result<()>
pub async fn mark_sent( &self, peer: NodeId, message_id: [u8; 16], at_ms: i64, ) -> Result<()>
Move an outbound message from pending to sent.
Sourcepub async fn mark_delivered(
&self,
peer: NodeId,
message_id: [u8; 16],
at_ms: i64,
) -> Result<()>
pub async fn mark_delivered( &self, peer: NodeId, message_id: [u8; 16], at_ms: i64, ) -> Result<()>
Apply a delivered ack from the peer.
Sourcepub async fn mark_read(
&self,
peer: NodeId,
message_id: [u8; 16],
at_ms: i64,
) -> Result<()>
pub async fn mark_read( &self, peer: NodeId, message_id: [u8; 16], at_ms: i64, ) -> Result<()>
Apply a read ack from the peer (if/when supported by the UI).
Sourcepub async fn mark_failed(
&self,
peer: NodeId,
message_id: [u8; 16],
reason: String,
at_ms: i64,
) -> Result<()>
pub async fn mark_failed( &self, peer: NodeId, message_id: [u8; 16], reason: String, at_ms: i64, ) -> Result<()>
Mark a previously-pending outbound message as failed.
Sourcepub async fn delete_conversation(&self, peer: NodeId) -> Result<(usize, bool)>
pub async fn delete_conversation(&self, peer: NodeId) -> Result<(usize, bool)>
Atomic per-peer wipe — see MessagingStorage::delete_conversation.
Sourcepub async fn delete_all_messages(&self) -> Result<(usize, usize)>
pub async fn delete_all_messages(&self) -> Result<(usize, usize)>
Atomic global wipe — see MessagingStorage::delete_all_messages.
Sourcepub async fn send(&self, peer: NodeId, body: String) -> Result<MessageRecord>
pub async fn send(&self, peer: NodeId, body: String) -> Result<MessageRecord>
Encrypt + send a user message to peer. Returns the persisted record
(with status pending initially, transitioning to sent once the
transport accepts it). Bumps to failed if no route or no x25519 is
known yet.
Sourcepub async fn handle_incoming_message(&self, src: NodeId, body: Bytes)
pub async fn handle_incoming_message(&self, src: NodeId, body: Bytes)
Decrypt + persist an incoming messaging.msg and ack it.
Sourcepub async fn handle_incoming_message_ack(&self, src: NodeId, body: Bytes)
pub async fn handle_incoming_message_ack(&self, src: NodeId, body: Bytes)
Apply an inbound messaging.ack to the local outbound row.
Sourcepub async fn on_peer_forgotten(&self, peer: NodeId)
pub async fn on_peer_forgotten(&self, peer: NodeId)
Plugin lifecycle: daemon dropped this peer’s identity. Wipe any
per-peer state owned by messaging and emit HistoryCleared so
live UIs flush their per-peer buffers.