Skip to content

Commit 02fe89b

Browse files
authored
Add DbClosedError (#88)
* Add DbClosedError * Fix test * Clean up clippy lint for iter()
1 parent 1f73049 commit 02fe89b

File tree

4 files changed

+328
-388
lines changed

4 files changed

+328
-388
lines changed

src/exceptions.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use pyo3::create_exception;
2+
use pyo3::exceptions::PyException;
3+
4+
create_exception!(
5+
rocksdict,
6+
DbClosedError,
7+
PyException,
8+
"Raised when accessing a closed database instance."
9+
);

src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// #![feature(core_intrinsics)]
22
mod encoder;
3+
mod exceptions;
34
mod iter;
45
mod options;
56
mod rdict;
@@ -8,6 +9,7 @@ mod sst_file_writer;
89
mod util;
910
mod write_batch;
1011

12+
use crate::exceptions::*;
1113
use crate::iter::*;
1214
use crate::options::*;
1315
use crate::rdict::*;
@@ -104,7 +106,7 @@ use pyo3::prelude::*;
104106
/// supports `pickle`.
105107
///
106108
#[pymodule]
107-
fn rocksdict(_py: Python, m: &PyModule) -> PyResult<()> {
109+
fn rocksdict(py: Python, m: &PyModule) -> PyResult<()> {
108110
m.add_class::<Rdict>()?;
109111
m.add_class::<OptionsPy>()?;
110112
m.add_class::<MemtableFactoryPy>()?;
@@ -140,6 +142,9 @@ fn rocksdict(_py: Python, m: &PyModule) -> PyResult<()> {
140142
m.add_class::<BottommostLevelCompactionPy>()?;
141143
m.add_class::<ChecksumTypePy>()?;
142144
m.add_class::<KeyEncodingTypePy>()?;
145+
146+
m.add("DbClosedError", py.get_type::<DbClosedError>())?;
147+
143148
pyo3_log::init();
144149
Ok(())
145150
}

0 commit comments

Comments
 (0)