pub struct SqliteStorage { /* private fields */ }Expand description
SQLite-backed storage for mi6 events.
This struct provides the main entry point for database operations.
It implements the Storage trait from mi6-core.
§Example
use mi6_storage_sqlite::SqliteStorage;
use mi6_core::Storage;
let storage = SqliteStorage::open(Path::new("events.db"))?;
let count = storage.count()?;Implementations§
Source§impl SqliteStorage
impl SqliteStorage
Sourcepub fn open(path: &Path) -> Result<Self, StorageError>
pub fn open(path: &Path) -> Result<Self, StorageError>
Open or create a database at the given path.
This will:
- Create the parent directory if needed
- Enable WAL mode for better concurrent access
- Set a busy timeout for handling concurrent writes
- Initialize or migrate the schema as needed
Open or create a database at the given path, wrapped in an Arc for shared ownership.
This is a convenience method equivalent to Arc::new(SqliteStorage::open(path)?).
The returned Arc<SqliteStorage> implements the Storage trait directly, allowing
you to use it anywhere a Storage implementation is expected.
§Thread Safety
Note: SqliteStorage itself is not Sync because rusqlite::Connection is not
Sync. For true multi-threaded access, wrap in a Mutex:
use mi6_storage_sqlite::SqliteStorage;
use std::sync::{Arc, Mutex};
let storage = Arc::new(Mutex::new(SqliteStorage::open(path)?));Or use a connection pool for high-concurrency scenarios.
§Example
use mi6_storage_sqlite::SqliteStorage;
use mi6_core::Storage;
let storage = SqliteStorage::open_shared(path)?;
// Arc<SqliteStorage> implements Storage, so you can call methods directly
let count = storage.count()?;Sourcepub fn query_transcript_positions(
&self,
) -> Result<Vec<(String, FilePosition)>, StorageError>
pub fn query_transcript_positions( &self, ) -> Result<Vec<(String, FilePosition)>, StorageError>
Query all transcript file positions.
Returns a list of (file_path, position) pairs.
Trait Implementations§
Source§impl Storage for SqliteStorage
Implement Storage trait for SqliteStorage.
impl Storage for SqliteStorage
Implement Storage trait for SqliteStorage.