pub struct EntryRepository { /* private fields */ }Expand description
Repository for persisting relay entries to SQLite.
Thread-safe via internal Mutex. Uses WAL mode for better concurrency.
Implementations§
Source§impl EntryRepository
impl EntryRepository
Sourcepub fn insert(
&self,
id: &str,
body: &[u8],
content_type: Option<&str>,
expires_at: i64,
) -> Result<()>
pub fn insert( &self, id: &str, body: &[u8], content_type: Option<&str>, expires_at: i64, ) -> Result<()>
Inserts or replaces an entry in the database.
If the entry count exceeds max_entries, the oldest entry (by created_at)
is deleted first to make room (LRU eviction).
§Arguments
id- Unique identifier for the entrybody- Message body bytescontent_type- Optional content type headerexpires_at- Unix timestamp when entry expires
Sourcepub fn get(&self, id: &str) -> Result<Option<StoredEntry>>
pub fn get(&self, id: &str) -> Result<Option<StoredEntry>>
Retrieves an entry by ID.
Returns None if the entry doesn’t exist.
Sourcepub fn ack(&self, id: &str) -> Result<bool>
pub fn ack(&self, id: &str) -> Result<bool>
Marks an entry as acknowledged and clears its message body.
Returns true if an entry was updated, false if the entry didn’t exist.
Sourcepub fn delete(&self, id: &str) -> Result<bool>
pub fn delete(&self, id: &str) -> Result<bool>
Deletes an entry by ID.
Returns true if an entry was deleted, false if the entry didn’t exist.
Sourcepub fn cleanup_expired(&self) -> Result<usize>
pub fn cleanup_expired(&self) -> Result<usize>
Deletes all expired entries.
Returns the number of entries deleted.
Auto Trait Implementations§
impl !Freeze for EntryRepository
impl RefUnwindSafe for EntryRepository
impl Send for EntryRepository
impl Sync for EntryRepository
impl Unpin for EntryRepository
impl UnsafeUnpin for EntryRepository
impl UnwindSafe for EntryRepository
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
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