pub trait AsRawPtr<T> {
// Required method
unsafe fn as_raw_ptr(&self) -> *mut T;
}Available on crate feature
raw-ptr only.Expand description
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
ⓘ
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.
Required Methods§
Sourceunsafe fn as_raw_ptr(&self) -> *mut T
unsafe fn as_raw_ptr(&self) -> *mut T
Returns a raw pointer to the underlying RocksDB object.
§Safety
The returned pointer is only valid as long as the object implementing this trait is alive. The caller must ensure proper lifetime management and avoid using the pointer after the object has been dropped.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".