Installation
Install the dexcost Rust SDK with cargo add, including optional Cargo features and a verification snippet.
cargo add dexcostOr add the dependency directly to your Cargo.toml:
[dependencies]
dexcost = "0.1"
tokio = { version = "1", features = ["full"] }tokio with the full feature set is required because the SDK is async and built on the Tokio runtime.
Optional extras
The SDK ships several optional Cargo features. Each is disabled by default — enable only the ones you need to keep your build lean.
| Feature | What it enables | How to enable |
|---|---|---|
reqwest-middleware | Integrates with the reqwest-middleware crate so that HTTP requests made through a reqwest middleware stack are tracked automatically | dexcost = { version = "0.1", features = ["reqwest-middleware"] } |
axum-middleware | Provides dexcost::middleware::axum::dexcost_middleware, a Tower-compatible layer for Axum routers that records per-request HTTP costs | dexcost = { version = "0.1", features = ["axum-middleware"] } |
tower-middleware | Enables Tower and tower-http integration for middleware stacks that are not Axum-specific | dexcost = { version = "0.1", features = ["tower-middleware"] } |
actix-middleware | Provides middleware for Actix Web 4 services | dexcost = { version = "0.1", features = ["actix-middleware"] } |
streaming | Enables streaming response support via async-stream | dexcost = { version = "0.1", features = ["streaming"] } |
tracing-bridge | Bridges dexcost events into the tracing ecosystem, emitting structured spans and events that any tracing-subscriber can consume | dexcost = { version = "0.1", features = ["tracing-bridge"] } |
To enable multiple features at once, list them in the features array:
[dependencies]
dexcost = { version = "0.1", features = ["axum-middleware", "streaming"] }Requirements
Async Rust with the Tokio runtime. Rust edition 2021 (Rust 1.75+ for stable async trait support). The SQLite event buffer is bundled via rusqlite with the bundled feature — no separate SQLite installation is required.
Verify your install
After running cargo add dexcost, confirm the crate resolves and the SDK version constant is accessible:
fn main() {
println!("{}", dexcost::VERSION);
}This prints the installed SDK version (for example, 0.1.0). If the build fails, run cargo check and verify that dexcost appears in your Cargo.lock.