Skip to content

Commit

Permalink
Export newtypes for DB open parameters and add docs for them
Browse files Browse the repository at this point in the history
  • Loading branch information
torrancew committed Aug 2, 2024
1 parent 53d45b9 commit 8d0a115
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@ impl From<WritableDatabase> for Database {
#[repr(i32)]
#[derive(Default)]
pub enum DbAction {
/// Open the database if it exists, create it otherwise
#[default]
CreateOrOpen = 0x00,
/// Overwrite the database if it exists, create it otherwise
CreateOrOverwrite = 0x01,
/// Create a new database
Create = 0x02,
/// Open an existing database
Open = 0x03,
}

Expand All @@ -79,10 +83,15 @@ impl From<DbAction> for autocxx::c_int {
#[derive(Default)]
pub enum DbBackend {
#[default]
/// Automatically select a backend
Auto = 0x000,
/// Use the Glass backend
Glass = 0x100,
/// Use the Chert backend
Chert = 0x200,
/// Use the stub backend
Stub = 0x300,
/// Use an in-memory database
InMemory = 0x400,
}

Expand All @@ -93,11 +102,17 @@ impl From<DbBackend> for autocxx::c_int {
}

bitflags! {
/// Various flags to modify writable database behavior
pub struct DbFlags: u32 {
/// Don't attempt to ensure changes have hit the disk
const NO_SYNC = 0x04;
/// Try to ensure changes have hit the disk
const FULL_SYNC = 0x08;
/// Update the database in-place
const DANGEROUS = 0x10;
/// Do not create a termlist table when creating the database
const NO_TERMLIST = 0x20;
/// If the database is already locked, retry it
const RETRY_LOCK = 0x40;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod db;
use std::num::NonZeroU32;

use bytes::Bytes;
pub use db::{Database, WritableDatabase};
pub use db::{Database, DbAction, DbBackend, DbFlags, WritableDatabase};

mod doc;
pub use doc::Document;
Expand Down

0 comments on commit 8d0a115

Please sign in to comment.