1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use crate::;
use rust_librocksdb_sys as ffi;
/// Trait for accessing raw pointers to underlying RocksDB objects.
///
/// This trait is only available when the `raw-ptr` feature is enabled.
/// It provides access to the underlying C API pointers for advanced use cases.
///
/// # Examples
///
/// ```rust,ignore
/// use rust_rocksdb::{DB, Options, AsRawPtr};
///
/// let db = DB::open_default("path")?;
/// let raw_db_ptr = unsafe { db.as_raw_ptr() }; // *mut rocksdb_t
///
/// let opts = Options::default();
/// let raw_opts_ptr = unsafe { opts.as_raw_ptr() }; // *mut rocksdb_options_t
///
/// // You can now use these pointers with the C API directly
/// // unsafe { rocksdb_some_c_function(raw_db_ptr, raw_opts_ptr); }
/// ```
///
/// # Safety
///
/// The returned pointers are only valid as long as the Rust objects are alive.
/// You must ensure proper lifetime management and avoid using the pointers
/// after the objects have been dropped.