leash-sdk (Rust)
Rust SDK for the Leash platform — one unified async client for authentication, runtime env vars, and integrations.
Framework-agnostic. Works with axum, actix-web, plain http::Request, and anything else you can extract cookies + headers from.
Installation
[]
= "0.4"
= { = "1", = ["macros", "rt-multi-thread"] }
# Optional framework integrations — pick what you use.
# leash-sdk = { version = "0.4", features = ["axum"] }
# leash-sdk = { version = "0.4", features = ["actix-web"] }
Quick Start
use ;
async
Request-bound construction
The canonical entry point: Leash::new(req) reads LEASH_API_KEY from env, plus the inbound request's leash-auth cookie and Authorization: Bearer header.
axum
use ;
use Leash;
async
let _app = new.route;
actix-web
use ;
use Leash;
async
Plain http::Request
use Leash;
let req = builder
.header
.body.unwrap;
let leash = new.unwrap;
Auth precedence
LEASH_API_KEYenv var (orLeash::with_api_key(...)).Authorization: Bearer <jwt>on the inbound request — used for identity and, only when no API key is configured, as a fallback bearer on env-fetch endpoints. Never forwarded on integration POSTs (the platform'sverifyToken()rejects user JWTs before the API-key check runs).leash-authcookie — forwarded to the platform on integration calls.
Integration verbs
| Provider | Verbs |
|---|---|
gmail() |
list_messages, get_message, send_message, search_messages, list_labels, get_profile |
calendar() (alias google_calendar()) |
list_calendars, list_events, create_event, get_event |
drive() (alias google_drive()) |
list_files, get_file, download_file, create_folder, upload_file, delete_file, search_files |
linear() |
list_issues, get_issue, create_issue, update_issue, add_comment, list_teams, list_projects |
provider(name) |
call(action, body) — generic escape hatch for Slack, GitHub, HubSpot, … |
use ;
# async
Errors
LeashError is a structured enum. Predicates cover the common branches:
#
env().get(key) returns Result<Option<String>> — Ok(None) for KEY_NOT_DECLARED, Err(_) for actual errors so you can branch with if value.is_none().
TLS
reqwest is configured with rustls-tls only — no OpenSSL transitively.
What's NOT in 0.4 yet
- Dev-auth cookie-exchange handler (
Leash::createDevAuthHandlerin TS) — the local-dev/api/leash/dev-authflow is TS-only for 0.4. Rust callers using local dev should rely on the cookie pre-set byleash upinstead. - Browser-mode client — there's no WASM/browser build. Construct from a server route.
- MCP exec helpers (
run_mcp, custom MCP config) — out of scope for the unified 0.4 client. Use the genericprovider(name).call(...)escape hatch if you need to reach an MCP-backed integration directly. - Connection status / connect URL helpers (
is_connected,get_connect_url,get_connections) — surface to be re-added in a follow-up once the platform's/api/integrations/connectionsshape stabilises.
If you depended on any of these in 0.3.x, pin to leash-sdk = "0.3" and migrate when the replacement lands.
Compatibility
| SDK | Wire-compatible with platform |
|---|---|
| 0.4.x | leash.build (current) |
| 0.3.x | leash.build (legacy LeashIntegrations surface) |
License
Apache-2.0.