Skip to content

Commit

Permalink
Add DbClosedError (#88)
Browse files Browse the repository at this point in the history
* Add DbClosedError

* Fix test

* Clean up clippy lint for iter()
  • Loading branch information
GodTamIt authored Nov 3, 2023
1 parent 1f73049 commit 02fe89b
Show file tree
Hide file tree
Showing 4 changed files with 328 additions and 388 deletions.
9 changes: 9 additions & 0 deletions src/exceptions.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use pyo3::create_exception;
use pyo3::exceptions::PyException;

create_exception!(
rocksdict,
DbClosedError,
PyException,
"Raised when accessing a closed database instance."
);
7 changes: 6 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// #![feature(core_intrinsics)]
mod encoder;
mod exceptions;
mod iter;
mod options;
mod rdict;
Expand All @@ -8,6 +9,7 @@ mod sst_file_writer;
mod util;
mod write_batch;

use crate::exceptions::*;
use crate::iter::*;
use crate::options::*;
use crate::rdict::*;
Expand Down Expand Up @@ -104,7 +106,7 @@ use pyo3::prelude::*;
/// supports `pickle`.
///
#[pymodule]
fn rocksdict(_py: Python, m: &PyModule) -> PyResult<()> {
fn rocksdict(py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<Rdict>()?;
m.add_class::<OptionsPy>()?;
m.add_class::<MemtableFactoryPy>()?;
Expand Down Expand Up @@ -140,6 +142,9 @@ fn rocksdict(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<BottommostLevelCompactionPy>()?;
m.add_class::<ChecksumTypePy>()?;
m.add_class::<KeyEncodingTypePy>()?;

m.add("DbClosedError", py.get_type::<DbClosedError>())?;

pyo3_log::init();
Ok(())
}
Loading

0 comments on commit 02fe89b

Please sign in to comment.