Expand description
§Pincho Rust Client Library
Official Rust Client Library for Pincho - Send push notifications to your mobile devices.
§Features
- Async/await support - Built on tokio for high-performance async operations
- Type-safe builder pattern - Compile-time guarantees for notification construction
- Connection pooling - Automatic HTTP connection reuse via reqwest
- Comprehensive error handling - Detailed error types with thiserror
- Zero-copy where possible - Efficient memory usage
- Thread-safe - All types are Send + Sync
§Quick Start
use pincho::Client;
#[tokio::main]
async fn main() -> Result<(), pincho::Error> {
let client = Client::new("abc12345")?;
// Send a simple notification
let response = client.send("Build Complete", "v1.2.3 deployed successfully").await?;
if response.is_success() {
println!("Notification sent successfully!");
}
Ok(())
}§Advanced Usage
use pincho::{Client, Notification};
#[tokio::main]
async fn main() -> Result<(), pincho::Error> {
let client = Client::new("abc12345")?;
// Build a notification with all options
let notification = Notification::builder()
.title("Deploy Complete")
.message("Version 1.2.3 deployed to production")
.notification_type("deployment")
.tags(vec!["production".to_string(), "release".to_string()])
.image_url("https://example.com/success.png")
.action_url("https://example.com/deployment/123")
.build()?;
let response = client.send_notification(notification).await?;
println!("Status: {}", response.status);
Ok(())
}§Error Handling
use pincho::{Client, Error};
#[tokio::main]
async fn main() {
let client = Client::new("abc12345").unwrap();
match client.send("Test", "Message").await {
Ok(response) => println!("Success: {}", response.message),
Err(Error::Authentication { message, status_code }) => {
eprintln!("Auth error ({}): {}", status_code, message);
}
Err(Error::Validation { message, status_code }) => {
eprintln!("Validation error ({}): {}", status_code, message);
}
Err(Error::RateLimit { message, status_code }) => {
eprintln!("Rate limit ({}): {}", status_code, message);
}
Err(e) => eprintln!("Error: {}", e),
}
}§Requirements
- Rust 2021 edition or later
- Tokio runtime for async operations
§Links
Structs§
- Client
- Pincho API client
- Error
Detail - Nested error details from the Pincho API
- Error
Response - Error response from the Pincho API (nested format)
- NotifAI
Notification - AI-generated notification details
- NotifAI
Response - Response from NotifAI endpoint
- Notification
- A notification to be sent via Pincho
- Notification
Builder - Builder for creating a Notification
- Notification
Response - Response from the Pincho API
- Rate
Limit Info - Rate limit information from response headers
Enums§
- Error
- Main error type for the Pincho Client Library
Functions§
- encrypt_
text - Encrypts text using AES-128-CBC with custom Base64 encoding
Type Aliases§
- Result
- Result type for Pincho operations