Feature flags¶
oneiriq-surql is a large crate with several orthogonal subsystems. Every optional dependency lives behind a feature flag so library-only consumers (e.g. schema / migration tooling that renders SurrealQL but never opens a socket) do not pull in tokio, surrealdb, redis, or any binary-only dependencies.
Summary¶
| Feature | Default | Implies | Pulls in | What you get |
|---|---|---|---|---|
client-rustls | yes | - | tokio, surrealdb 3.x (rustls), reqwest (rustls-tls-webpki-roots), futures | Same surface as client but with pure-Rust TLS (no openssl-sys). The default backend since 0.2.3. See Picking a TLS backend. |
client | no | - | tokio, surrealdb 3.x (native-tls), reqwest (default-tls), futures | DatabaseClient, async CRUD, executor, graph helpers, transaction buffer. Uses the system native-tls stack (openssl-sys on Linux). |
client-wasm | no | - | tokio (wasm subset), surrealdb 3.x (protocol-ws, kv-mem), futures | Wasm-friendly variant. Same DatabaseClient API, no TLS / reqwest / rt-multi-thread. See WebAssembly support. |
cli | no | client, orchestration, settings | clap, tracing-subscriber, comfy-table, colored | The surql binary (migrate, schema, db, orchestrate). |
cache | no | - | tokio, async-trait | MemoryCache backend, CacheManager, global cache registry. |
cache-redis | no | cache | redis | RedisCache backend for the cache manager. |
settings | no | - | dotenvy, toml | Layered Settings / SettingsBuilder (env, .env, Cargo.toml metadata). |
orchestration | no | client | async-trait | Multi-database deployment strategies, environment registry, health checks. |
watcher | no | - | notify, tokio, tokio-util | Filesystem watcher for schema / migration hot-reload. |
Picking a profile¶
Library-only (render SurrealQL, no network)¶
Gives you the schema DSL, migration renderer, query builder, and typed result helpers. Everything under types::, schema::, query::* (except executor, crud, typed, graph), migration::models / diff / generator / versioning / discovery, and the parser remains available.
Default async client (rustls TLS)¶
Equivalent to features = ["client-rustls"]. Brings in tokio, surrealdb, and the full async surface (DatabaseClient, executor::fetch_all, crud::*, graph::*, batch::*_many, Transaction). TLS is handled by rustls + webpki-roots, so no openssl-sys is linked, no libssl-dev is needed at build time, and the dependency graph is portable across glibc / musl / cross-compile targets.
Async client with native-tls¶
Same API surface as client-rustls, but TLS is delegated to the system native-tls stack (links openssl-sys on Linux, Security.framework on macOS). Use this when you must validate against the OS trust store or interop with a TLS extension that is only implemented by OpenSSL.
Picking a TLS backend¶
Pick exactly one of client or client-rustls:
client | client-rustls | |
|---|---|---|
| TLS stack | native-tls (+ openssl-sys on Linux) | rustls + webpki-roots |
Needs libssl-dev at build | yes (on Linux) | no |
| Uses OS trust store | yes | no -- ships Mozilla webpki roots |
| Cross-compilation friendliness | depends on target OpenSSL | portable, pure Rust |
| API surface | identical | identical |
| Backwards compatible | yes (default 0.1.x, 0.2.0 to 0.2.2) | new in 0.2.2, default since 0.2.3 |
Enabling both at once compiles, but doubles the TLS dependency set. If you are consuming this crate from multiple workspace members, pick one variant and hold it consistent via a workspace-level feature flag.
CLI / service binary¶
Implies client, orchestration, and settings. Adds the surql binary. See CLI reference.
Cache layer¶
[dependencies]
oneiriq-surql = { version = "0.2", features = ["cache"] }
# or with Redis:
oneiriq-surql = { version = "0.2", features = ["cache-redis"] }
cache enables MemoryCache + CacheManager. cache-redis additionally enables the redis backend (implies cache).
Orchestration (standalone)¶
Pulls in the async client (orchestration requires live connections) plus the EnvironmentRegistry, MigrationCoordinator, and the four deployment strategies (sequential, parallel, rolling, canary).
Settings¶
Enables the layered Settings loader (env vars, .env, Cargo.toml [package.metadata.surql]). Pure dependency - does not require a client.
Schema watcher¶
Filesystem watcher for schema / migration files - useful for cargo watch-style development loops.
WebAssembly support¶
[dependencies]
oneiriq-surql = { version = "0.2", default-features = false, features = ["client-wasm"] }
Tracks Oneiriq/surql-rs#115. Enables the same DatabaseClient / executor::* / crud::* / graph::* / batch::*_many API as client-rustls, but compiles cleanly to wasm32-unknown-unknown:
surrealdbis pulled withprotocol-ws+kv-memonly. Browsers terminate TLS at the WebSocket layer, so neitherrustls(which pullsring's C glue) nornative-tlsis enabled.kv-memlets wasm callers run an embedded engine for local state and tests with no server roundtrip.reqwestis not pulled. It is unused insurql's source path andreqwest's default TLS stacks do not link on wasm.tokiois reduced to["sync", "macros", "rt", "time"].tokio::spawnis not available; if you need to fan out, usewasm-bindgen-futures::spawn_localfrom the caller crate.
Build prerequisites¶
surrealdb-core 3.x pulls ring 0.17 with its wasm32_unknown_unknown_js feature, but ring's build script still invokes the system C compiler with --target=wasm32-unknown-unknown. On macOS, Apple's /usr/bin/clang does not include a wasm32 backend; install Homebrew LLVM and point cc-rs at it:
brew install llvm
export CC_wasm32_unknown_unknown="$(brew --prefix llvm)/bin/clang"
export AR_wasm32_unknown_unknown="$(brew --prefix llvm)/bin/llvm-ar"
Modern Linux distributions (Ubuntu 22.04+ clang-15, Fedora clang) ship with the wasm32 backend built in -- no override needed.
The crate ships .cargo/config.toml with the --cfg=getrandom_backend="wasm_js" rustflag (required by getrandom 0.3 on wasm; the feature flag alone is insufficient -- see https://docs.rs/getrandom/0.3/#webassembly-support) and a scripts/check-wasm.sh wrapper that auto-detects Homebrew LLVM and runs the canonical:
cargo build \
--target wasm32-unknown-unknown \
--no-default-features \
--features client-wasm \
-p oneiriq-surql
This is the gate downstream consumers (pixel-stroke-persistence, etc.) should mirror in their own CI.
Build-time guarantees¶
#![deny(missing_docs)]is enforced on every feature combination.#![forbid(unsafe_code)]at the crate root.cargo doc --no-deps --all-featuressucceeds with-D warnings.cargo clippy --all-targets --all-features -- -D warningsis part of CI and the pre-push hook (seeCONTRIBUTING.md).
What's next¶
- Installation - crate + binary install recipes.
- CLI reference - subcommand tree.
- Query UX helpers -
type_record,extract_many,aggregate_records,Query::execute.