#![cfg_attr(redb_no_std, no_std)]
#![deny(clippy::all, clippy::pedantic, clippy::disallowed_methods)]
#![allow(
clippy::if_not_else,
clippy::iter_not_returning_iterator,
clippy::missing_errors_doc,
clippy::missing_panics_doc,
clippy::module_name_repetitions,
clippy::must_use_candidate,
clippy::needless_pass_by_value,
clippy::redundant_closure_for_method_calls,
clippy::similar_names,
clippy::too_many_lines,
clippy::unnecessary_wraps,
clippy::unreadable_literal
)]
extern crate alloc;
pub use db::ConcurrencyMode;
pub use db::{
Builder, CacheStats, Database, MultimapTableDefinition, MultimapTableHandle, ReadOnlyDatabase,
ReadableDatabase, RepairSession, StorageBackend, TableDefinition, TableHandle,
UntypedMultimapTableHandle, UntypedTableHandle,
};
pub use error::{
BackendError, CommitError, CompactionError, CursorError, DatabaseError, Error, SavepointError,
SetDurabilityError, StorageError, TableError, TransactionError,
};
#[cfg(feature = "experimental-api-5")]
pub use error::{TableTypeMismatch, TypeDefinitionInfo};
#[cfg(feature = "experimental-api-5")]
pub use key_range::KeyRange;
#[cfg(feature = "experimental-niches")]
pub use legacy_types::Legacy;
pub use multimap_table::{
MultimapRange, MultimapTable, MultimapValue, OwnedMultimapRange, OwnedMultimapValue,
ReadOnlyMultimapTable, ReadOnlyUntypedMultimapTable, ReadableMultimapTable,
};
pub use table::{
Cursor, CursorMut, Entry, ExtractIf, OwnedAccessGuard, OwnedRange, Range, ReadOnlyTable,
ReadOnlyUntypedTable, ReadableTable, ReadableTableMetadata, Table, TableStats,
};
#[cfg(feature = "experimental-api-5")]
pub use table::{OccupiedEntry, VacantEntry};
#[cfg(not(feature = "experimental-api-5"))]
pub type OccupiedEntry<'a, K, V> = table::OccupiedEntry<'a, 'a, K, V>;
#[cfg(not(feature = "experimental-api-5"))]
pub type VacantEntry<'a, K, V> = table::VacantEntry<'a, 'a, K, V>;
pub use transactions::{DatabaseStats, Durability, ReadTransaction, WriteTransaction};
pub use tree_store::{AccessGuard, AccessGuardMut, AccessGuardMutInPlace, Savepoint};
pub use types::{Key, MutInPlaceValue, TypeName, Value};
pub type Result<T = (), E = StorageError> = core::result::Result<T, E>;
pub mod backends;
mod complex_types;
mod db;
mod error;
#[cfg(feature = "experimental-api-5")]
mod key_range;
#[cfg(feature = "experimental-niches")]
mod legacy_types;
mod multimap_table;
mod sealed;
mod sync;
mod table;
mod transaction_tracker;
mod transactions;
mod tree_store;
mod tuple_types;
mod types;
#[cfg(all(redb_no_std, panic = "unwind"))]
compile_error!(
"redb is being built without the standard library, because its \"std\" feature is disabled \
(for example by `default-features = false`). Enable the \"std\" feature, or set \
panic = \"abort\" to build without it. Tests always unwind, so to test on the host, enable \
\"std\" there, for example through a dev-dependency."
);
#[cfg(all(feature = "cache_metrics", not(target_has_atomic = "64")))]
compile_error!(
"the \"cache_metrics\" feature requires a target with 64-bit atomics: its counters are \
AtomicU64. Disable the feature on this target."
);
#[cfg(not(redb_no_std))]
pub(crate) fn panicking() -> bool {
std::thread::panicking()
}
#[cfg(redb_no_std)]
pub(crate) fn panicking() -> bool {
false
}
#[cfg(test)]
fn create_tempfile() -> tempfile::NamedTempFile {
if cfg!(target_os = "wasi") {
tempfile::NamedTempFile::new_in("/tmp").unwrap()
} else {
tempfile::NamedTempFile::new().unwrap()
}
}