PushizoDocs
SDK guides

Rust SDK

The pushizo crate on crates.io — Rust 1.71+, ureq; models and services generated from OpenAPI, retries, idempotency, pagination, webhook signature verification.

Source: sdk/rust, public repository pushizo-rust. The models (pushizo::models) and resource services (pushizo::resources) are generated from api/openapi.yaml and cover the same endpoints as the other server SDKs; authentication, retries, idempotency, pagination, multipart, and webhook signature verification are hand-written.

Installation

cargo add pushizo

Usage

use std::collections::HashMap;

use pushizo::models::{CreateNotificationDto, CreateNotificationDtoTarget};
use pushizo::{Client, RequestOptions};

fn main() -> pushizo::Result<()> {
    let client = Client::builder(std::env::var("PUSHIZO_API_KEY").unwrap_or_default())
        .app_id("app_…")
        .build()?;

    let mut target = CreateNotificationDtoTarget::default();
    target.include_aliases = Some(HashMap::from([("external_id".into(), vec!["user-42".into()])]));
    let body = CreateNotificationDto {
        target,
        contents: Some(HashMap::from([("en".into(), "Your order shipped".into())])),
        ..Default::default()
    };
    let res = client
        .notifications()
        .with_options(RequestOptions::new().idempotency_key("order-1001"))
        .create(&body)?;
    println!("{} {}", res.id, res.status);

    // Cursor pagination: all pages as a single iterator
    for segment in client.segments().list_all(None) {
        println!("{}", segment?.name);
    }
    Ok(())
}

Behavior

  • App scope: ClientBuilder::app_id is the default; per service, use with_options(RequestOptions::new().app_id(…)).
  • Retries: 429 on every method; 5xx and network errors on GET/PUT/DELETE, and on POST/PATCH only when an Idempotency-Key is set. Retry-After is honored.
  • Errors: pushizo::Error (status, code, message, request_id) and kind() (NotFound, RateLimited …). The API key is never written to error messages or Debug output.
  • Webhooks: construct_webhook_events(raw_body, Some(signature_header), &[secret], &Default::default()).
  • Authentication: identity_hash(sdk_secret, external_id) and ES256 identity_token(&IdentityTokenOptions { … }).

Detailed guide: pushizo-rust README.

On this page