pub struct ReadOnlyDatabase { /* private fields */ }Expand description
A redb database opened in read-only mode
Use Self::begin_read to get a ReadTransaction object that can be used to read from the database
Multiple processes may open a ReadOnlyDatabase, but it may not be opened concurrently
with a Database.
§Examples
Basic usage:
use redb::*;
const TABLE: TableDefinition<u64, u64> = TableDefinition::new("my_data");
let db = Database::create(filename)?;
let txn = db.begin_write()?;
{
let mut table = txn.open_table(TABLE)?;
table.insert(&0, &0)?;
}
txn.commit()?;
drop(db);
let db = ReadOnlyDatabase::open(filename)?;
let txn = db.begin_read()?;
{
let mut table = txn.open_table(TABLE)?;
println!("{}", table.get(&0)?.unwrap().value());
}Implementations§
Source§impl ReadOnlyDatabase
impl ReadOnlyDatabase
Sourcepub fn open(path: impl AsRef<Path>) -> Result<ReadOnlyDatabase, DatabaseError>
pub fn open(path: impl AsRef<Path>) -> Result<ReadOnlyDatabase, DatabaseError>
Opens an existing redb database.
Trait Implementations§
Source§impl ReadableDatabase for ReadOnlyDatabase
impl ReadableDatabase for ReadOnlyDatabase
Source§fn begin_read(&self) -> Result<ReadTransaction, TransactionError>
fn begin_read(&self) -> Result<ReadTransaction, TransactionError>
Begins a read transaction Read more
Source§fn cache_stats(&self) -> CacheStats
fn cache_stats(&self) -> CacheStats
Information regarding the usage of the in-memory cache Read more
Auto Trait Implementations§
impl Freeze for ReadOnlyDatabase
impl !RefUnwindSafe for ReadOnlyDatabase
impl Send for ReadOnlyDatabase
impl Sync for ReadOnlyDatabase
impl Unpin for ReadOnlyDatabase
impl !UnwindSafe for ReadOnlyDatabase
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more