StoreLocator

sealed interface StoreLocator

Where a KryptoStore androidx.datastore.core.DataStore persists.

Prefer Platform from commonMain: file targets use Platform.producePath, JS/Wasm use Platform.name (IndexedDB for typed proto, localStorage for preferences).

File / Named are explicit single-backend escape hatches (fail closed on the wrong target).

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class File(val producePath: () -> Path) : StoreLocator

File-backed only (Okio).

Link copied to clipboard
data class Named(val name: String) : StoreLocator

Named web store only (non-blank). Typed proto → IndexedDB; preferences → localStorage.

Link copied to clipboard
data class Platform(val producePath: () -> Path, val name: String) : StoreLocator

Dual identity with automatic platform routing.

Functions

Link copied to clipboard

Applies this locator's logical store name (for StoreLocator.Platform and StoreLocator.Named) to options via EncryptedStoreOptions.applyDefaultStoreName so AAD derivation is identical across file and web targets when EncryptedStoreOptions.storeName is left at its default.

Link copied to clipboard
fun <R> StoreLocator.resolve(onFile: (producePath: () -> Path) -> R, onNamed: (name: String) -> R): R

Resolves this locator to a file path or web name for the current target.

fun <R> StoreLocator.resolve(usesFileStorage: Boolean, onFile: (producePath: () -> Path) -> R, onNamed: (name: String) -> R): R

Same as resolve with an explicit usesFileStorage override (tests / tooling).