octra_sqlite/lib.rs
1//! Real SQLite inside an Octra Circle.
2//!
3//! `octra-sqlite` provides a small Rust client for querying and writing to a
4//! SQLite database whose engine runs inside an Octra `wasm_v1` Circle. The
5//! crate keeps the first story deliberately small: create a [`Client`], open a
6//! [`Database`], then run SQL.
7//!
8//! ```no_run
9//! use octra_sqlite::{Client, Result};
10//!
11//! fn main() -> Result<()> {
12//! let client = Client::from_default_config()?;
13//! let db = client.database("art")?;
14//! let rows = db.query("select * from artist order by name;")?;
15//! println!("{} rows", rows.row_count);
16//! Ok(())
17//! }
18//! ```
19//!
20//! A public-read database can be queried without local wallet setup:
21//!
22//! ```no_run
23//! use octra_sqlite::{Client, Result};
24//!
25//! fn main() -> Result<()> {
26//! let client = Client::default();
27//! let db = client.database(
28//! "oct://devnet/octQfYK2fE9RvR9kfj8FJfMBQw1e4EzfHB8Q5Z9J2DCnRBQ",
29//! )?;
30//! let rows = db.query("select id, name from artist order by id;")?;
31//! println!("{} rows", rows.row_count);
32//! Ok(())
33//! }
34//! ```
35//!
36//! Sealed databases use signed Octra view auth for reads. Public-read
37//! databases use unsigned Octra Circle views for SQL reads while keeping writes
38//! owner-signed through OSW1 owner write intent. Pass a saved database name or a
39//! full `oct://NETWORK/<circle>` URI to [`Client::database`]. The client
40//! detects the Circle's Octra read surface unless `read_mode` is explicitly set.
41//!
42//! Feature flags:
43//!
44//! - `cli`: build the `octra-sqlite` command line interface.
45//! - `http`: include the default blocking HTTP RPC transport.
46//! - `wasm-behavior`: enable host-harness tests for the bundled Circle WASM.
47//!
48//! The CLI JSON envelopes and OSR1/OSW1 wire formats are treated as public
49//! surfaces. The Rust API is still `0.x`; breaking Rust API cleanup happens in
50//! minor versions.
51
52pub mod client;
53pub mod protocol;
54
55pub use client::{
56 AuthInfo, Client, ClientOptions, Database, Error, ErrorKind, ExecuteResult, ProgramInfo,
57 QueryResult, Result, SubmittedTransaction,
58};
59pub use protocol::target::ReadMode;
60pub use serde_json::Value;
61
62#[cfg(feature = "cli")]
63#[path = "cli/mod.rs"]
64pub mod cli;