pub struct SqliteBackend {
pub conn: Arc<Mutex<Connection>>,
/* private fields */
}Fields§
§conn: Arc<Mutex<Connection>>Implementations§
Source§impl SqliteBackend
impl SqliteBackend
Sourcepub fn new(path: impl AsRef<Path>) -> Result<Self, StorageError>
pub fn new(path: impl AsRef<Path>) -> Result<Self, StorageError>
Create or open a SQLite database at the given path.
On Unix a new database file is created owner-only (0600) before SQLite opens it, so it is never readable by other users at any point; existing files and WAL siblings are tightened best-effort (a file another owner shares with this process stays usable even though chmod fails). Directory permissions are the caller’s responsibility.
Sourcepub fn in_memory() -> Result<Self, StorageError>
pub fn in_memory() -> Result<Self, StorageError>
Create an in-memory database (for testing)
Sourcepub fn with_append_only(self, append_only: bool) -> Self
pub fn with_append_only(self, append_only: bool) -> Self
Opt in to append-only writes. Off by default, where saving an id that
is already stored replaces the row. When on, such a save fails with
StorageError::AlreadyExists and leaves the stored row untouched (a
batch save is rejected as a whole), and delete fails with
StorageError::PermissionDenied, so a recorded decision cannot be
rewritten through this handle. The flag belongs to the handle, not the
database file: another handle opened without it can still overwrite.
Sourcepub fn is_append_only(&self) -> bool
pub fn is_append_only(&self) -> bool
Whether this handle refuses to overwrite or delete stored snapshots.
pub fn save_internal(&self, snapshot: &Snapshot) -> Result<String, StorageError>
pub fn save_decision_internal( &self, decision: &DecisionSnapshot, ) -> Result<String, StorageError>
Sourcepub fn save_decisions_internal(
&self,
decisions: &[DecisionSnapshot],
) -> Result<Vec<String>, StorageError>
pub fn save_decisions_internal( &self, decisions: &[DecisionSnapshot], ) -> Result<Vec<String>, StorageError>
Write many decisions inside one transaction, so a batch costs one commit rather than one per decision. Either all rows land or none do.
Sourcepub fn delete_internal(&self, snapshot_id: &str) -> Result<bool, StorageError>
pub fn delete_internal(&self, snapshot_id: &str) -> Result<bool, StorageError>
Delete a snapshot by id; Ok(false) when no such id is stored.
Refused with PermissionDenied in append-only mode.