pub struct Database { /* private fields */ }Expand description
Database handle for queue and history persistence.
Implementations§
Source§impl Database
impl Database
Sourcepub fn open(path: &Path) -> Result<Self, NzbError>
pub fn open(path: &Path) -> Result<Self, NzbError>
Open (or create) the database at the given path.
Sourcepub fn open_memory() -> Result<Self, NzbError>
pub fn open_memory() -> Result<Self, NzbError>
Open an in-memory database (for testing).
Sourcepub fn get_setting(&self, key: &str) -> Option<String>
pub fn get_setting(&self, key: &str) -> Option<String>
Read a setting by key.
Sourcepub fn set_setting(&self, key: &str, value: &str)
pub fn set_setting(&self, key: &str, value: &str)
Write a setting (upsert).
Sourcepub fn queue_insert(&self, job: &NzbJob) -> Result<(), NzbError>
pub fn queue_insert(&self, job: &NzbJob) -> Result<(), NzbError>
Insert a new job into the queue.
Sourcepub fn queue_update_progress(
&self,
id: &str,
status: JobStatus,
downloaded_bytes: u64,
articles_downloaded: usize,
articles_failed: usize,
files_completed: usize,
) -> Result<(), NzbError>
pub fn queue_update_progress( &self, id: &str, status: JobStatus, downloaded_bytes: u64, articles_downloaded: usize, articles_failed: usize, files_completed: usize, ) -> Result<(), NzbError>
Update job progress in the queue.
Sourcepub fn queue_update_priority(
&self,
id: &str,
priority: i32,
) -> Result<(), NzbError>
pub fn queue_update_priority( &self, id: &str, priority: i32, ) -> Result<(), NzbError>
Update job priority in the queue.
Sourcepub fn queue_list(&self) -> Result<Vec<NzbJob>, NzbError>
pub fn queue_list(&self) -> Result<Vec<NzbJob>, NzbError>
List all jobs in the queue, ordered by priority then add time.
Sourcepub fn history_insert(&self, entry: &HistoryEntry) -> Result<(), NzbError>
pub fn history_insert(&self, entry: &HistoryEntry) -> Result<(), NzbError>
Move a completed/failed job to history.
Sourcepub fn history_list(&self, limit: usize) -> Result<Vec<HistoryEntry>, NzbError>
pub fn history_list(&self, limit: usize) -> Result<Vec<HistoryEntry>, NzbError>
List history entries, most recent first.
Sourcepub fn history_get_nzb_data(
&self,
id: &str,
) -> Result<Option<Vec<u8>>, NzbError>
pub fn history_get_nzb_data( &self, id: &str, ) -> Result<Option<Vec<u8>>, NzbError>
Get the raw NZB data for a history entry (for retry).
Sourcepub fn history_enforce_retention(
&self,
max_entries: usize,
) -> Result<(), NzbError>
pub fn history_enforce_retention( &self, max_entries: usize, ) -> Result<(), NzbError>
Enforce history retention limit by deleting oldest entries.
Sourcepub fn history_get(&self, id: &str) -> Result<Option<HistoryEntry>, NzbError>
pub fn history_get(&self, id: &str) -> Result<Option<HistoryEntry>, NzbError>
Get a single history entry by ID.
Sourcepub fn queue_store_job_data(
&self,
id: &str,
data: &[u8],
) -> Result<(), NzbError>
pub fn queue_store_job_data( &self, id: &str, data: &[u8], ) -> Result<(), NzbError>
Store serialized job file/article state for resume support.
Sourcepub fn queue_load_job_data(&self, id: &str) -> Result<Option<Vec<u8>>, NzbError>
pub fn queue_load_job_data(&self, id: &str) -> Result<Option<Vec<u8>>, NzbError>
Load serialized job file/article state for resume.
Sourcepub fn queue_store_nzb_data(
&self,
id: &str,
nzb_data: &[u8],
) -> Result<(), NzbError>
pub fn queue_store_nzb_data( &self, id: &str, nzb_data: &[u8], ) -> Result<(), NzbError>
Store raw NZB data for a queue job.
Sourcepub fn queue_get_nzb_data(&self, id: &str) -> Result<Option<Vec<u8>>, NzbError>
pub fn queue_get_nzb_data(&self, id: &str) -> Result<Option<Vec<u8>>, NzbError>
Get raw NZB data from a queue job.
Sourcepub fn history_count(&self) -> Result<usize, NzbError>
pub fn history_count(&self) -> Result<usize, NzbError>
Count history entries.
Sourcepub fn history_clear(&self) -> Result<(), NzbError>
pub fn history_clear(&self) -> Result<(), NzbError>
Clear all history.
Sourcepub fn history_store_logs(
&self,
id: &str,
logs_json: &str,
) -> Result<(), NzbError>
pub fn history_store_logs( &self, id: &str, logs_json: &str, ) -> Result<(), NzbError>
Store per-job logs for a history entry.
Sourcepub fn history_get_logs(&self, id: &str) -> Result<Option<String>, NzbError>
pub fn history_get_logs(&self, id: &str) -> Result<Option<String>, NzbError>
Get per-job logs for a history entry.
Sourcepub fn rss_item_upsert(&self, item: &RssItem) -> Result<(), NzbError>
pub fn rss_item_upsert(&self, item: &RssItem) -> Result<(), NzbError>
Upsert an RSS feed item (insert or ignore if already exists).
Sourcepub fn rss_items_batch_upsert(
&self,
items: &[RssItem],
) -> Result<usize, NzbError>
pub fn rss_items_batch_upsert( &self, items: &[RssItem], ) -> Result<usize, NzbError>
Batch upsert RSS feed items in a single transaction. Returns the number of newly inserted items.
Sourcepub fn rss_item_exists(&self, id: &str) -> Result<bool, NzbError>
pub fn rss_item_exists(&self, id: &str) -> Result<bool, NzbError>
Check if an RSS item ID already exists in the database.
Sourcepub fn rss_items_list(
&self,
feed_name: Option<&str>,
limit: usize,
) -> Result<Vec<RssItem>, NzbError>
pub fn rss_items_list( &self, feed_name: Option<&str>, limit: usize, ) -> Result<Vec<RssItem>, NzbError>
List RSS items, optionally filtered by feed name, ordered by first_seen_at DESC.
Sourcepub fn rss_item_get(&self, id: &str) -> Result<Option<RssItem>, NzbError>
pub fn rss_item_get(&self, id: &str) -> Result<Option<RssItem>, NzbError>
Get a single RSS item by ID.
Sourcepub fn rss_item_mark_downloaded(
&self,
id: &str,
category: Option<&str>,
) -> Result<(), NzbError>
pub fn rss_item_mark_downloaded( &self, id: &str, category: Option<&str>, ) -> Result<(), NzbError>
Mark an RSS item as downloaded.
Sourcepub fn rss_item_count(&self) -> Result<usize, NzbError>
pub fn rss_item_count(&self) -> Result<usize, NzbError>
Count total RSS items.
Sourcepub fn rss_items_prune(&self, keep: usize) -> Result<usize, NzbError>
pub fn rss_items_prune(&self, keep: usize) -> Result<usize, NzbError>
Prune RSS items to keep only the N most recent (by first_seen_at).
Sourcepub fn rss_rule_insert(&self, rule: &RssRule) -> Result<(), NzbError>
pub fn rss_rule_insert(&self, rule: &RssRule) -> Result<(), NzbError>
Insert a new RSS download rule. feed_names is stored as comma-separated string in the DB.
Auto Trait Implementations§
impl !Freeze for Database
impl !RefUnwindSafe for Database
impl Send for Database
impl !Sync for Database
impl Unpin for Database
impl UnsafeUnpin for Database
impl !UnwindSafe for Database
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> 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