khive_db/backend/
claimed_file_identity.rs1use super::*;
3use crate::file_identity::DatabaseFileIdentity;
4
5impl StorageBackend {
6 pub fn sqlite_with_claimed_file_identity(
15 path: impl AsRef<Path>,
16 max_readers: Option<usize>,
17 wal_ceiling: WalCeilingPolicy,
18 read_only: bool,
19 expected: DatabaseFileIdentity,
20 ) -> Result<Self, SqliteError> {
21 let config = PoolConfig {
22 expected_file_identity: Some(expected),
23 wal_ceiling,
24 ..PoolConfig::default()
25 };
26 if read_only {
27 Self::sqlite_read_only_with_pool_config(path, config, max_readers)
28 } else {
29 Self::sqlite_with_pool_config(path, config, max_readers)
30 }
31 }
32
33 pub fn sqlite_with_claimed_file_identity_and_policies(
36 path: impl AsRef<Path>,
37 max_readers: Option<usize>,
38 wal_ceiling: WalCeilingPolicy,
39 expected: DatabaseFileIdentity,
40 disk_guard_config: crate::EffectiveDiskGuardConfig,
41 volume_lock_dir: std::path::PathBuf,
42 ) -> Result<Self, SqliteError> {
43 let config = PoolConfig {
44 expected_file_identity: Some(expected),
45 wal_ceiling,
46 disk_guard_config: Some(disk_guard_config),
47 volume_lock_dir: Some(volume_lock_dir),
48 ..PoolConfig::default()
49 };
50 Self::sqlite_with_pool_config(path, config, max_readers)
51 }
52}