This page is a work in progress.

The Rust SDK is currently in beta.

Installing

[dependencies]
sailhouse = { version = "0.1" }

# Just for the examples below
tokio = { version = "1", features = ["full"] }

Basic Usage

use std::{collections::HashMap, env};
use sailhouse::SailhouseClient;

fn main() {
    let token = match env::var("SAILHOUSE_TOKEN") {
        Ok(value) => value,
        Err(error) => {
            eprintln!("Failed to read SAILHOUSE_TOKEN: {}", error);
            return;
        }
    };

    let client = SailhouseClient::new(token);
    let mut data = HashMap::new();
    data.insert("message", "Hello world!");

    let publish_future = client.publish("example-topic", data);
    let _ = tokio::runtime::Runtime::new().unwrap().block_on(publish_future);
}

Initialising the client

let token = match env::var("SAILHOUSE_TOKEN") {
    Ok(value) => value,
    Err(error) => {
        eprintln!("Failed to read SAILHOUSE_TOKEN: {}", error);
        return;
    }
};

let client = SailhouseClient::new(token);