// `PathBuf` + `Zeroizing` are only referenced by the `Sqlite` variant, which is
// native-only. Gate the imports the same way to avoid a wasm32 unused-imports lint.
#[cfg(not(target_arch = "wasm32"))]
use std::path::PathBuf;
#[cfg(not(target_arch = "wasm32"))]
use zeroize::Zeroizing;

/// Where the persistent provider checkpoints `MemoryStorage` to. Selected at
/// `MessagingClient::init` time via [`ping_core::ClientConfig::storage_backend`].
#[derive(Debug, Clone, Default)]
pub enum StorageBackend {
    /// In-memory only. Default and what tests use; loses state on process exit.
    /// Cold-start scenarios (iOS NSE, web Service Worker) MUST use [`Self::Sqlite`]
    /// or [`Self::IndexedDb`] instead.
    #[default]
    Memory,

    /// SQLite-backed; native targets only. The SDK owns the file at `path`; the
    /// parent directory must exist. Pass `encryption_key = Some(...)` to enable
    /// SQLCipher; absence means the file is unencrypted (tests, dev only).
    #[cfg(not(target_arch = "wasm32"))]
    Sqlite {
        /// Absolute path. Host convention: `<app_support>/ping/<account_id>/mls.sqlite`
        /// for per-account isolation (CR-18); the SDK doesn't enforce this — the host
        /// picks the path.
        path: PathBuf,
        /// SQLCipher key. The SDK zeroes its copy on drop; the host is responsible
        /// for sourcing this from the OS keyring (Keychain / Keystore / etc.).
        encryption_key: Option<Zeroizing<[u8; 32]>>,
    },

    /// IndexedDB-backed; WASM only. Placeholder for the chunk-2 implementation — the
    /// memo's recommended approach. Returns an error from `PersistentMlsProvider::open`
    /// today; tracking issue: CR-4 WASM follow-up.
    #[cfg(target_arch = "wasm32")]
    IndexedDb { db_name: String },
}
