Skip to content

Commit

Permalink
Move InMemoryBackend and FileBackend exports into backends module
Browse files Browse the repository at this point in the history
  • Loading branch information
cberner committed Oct 23, 2023
1 parent 78825c7 commit 8cf6cc8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/backends.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pub use crate::tree_store::file_backend::FileBackend;
pub use crate::tree_store::InMemoryBackend;
7 changes: 4 additions & 3 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::error::TransactionError;
use crate::multimap_table::{parse_subtree_roots, DynamicCollection};
use crate::sealed::Sealed;
use crate::transactions::SAVEPOINT_TABLE;
use crate::tree_store::file_backend::FileBackend;
#[cfg(feature = "logging")]
use log::{info, warn};

Expand Down Expand Up @@ -814,7 +815,7 @@ impl Builder {
.open(path)?;

Database::new(
Box::new(crate::FileBackend::new(file)?),
Box::new(FileBackend::new(file)?),
self.page_size,
self.region_size,
self.read_cache_size_bytes,
Expand All @@ -831,7 +832,7 @@ impl Builder {
}

Database::new(
Box::new(crate::FileBackend::new(file)?),
Box::new(FileBackend::new(file)?),
self.page_size,
None,
self.read_cache_size_bytes,
Expand All @@ -844,7 +845,7 @@ impl Builder {
/// The file must be empty or contain a valid database.
pub fn create_file(&self, file: File) -> Result<Database, DatabaseError> {
Database::new(
Box::new(crate::FileBackend::new(file)?),
Box::new(FileBackend::new(file)?),
self.page_size,
self.region_size,
self.read_cache_size_bytes,
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ pub use multimap_table::{
};
pub use table::{Drain, DrainFilter, Range, ReadOnlyTable, ReadableTable, Table};
pub use transactions::{DatabaseStats, Durability, ReadTransaction, WriteTransaction};
pub use tree_store::file_backend::FileBackend;
pub use tree_store::{AccessGuard, AccessGuardMut, InMemoryBackend, Savepoint};
pub use tree_store::{AccessGuard, AccessGuardMut, Savepoint};
pub use types::{RedbKey, RedbValue, TypeName};

type Result<T = (), E = StorageError> = std::result::Result<T, E>;

#[cfg(feature = "python")]
pub use crate::python::redb;

pub mod backends;
mod complex_types;
mod db;
mod error;
Expand Down
3 changes: 2 additions & 1 deletion src/tree_store/page_store/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ impl TransactionHeader {

#[cfg(test)]
mod test {
use crate::backends::FileBackend;
use crate::db::TableDefinition;
use crate::tree_store::page_store::header::{
GOD_BYTE_OFFSET, MAGICNUMBER, PAGE_SIZE, PRIMARY_BIT, RECOVERY_REQUIRED,
Expand All @@ -413,7 +414,7 @@ mod test {
use crate::tree_store::page_store::TransactionalMemory;
#[cfg(not(target_os = "windows"))]
use crate::StorageError;
use crate::{Database, FileBackend, ReadableTable};
use crate::{Database, ReadableTable};
use std::fs::OpenOptions;
use std::io::{Read, Seek, SeekFrom, Write};
use std::mem::size_of;
Expand Down

0 comments on commit 8cf6cc8

Please sign in to comment.