DatabaseManager

Interface for managing database instances and cache limits.

Properties

Link copied to clipboard
abstract val cacheLimit: StateFlow<Int>

Reactive stream of the current database cache limit.

Functions

Link copied to clipboard
abstract suspend fun associateDevice(address: String, nodeNum: Int, deviceId: String?, isSessionActive: () -> Boolean)

Associates the connection identified by address with the physical device learned from its radio handshake, so the same device reached over a different transport (BLE / TCP / USB) shares one database. Implementations must reject an address that is no longer active, preventing a stale identity emission from claiming or merging the newly selected transport's database. The first transport to report the device claims its active DB; a later transport folds its own data in and switches to the claimed DB. Idempotent once a device/transport pair has been unified.

Link copied to clipboard
abstract suspend fun cachedDeviceDbCount(): Int

Returns how many device-specific databases are currently cached on disk, subject to eviction.

Link copied to clipboard
abstract fun getCurrentCacheLimit(): Int

Returns the current database cache limit from storage.

Link copied to clipboard
abstract fun hasDatabaseFor(address: String?): Boolean

Returns true if a database exists for the given device address.

Link copied to clipboard
abstract fun setCacheLimit(limit: Int)

Sets the database cache limit.

Link copied to clipboard
abstract suspend fun switchActiveDatabase(address: String?)

Switches the active database to the one associated with the given address.