Skip to main content

noxu_db/
lib.rs

1// Copyright (C) 2024-2025 Greg Burd.  Licensed under either of the
2// Apache License, Version 2.0 or the MIT license, at your option.
3// See LICENSE-APACHE and LICENSE-MIT at the root of this repository.
4// SPDX-License-Identifier: Apache-2.0 OR MIT
5
6#![allow(clippy::type_complexity, clippy::too_many_arguments)]
7//! > **Internal component of the [`noxu`](https://crates.io/crates/noxu) database.**
8//! >
9//! > This crate is published only so the `noxu` umbrella crate can depend on it.
10//! > Use `noxu` (`noxu = "7"`) in applications; depend on this crate directly only
11//! > if you are extending the engine internals. Its API may change without a major
12//! > version bump.
13//!
14//! Noxu DB - An embedded transactional database engine.
15//!
16//! Public API : Environment, Database,
17//! Cursor, Transaction, DatabaseEntry, SecondaryDatabase, Sequence, etc.
18//!
19//! This crate provides the public API for Noxu DB.
20//! It is designed to be familiar to embedded database users while being
21//! idiomatic Rust.
22//!
23//! # Example
24//!
25//! ```no_run
26//! use noxu_db::{EnvironmentConfig, DatabaseConfig};
27//! use std::path::PathBuf;
28//!
29//! let env_config = EnvironmentConfig::new(PathBuf::from("/tmp/mydb"))
30//!     .with_allow_create(true)
31//!     .with_transactional(true);
32//!
33//! let db_config = DatabaseConfig::new()
34//!     .with_allow_create(true)
35//!     .with_transactional(true);
36//! ```
37
38#[macro_use]
39mod observe;
40pub mod unimplemented_params;
41
42/// Re-export of the observability crate when the `observability` feature is enabled.
43/// Users can access `noxu_db::observe_crate::{metrics, tracing}` for their own
44/// recorder/subscriber setup.
45#[cfg(feature = "observability")]
46pub use noxu_observe as observe_crate;
47
48/// Periodic metrics exporter (samples `stats()` to the `metrics` facade).
49/// Only available with the `observability` feature.
50#[cfg(feature = "observability")]
51pub mod metrics_export;
52
53/// Re-export of the synchronization primitive that appears in this crate's
54/// public API.  `SecondaryDatabase::open` takes the primary database wrapped
55/// in `Arc<Mutex<Database>>`; this re-export lets callers name that `Mutex`
56/// (and its guard) without depending on the internal `noxu-sync` crate
57/// directly — reachable as `noxu::Mutex` through the umbrella.
58pub use noxu_sync::{Mutex, MutexGuard};
59
60/// Re-exports of `noxu-dbi` types that appear in public API signatures.
61///
62/// `Environment::set_replica_coordinator` takes a
63/// `SharedReplicaAckCoordinator`; users implementing a custom
64/// `ReplicaAckCoordinator` for testing need `ReplicaAckCoordinator` and
65/// `AckWaitError`/`AckWaitErrorKind` without depending on the internal
66/// `noxu-dbi` crate directly.  All are reachable as `noxu::Type` through
67/// the umbrella crate.
68///
69/// Closes re-audit JE F-6 and the partial fix noted in reaudit-jonhoo #3.
70pub use noxu_dbi::{
71    AckWaitError, AckWaitErrorKind, ReplicaAckCoordinator,
72    ReplicaAckPolicyKind, SharedReplicaAckCoordinator,
73};
74
75/// Re-exports of `noxu-recovery` types that appear in public API signatures.
76///
77/// `Environment::recovered_prepared_txns` returns `Vec<PreparedTxnInfo>`;
78/// `Environment::take_recovered_prepared_lns` returns
79/// `Vec<PreparedLnReplay>`, and `apply_recovered_prepared_lns` takes
80/// `&[PreparedLnReplay]`.  XA users need these types to name return values
81/// without depending on the internal `noxu-recovery` crate directly.
82///
83/// Closes reaudit-jonhoo #3.
84pub use noxu_recovery::{
85    PreparedLnOperation, PreparedLnReplay, PreparedTxnInfo,
86};
87
88pub mod cache_mode;
89pub mod checkpoint_config;
90pub mod cursor;
91pub mod cursor_config;
92pub mod database;
93pub mod database_config;
94pub mod database_entry;
95pub mod database_stats;
96pub mod db_iter;
97pub mod disk_ordered_cursor;
98pub mod durability;
99pub mod environment;
100pub mod environment_config;
101pub mod environment_mutable_config;
102pub mod error;
103pub mod extinction_filter;
104pub mod get;
105pub mod join_config;
106pub mod join_cursor;
107pub mod lock_mode;
108pub mod operation_result;
109pub mod operation_status;
110pub mod preload;
111pub mod put;
112pub mod read_options;
113pub mod scan_filter;
114pub mod secondary_config;
115pub mod secondary_cursor;
116pub mod secondary_database;
117pub mod sequence;
118pub mod sequence_config;
119pub mod sequence_stats;
120pub mod stats_config;
121pub mod stats_file;
122pub mod transaction;
123pub mod transaction_config;
124pub mod write_options;
125pub mod verify_daemon;
126
127// Re-export commonly used types
128pub use cache_mode::CacheMode;
129pub use checkpoint_config::CheckpointConfig;
130pub use cursor::Cursor;
131pub use cursor_config::CursorConfig;
132pub use database::Database;
133pub use database_config::{Comparator, DatabaseConfig};
134pub use database_entry::DatabaseEntry;
135pub use database_stats::{BtreeStats, DatabaseStats};
136pub use db_iter::{DbIter, DbRange};
137pub use disk_ordered_cursor::{
138    DiskOrderedCursor, DiskOrderedCursorConfig, open_disk_ordered_cursor_multi,
139};
140pub use durability::{Durability, ReplicaAckPolicy, SyncPolicy};
141pub use environment::Environment;
142pub use environment_config::{EnvironmentConfig, ExceptionListenerHolder};
143pub use environment_mutable_config::EnvironmentMutableConfig;
144pub use error::{
145    EnvironmentFailureReason, ExceptionEvent, ExceptionListener,
146    ExceptionSource, NoxuError, Result,
147};
148pub use extinction_filter::{ExtinctionFilter, ExtinctionStatus};
149pub use get::Get;
150pub use join_config::JoinConfig;
151pub use join_cursor::JoinCursor;
152pub use lock_mode::LockMode;
153pub use noxu_dbi::Trigger;
154pub use noxu_engine::{
155    EnvironmentStats, VerifyConfig, VerifyError, VerifyResult,
156};
157pub use operation_result::OperationResult;
158pub use operation_status::OperationStatus;
159pub use preload::{PreloadConfig, PreloadStats};
160pub use put::Put;
161pub use read_options::ReadOptions;
162pub use scan_filter::{ScanFilter, ScanResult};
163pub use secondary_config::{
164    ForeignKeyDeleteAction, ForeignKeyNullifier, ForeignMultiKeyNullifier,
165    SecondaryConfig, SecondaryKeyCreator, SecondaryMultiKeyCreator,
166};
167pub use secondary_cursor::SecondaryCursor;
168pub use secondary_database::SecondaryDatabase;
169pub use sequence::Sequence;
170pub use sequence_config::SequenceConfig;
171pub use sequence_stats::SequenceStats;
172pub use stats_config::StatsConfig;
173pub use transaction::Transaction;
174pub use transaction_config::TransactionConfig;
175pub use write_options::WriteOptions;