Rust SDK
emitwave — a server-side crate that HMAC-signs and publishes events to the gateway.
Server SDK· 3 min read
Install
bash
cargo add emitwave
Requires an application ID and an active server credential (public key + one-time secret). Keep the secret on the server — never in client code, public env vars, logs, or API responses. The blocking HTTP client is behind the default client feature; disable default features to use just the signing core.
The
key and secret are a server credential, not the browser public application key. For every request the SDK hashes the exact JSON body and signs the method, path, canonical query, and body hash with HMAC-SHA256.Publish an event
trigger(channel, event, data) serializes the event, signs the body, and sends it to /apps/{app_id}/events. An empty gateway_url defaults to the live gateway (emitwave::DEFAULT_GATEWAY_URL).
publish.rs
use emitwave::{Client, Config}; use serde_json::json; let client = Client::new(Config { gateway_url: String::new(), // empty -> https://api.emitwave.com app_id: "app_...".into(), key: "ew_pk_live_...".into(), // server credential public key secret: "ew_sk_live_...".into(), // server credential secret })?; client.trigger("orders", "order.created", json!({ "id": "ord_123", "total": 4900 }))?;
Error handling
Error::Gateway { status, body } represents a non-2xx gateway response; the body never includes your secret.
errors.rs
match client.trigger("orders", "order.created", json!({ "id": "ord_123" })) { Ok(()) => {} Err(emitwave::Error::Gateway { status, body }) => { eprintln!("Emitwave rejected the event {status}: {body}"); } Err(e) => eprintln!("transport or config error: {e}"), }
This SDK publishes the provided JSON as-is. It does not build the ciphertext envelope for a private-encrypted channel — see Encryption.