Skip to main content

miden_node_db/
lib.rs

1mod conv;
2mod errors;
3pub mod migration;
4pub mod sqlite;
5
6use std::num::NonZeroUsize;
7
8pub use conv::{DatabaseTypeConversionError, SqlTypeConvert};
9pub use errors::{DatabaseError, SchemaVerificationError};
10/// Raw SQLite types for migrations and database setup outside the connection pool.
11pub use rusqlite::{Connection, Transaction};
12
13pub type Result<T, E = DatabaseError> = std::result::Result<T, E>;
14
15/// Returns the default SQLite connection pool size.
16///
17/// Defaults to twice the available CPU parallelism. If the OS cannot report the available
18/// parallelism, fall back to two connections.
19pub fn default_connection_pool_size() -> NonZeroUsize {
20    let available_cores = std::thread::available_parallelism().map_or(1, NonZeroUsize::get);
21    let connection_count = available_cores.saturating_mul(2);
22    NonZeroUsize::new(connection_count).expect("connection count must be non-zero")
23}
24
25#[doc(hidden)]
26pub use miden_node_persistence as persistence;