pub struct Database { /* private fields */ }
Expand description

Opened redb database file

Use Self::begin_read to get a ReadTransaction object that can be used to read from the database Use Self::begin_write to get a WriteTransaction object that can be used to read or write to the database

Multiple reads may be performed concurrently, with each other, and with writes. Only a single write may be in progress at a time.

Examples

Basic usage:

use redb::*;
const TABLE: TableDefinition<u64, u64> = TableDefinition::new("my_data");

let db = unsafe { Database::create(filename, db_max_size)? };
let write_txn = db.begin_write()?;
{
    let mut table = write_txn.open_table(TABLE)?;
    table.insert(&0, &0)?;
}
write_txn.commit()?;

Implementations

Opens the specified file as a redb database.

  • if the file does not exist, or is an empty file, a new database will be initialized in it
  • if the file is a valid redb database, it will be opened
  • otherwise this function will return an error

db_size: the maximum size in bytes of the database.

Safety

The file referenced by path must not be concurrently modified by any other process

Opens an existing redb database.

Safety

The file referenced by path must not be concurrently modified by any other process

Convenience method for DatabaseBuilder::new

Begins a write transaction

Returns a WriteTransaction which may be used to read/write to the database. Only a single write may be in progress at a time

Begins a read transaction

Captures a snapshot of the database, so that only data committed before calling this method is visible in the transaction

Returns a ReadTransaction which may be used to read from the database. Read transactions may exist concurrently with writes

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.