Expand description
Thread-safe wrapper for OverDriveDB
OverDriveDB is not Send + Sync by design. Use SharedDB when you need
to share a single database across multiple threads (e.g., a web server).
§Quick Example
use overdrive::shared::SharedDB;
use std::thread;
let db = SharedDB::open("app.odb").unwrap();
let db2 = db.clone(); // cheaply cloned — same underlying Mutex
let handle = thread::spawn(move || {
db2.with(|d| {
d.query("SELECT * FROM users").unwrap()
}).unwrap()
});
let result = handle.join().unwrap();
println!("{:?}", result.rows);Structs§
- SharedDB
- A thread-safe, cheaply-cloneable handle to an
OverDriveDB.