db-http-core
Shared core library for the db-http workspace — provides the DatabaseBackend trait, query/transaction builders, error types, and HTTP abstraction.
Install
Quick Start
Implement DatabaseBackend for your own database:
use ;
;
Build queries and transactions with the provided builders:
use ;
let users: = new
.bind
.fetch_all
.await?;
let results = new
.query
.bind
.query
.bind
.execute
.await?;
API Reference
| Item | Kind | Description |
|---|---|---|
DatabaseBackend |
trait | Implement to add a new database backend |
QueryBuilder |
struct | Fluent builder for single queries |
TransactionBuilder |
struct | Fluent builder for multi-query transactions |
Query |
struct | A prepared query with SQL + parameters |
Transaction |
struct | A set of queries to execute atomically |
QueryResult |
struct | Rows + columns returned by a query |
Column |
struct | Column name and type metadata |
Error |
enum | Error type used across all crates |
HttpRequest |
struct | Minimal HTTP request abstraction |
http_post |
fn | Send an HTTP POST (uses reqwest or WASI) |
deserialize_one |
fn | Deserialize a single row from a QueryResult |
deserialize_all |
fn | Deserialize all rows from a QueryResult |
WASM/WASI Support
db-http-core compiles for both native (reqwest + tokio) and WASI (wstd) targets. The http_post function automatically uses the correct HTTP client based on the compilation target.
Contributing
- Fork and clone the repository
- Make your changes
- Run
cargo fmtandcargo clippy - Run tests:
cargo test - Open a pull request
License
MIT — see LICENSE.