Rust Alerts SDK
The API Alerts Rust SDK sends alerts from your Rust code through API Alerts. Drop it into Actix Web servers, Tokio applications, CLI tools, systems software, or any Rust binary that needs to notify you when something important happens. Minimal setup, fire-and-forget by default with optional response handling, and zero infrastructure.
Installation
Add to your Cargo.toml:
[dependencies]
apialerts = "1.1.0"
tokio = { version = "1", features = ["full"] }
serde_json = "1"
Usage
The Rust SDK is instance-based: construct ApiAlertsClient directly and manage its lifetime yourself. This is more idiomatic for Rust than a global singleton.
use apialerts::{ApiAlertsClient, Event};
#[tokio::main]
async fn main() {
let client = ApiAlertsClient::new("YOUR-API-KEY");
// Simple notification
client.send(Event::new("Deployment successful")).await;
// With all options
client.send(
Event::new("New user signed up")
.channel("developers")
.event("user.signup")
.title("New Signup")
.tags(vec!["signup", "organic"])
.link("https://dashboard.example.com/users/123")
.data(serde_json::json!({ "plan": "pro" })),
).await;
}
send is fire-and-forget and never panics. Use send_async when you want the result back (inside an async context):
match client.send_async(Event::new("Deployment successful")).await {
Ok(result) => println!("Sent to {} ({})", result.workspace, result.channel),
Err(e) => eprintln!("Error: {}", e),
}