pub struct SqliteDb { /* private fields */ }Expand description
SQLite-backed items database
Implementations§
Source§impl SqliteDb
impl SqliteDb
Sourcepub fn open_in_memory() -> Result<Self, Error>
pub fn open_in_memory() -> Result<Self, Error>
Open an in-memory database (for testing)
Sourcepub fn get_setting(&self, key: &str) -> RepoResult<Option<String>>
pub fn get_setting(&self, key: &str) -> RepoResult<Option<String>>
Get a setting value
Sourcepub fn set_setting(&self, key: &str, value: &str) -> RepoResult<()>
pub fn set_setting(&self, key: &str, value: &str) -> RepoResult<()>
Set a setting value
Sourcepub fn get_or_create_salt(&self) -> RepoResult<String>
pub fn get_or_create_salt(&self) -> RepoResult<String>
Get the source salt, generating one if it doesn’t exist
Sourcepub fn get_distinct_sources(&self) -> RepoResult<Vec<String>>
pub fn get_distinct_sources(&self) -> RepoResult<Vec<String>>
Get all distinct sources from the database
Source§impl SqliteDb
impl SqliteDb
Sourcepub fn get_all_values_bulk(
&self,
serials: &[&str],
) -> RepoResult<Vec<ItemValue>>
pub fn get_all_values_bulk( &self, serials: &[&str], ) -> RepoResult<Vec<ItemValue>>
Get all item_values for multiple serials (bulk fetch)
Trait Implementations§
Source§impl ImportExportRepository for SqliteDb
impl ImportExportRepository for SqliteDb
Source§fn import_from_dir(&self, dir: &Path) -> RepoResult<String>
fn import_from_dir(&self, dir: &Path) -> RepoResult<String>
Import an item from a directory
Source§fn export_to_dir(&self, serial: &str, dir: &Path) -> RepoResult<()>
fn export_to_dir(&self, serial: &str, dir: &Path) -> RepoResult<()>
Export an item to a directory
Source§impl ItemsRepository for SqliteDb
impl ItemsRepository for SqliteDb
Source§fn init(&self) -> RepoResult<()>
fn init(&self) -> RepoResult<()>
Initialize the database schema
Source§fn update_item(&self, serial: &str, update: &ItemUpdate) -> RepoResult<()>
fn update_item(&self, serial: &str, update: &ItemUpdate) -> RepoResult<()>
Update item metadata
Source§fn list_items(&self, filter: &ItemFilter) -> RepoResult<Vec<Item>>
fn list_items(&self, filter: &ItemFilter) -> RepoResult<Vec<Item>>
List items with optional filters
Source§fn delete_item(&self, serial: &str) -> RepoResult<bool>
fn delete_item(&self, serial: &str) -> RepoResult<bool>
Delete an item
Source§fn set_verification_status(
&self,
serial: &str,
status: VerificationStatus,
notes: Option<&str>,
) -> RepoResult<()>
fn set_verification_status( &self, serial: &str, status: VerificationStatus, notes: Option<&str>, ) -> RepoResult<()>
Set verification status for an item
Source§fn set_all_legal(&self, legal: bool) -> RepoResult<usize>
fn set_all_legal(&self, legal: bool) -> RepoResult<usize>
Set legal status for all items
Source§fn set_item_type(&self, serial: &str, item_type: &str) -> RepoResult<()>
fn set_item_type(&self, serial: &str, item_type: &str) -> RepoResult<()>
Set item type
Source§fn set_source(&self, serial: &str, source: &str) -> RepoResult<()>
fn set_source(&self, serial: &str, source: &str) -> RepoResult<()>
Set source for an item
Source§fn set_source_for_null(&self, source: &str) -> RepoResult<usize>
fn set_source_for_null(&self, source: &str) -> RepoResult<usize>
Set source for items without one
Source§fn set_source_where(&self, source: &str, condition: &str) -> RepoResult<usize>
fn set_source_where(&self, source: &str, condition: &str) -> RepoResult<usize>
Set source for items matching a condition (SQL WHERE clause)
WARNING: condition is inserted directly into SQL - do not use with untrusted input
Source§fn set_value(
&self,
serial: &str,
field: &str,
value: &str,
source: ValueSource,
source_detail: Option<&str>,
confidence: Confidence,
) -> RepoResult<()>
fn set_value( &self, serial: &str, field: &str, value: &str, source: ValueSource, source_detail: Option<&str>, confidence: Confidence, ) -> RepoResult<()>
Set a field value with source attribution
Source§fn get_values(&self, serial: &str, field: &str) -> RepoResult<Vec<ItemValue>>
fn get_values(&self, serial: &str, field: &str) -> RepoResult<Vec<ItemValue>>
Get all values for a field across sources
Source§fn get_best_value(
&self,
serial: &str,
field: &str,
) -> RepoResult<Option<ItemValue>>
fn get_best_value( &self, serial: &str, field: &str, ) -> RepoResult<Option<ItemValue>>
Get the best value for a field
Source§fn get_all_values(&self, serial: &str) -> RepoResult<Vec<ItemValue>>
fn get_all_values(&self, serial: &str) -> RepoResult<Vec<ItemValue>>
Get all values for an item
Source§fn get_best_values(&self, serial: &str) -> RepoResult<HashMap<String, String>>
fn get_best_values(&self, serial: &str) -> RepoResult<HashMap<String, String>>
Get best value for each field as a map
Source§fn get_all_items_best_values(
&self,
) -> RepoResult<HashMap<String, HashMap<String, String>>>
fn get_all_items_best_values( &self, ) -> RepoResult<HashMap<String, HashMap<String, String>>>
Get best values for all items (bulk query)
Source§fn stats(&self) -> RepoResult<DbStats>
fn stats(&self) -> RepoResult<DbStats>
Get database statistics
Source§fn migrate_column_values(&self, dry_run: bool) -> RepoResult<MigrationStats>
fn migrate_column_values(&self, dry_run: bool) -> RepoResult<MigrationStats>
Migrate column values to item_values table
Auto Trait Implementations§
impl !Freeze for SqliteDb
impl !RefUnwindSafe for SqliteDb
impl Send for SqliteDb
impl !Sync for SqliteDb
impl Unpin for SqliteDb
impl !UnwindSafe for SqliteDb
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