Driver Implementer
This skill guides the implementation of a new DataEngine driver in QoreDB.
Workflow
1. Driver Scaffold (Rust)
- •
Create Driver File: Create a new file in
src-tauri/src/engine/drivers/<driver_name>.rsusing theassets/driver_template.rs.- •Rename struct
NewDriverto<DriverName>Driver. - •Update
driver_id()to return the snake_case ID (e.g., "sqlite"). - •Update
driver_name()to return the Display Name (e.g., "SQLite").
- •Rename struct
- •
Declare Module: In
src-tauri/src/engine/drivers/mod.rs:- •Add
pub mod <driver_name>;
- •Add
- •
Register Driver: In
src-tauri/src/lib.rs(AppState::new):- •Import the new module:
use engine::drivers::<driver_name>::<DriverName>Driver; - •Register it:
registry.register(Arc::new(<DriverName>Driver::new()));
- •Import the new module:
2. Dependency Management
- •Add Crate:
- •Ask the user to add the Rust crate:
cargo add <crate_name> --package qoredb(usually insrc-tauri). - •Note: Ensure
tokiosupport is enabled for the crate if available, as QoreDB is async.
- •Ask the user to add the Rust crate:
3. Implementation Guide
Implement the DataEngine trait methods in this order:
- •Connection:
test_connectionandconnect. (You'll need a way to mapSessionId->Connectionusing aRwLock<HashMap>). - •Metadata:
list_namespacesandlist_collections. - •Query Execution:
execute(Parsing results intoQueryResult). - •Schema:
describe_table(Mapping types to QoreDB types).
Template
Driver Implementation (src-tauri/src/engine/drivers/<name>.rs)
Use the asset assets/driver_template.rs as a base.
rust
// Key imports
use crate::engine::traits::DataEngine;
use crate::engine::types::{...};
Checklist
- •
Cargo.toml: Added driver dependency (e.g.rusqlite,redis) - •
drivers/<name>.rs: Created struct implementingDataEngine - •
drivers/mod.rs: Module declared - •
lib.rs: Driver registered inDriverRegistry - •
test_connection: Implemented and verified