Skip to main content

bunnydb_http/
lib.rs

1//! Async HTTP client for Bunny.net Database SQL pipeline API.
2//!
3//! This crate wraps the `/v2/pipeline` endpoint with ergonomic methods:
4//!
5//! - [`BunnyDbClient::query`]
6//! - [`BunnyDbClient::execute`]
7//! - [`BunnyDbClient::batch`]
8//!
9//! # Quick Start
10//!
11//! ```no_run
12//! use bunnydb_http::{BunnyDbClient, Params, Value};
13//!
14//! # #[tokio::main]
15//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
16//! let pipeline_url = std::env::var("BUNNYDB_PIPELINE_URL")?;
17//! let token = std::env::var("BUNNYDB_TOKEN")?;
18//! let db = BunnyDbClient::new_bearer(pipeline_url, token);
19//!
20//! db.execute(
21//!     "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT NOT NULL)",
22//!     (),
23//! ).await?;
24//!
25//! let result = db.query(
26//!     "SELECT id, name FROM users WHERE name = :name",
27//!     Params::named([("name", Value::text("Kit"))]),
28//! ).await?;
29//!
30//! println!("rows={}", result.rows.len());
31//! # Ok(())
32//! # }
33//! ```
34
35mod client;
36mod decode;
37mod error;
38mod options;
39mod params;
40mod types;
41mod value;
42mod wire;
43
44#[cfg(feature = "baton-experimental")]
45pub mod baton;
46#[cfg(feature = "raw-mode")]
47pub mod raw;
48#[cfg(feature = "row-map")]
49pub mod row_map;
50
51pub use client::BunnyDbClient;
52pub use error::BunnyDbError;
53pub use options::ClientOptions;
54pub use params::{Params, Statement};
55pub use types::{Col, ExecResult, QueryResult, StatementOutcome};
56pub use value::Value;
57
58/// Crate-wide result type.
59pub type Result<T> = std::result::Result<T, BunnyDbError>;