LoopEngine Rust SDK
Rust client for the LoopEngine Ingest API. Create a client with your credentials, then call send with your payload.
Requirements: Rust 1.75+ (async/await, impl Trait)
Installation
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
= "1"
Usage
use Client;
async
Client::new(key, secret, project_id)— Builds a client. Use your project key, secret, and project ID from the LoopEngine dashboard. Returns an error if any credential is empty.client.send(payload).await— Sends the payload to the Ingest API atapi.loopengine.dev.project_idis added automatically. The payload must match the fields and constraints configured for your project in the LoopEngine dashboard (e.g. required fields, allowed keys, value types). You can pass any value that implementsserde::Serializeand serializes to a JSON object (aserde_json::json!map, a struct with#[derive(Serialize)], etc.). Useclient.send_with_geo(payload, lat, lon).awaitto send device coordinates (see Geolocation below).
The client is safe for concurrent use — it wraps a reqwest::Client which maintains an internal connection pool.
Geolocation
You can send device location so feedback is associated with coordinates instead of IP-based geo. Use send_with_geo and pass Some(lat) and Some(lon). When both are provided, the SDK adds geo_lat and geo_lon to the request body; they are included in the HMAC signature. Pass None for both to use IP-based geolocation (or use send(payload)). Valid ranges: latitude -90 to 90, longitude -180 to 180.
// Without geo (IP-based location is used)
client.send.await?;
// With device coordinates
client
.send_with_geo
.await?;
Custom HTTP client
Use Client::builder to pass a custom reqwest::Client (e.g. to set timeouts or a custom connector):
use Duration;
let http = builder
.timeout
.build
.unwrap;
let client = builder
.with_http_client
.build
.unwrap;
Error handling
All errors are represented by loopengine::Error:
| Variant | When |
|---|---|
MissingCredentials |
A credential is empty after trimming |
Serialize |
Payload could not be serialized to JSON |
Http |
Network / transport error |
ApiError { status, body } |
Server returned a non-2xx response |
Request signing
Every request is signed with HMAC-SHA256 over the canonical string "METHOD\nPATH\nTIMESTAMP\nSHA256(body)". The signature is base64url-encoded (no padding) and sent as the X-Signature: v1=<sig> header alongside X-Project-Key and X-Timestamp. All signing logic is handled transparently by the SDK.
License
MIT