use libc::c_uint; use std::ffi::CString; use std::ptr;
use ffi;
use error::{
lmdb_result,
Result,
};
/// A handle to an individual database in an environment. /// /// A database handle denotes the name and parameters of a database in an environment. #[derive(Clone, Copy, Debug, Eq, PartialEq)] pubstruct Database {
dbi: ffi::MDB_dbi,
}
impl Database { /// Opens a new database handle in the given transaction. /// /// Prefer using `Environment::open_db`, `Environment::create_db`, `TransactionExt::open_db`, /// or `RwTransaction::create_db`. pub(crate) unsafefn new(txn: *mut ffi::MDB_txn, name: Option<&str>, flags: c_uint) -> Result<Database> { let c_name = name.map(|n| CString::new(n).unwrap()); let name_ptr = iflet Some(ref c_name) = c_name {
c_name.as_ptr()
} else {
ptr::null()
}; letmut dbi: ffi::MDB_dbi = 0;
lmdb_result(ffi::mdb_dbi_open(txn, name_ptr, flags, &mut dbi))?;
Ok(Database {
dbi,
})
}
/// Returns the underlying LMDB database handle. /// /// The caller **must** ensure that the handle is not used after the lifetime of the /// environment, or after the database has been closed. #[allow(clippy::trivially_copy_pass_by_ref)] pubfn dbi(&self) -> ffi::MDB_dbi { self.dbi
}
}
unsafeimpl Sync for Database {} unsafeimpl Send for Database {}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.