Skip to main content

MessagingStorage

Struct MessagingStorage 

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

Wraps a single SQLite connection guarded by a std::sync::Mutex. The daemon serializes writes through the mutex, which is acceptable for the expected message volume (interactive chat).

Implementations§

Source§

impl MessagingStorage

Source

pub fn open(path: PathBuf) -> Result<Self>

Open or create the database file and apply the canonical schema.

Source

pub fn insert_message(&self, m: &MessageRecord) -> Result<()>

Persist a brand-new message row. Caller is responsible for choosing the appropriate initial status (Pending for outbound, Delivered for inbound).

Source

pub fn bump_conversation_after_local_send( &self, peer_id_hex: &str, message_id_hex: &str, ts_ms: i64, body: &str, ) -> Result<()>

Refresh the conversations_meta row after a local outbound send.

Source

pub fn bump_conversation_after_remote_receive( &self, peer_id_hex: &str, message_id_hex: &str, ts_ms: i64, body: &str, ) -> Result<ConversationBump>

Refresh the conversations_meta row after an inbound message and return the resulting partial summary (the service layer fills in name and x25519_pubkey from the peer directory).

Source

pub fn set_message_status( &self, message_id_hex: &str, status: MessageStatus, delivered_at_ms: Option<i64>, read_at_ms: Option<i64>, ) -> Result<()>

Update the lifecycle status of an existing outbound message and the optional delivered/read timestamps.

Source

pub fn set_message_failed( &self, message_id_hex: &str, reason: &str, at_ms: i64, ) -> Result<()>

Set status = failed and persist a human-readable reason.

Source

pub fn history( &self, peer_id_hex: &str, before_ts_ms: Option<i64>, limit: i64, ) -> Result<(Vec<MessageRecord>, bool)>

Page through a peer’s history newest-first.

Source

pub fn list_conversations_raw(&self) -> Result<Vec<ConversationSummary>>

Snapshot of all conversations, sorted by most-recent activity. name and x25519_pubkey are left blank/None — the service layer fills them in from the daemon’s peer directory.

Source

pub fn delete_conversation(&self, peer_id_hex: &str) -> Result<(usize, bool)>

Atomic per-peer wipe of messages and conversations_meta. Returns (deleted_messages, deleted_conversation) so the caller can report exact counts to the RPC client.

Source

pub fn delete_all_messages(&self) -> Result<(usize, usize)>

Atomic global wipe of every message + conversation row.

Source

pub fn mark_read_up_to( &self, peer_id_hex: &str, up_to_ts_ms: i64, ) -> Result<i64>

Mark every message at-or-before up_to_ts_ms as read for the peer. Returns the new unread_count (always 0).

Source

pub fn delete_conversation_for_peer( &self, peer: &NodeId, ) -> Result<(usize, bool)>

Convenience wrapper used by crate::service::MessagingService when handling an on_peer_forgotten lifecycle event. Equivalent to Self::delete_conversation but keyed by NodeId instead of the hex projection.

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<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