cuprate_database/lib.rs
1#![doc = include_str!("../README.md")]
2#![allow(
3 // This lint is allowed because the following
4 // code exists a lot in this crate:
5 //
6 // ```rust
7 // let env_inner = env.env_inner();
8 // let tx_rw = env_inner.tx_rw()?;
9 // OpenTables::create_tables(&env_inner, &tx_rw)?;
10 // ```
11 //
12 // Rust thinks `env_inner` can be dropped earlier
13 // but it cannot, we need it for the lifetime of
14 // the database transaction + tables.
15 clippy::significant_drop_tightening
16)]
17// Allow some lints in tests.
18#![cfg_attr(
19 test,
20 allow(
21 clippy::cognitive_complexity,
22 clippy::needless_pass_by_value,
23 clippy::cast_possible_truncation,
24 clippy::too_many_lines
25 )
26)]
27
28//---------------------------------------------------------------------------------------------------- Public API
29// Import private modules, export public types.
30//
31// Documentation for each module is located in the respective file.
32
33mod backend;
34mod constants;
35mod database;
36mod env;
37mod error;
38mod key;
39mod storable;
40mod table;
41mod tables;
42mod transaction;
43
44pub mod config;
45pub mod resize;
46
47pub use backend::ConcreteEnv;
48pub use constants::{
49 DATABASE_BACKEND, DATABASE_CORRUPT_MSG, DATABASE_DATA_FILENAME, DATABASE_LOCK_FILENAME,
50};
51pub use database::{DatabaseIter, DatabaseRo, DatabaseRw};
52pub use env::{Env, EnvInner};
53pub use error::{DbResult, InitError, RuntimeError};
54pub use key::{Key, KeyCompare};
55pub use storable::{Storable, StorableBytes, StorableStr, StorableVec};
56pub use table::Table;
57pub use transaction::{TxRo, TxRw};
58
59//---------------------------------------------------------------------------------------------------- Private
60#[cfg(test)]
61pub(crate) mod tests;
62
63// Used inside public facing macros.
64#[doc(hidden)]
65pub use paste;
66
67//----------------------------------------------------------------------------------------------------
68// HACK: needed to satisfy the `unused_crate_dependencies` lint.
69cfg_if::cfg_if! {
70 if #[cfg(feature = "redb")] {
71 use redb as _;
72 } else {
73 use heed as _;
74 }
75}