Skip to main content

Crate notifica_rust_sdk

Crate notifica_rust_sdk 

Source
Expand description

§notifica-crate

Rust client SDK for the Notifica notification service.

Install this crate in any project that needs to broadcast notifications (email, push, webhooks) to the Notifica service.

§Quick start

use notifica_crate::{EmailPayload, Notification, NotificaClient};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = NotificaClient::new(
        std::env::var("NOTIFICA_URL")?,    // e.g. "http://notifica:8000"
        std::env::var("NOTIFICA_TENANT")?, // e.g. "my-app"
    );

    client.send(
        "user_registered",
        Notification::new()
            .email(
                EmailPayload::new("alice@example.com")
                    .target_name("Alice")
                    .subject("Welcome!")
                    .param("code", "1234"),
            )
            .push(vec!["expo-device-token".into()]),
    ).await?;

    Ok(())
}

Re-exports§

pub use client::NotificaClient;
pub use error::NotificaError;
pub use error::NotificaResult;
pub use payload::EmailPayload;
pub use payload::Notification;
pub use payload::WebhookPayload;

Modules§

client
error
payload