1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! `SQLite` adapter configuration.
//!
//! **Configuration lives here.** Open a path explicitly or resolve from env:
//!
//! | API / env | Default | Purpose |
//! |-----------|---------|---------|
//! | [`SqliteStoragePort::open`](crate::SqliteStoragePort::open) | — | Open (or create) a database file. |
//! | [`SqliteStoragePort::from_env`](crate::SqliteStoragePort::from_env) / [`PATH_ENV`] | temp file | Resolve path via [`sqlite_path_from_env`]. |
//!
//! Production hosts must set [`PATH_ENV`] or call
//! [`SqliteStoragePort::open`](crate::SqliteStoragePort::open) with a durable, explicit path.
//! The temporary fallback is intended only for local development and tests.
//!
//! # Example
//!
//! ```rust,no_run
//! use photon_backend_sqlite::SqliteStoragePort;
//!
//! # async fn wire() -> photon_backend::Result<()> {
//! let _port = SqliteStoragePort::open("/var/lib/photon/events.db").await?;
//! // Photon::builder().storage_port(Arc::new(port)).auto_registry().build()?;
//! # Ok(())
//! # }
//! ```
/// Environment variable for the `SQLite` database file path.
pub const PATH_ENV: &str = "PHOTON_SQLITE_PATH";
/// Resolve database path from [`PATH_ENV`], or a unique file under the system temp dir.
///
/// The temporary fallback is not durable across hosts and must not be used for production data.