flawless-slack

Transport protocol agnostic Slack client for Rust

5 releases

1.0.0-alpha… Feb 26, 2024
1.0.0-alpha… Feb 23, 2024
1.0.0-alpha… Feb 22, 2024

35 downloads per month

BSD-2-Clause-Patent

15KB
209 lines

flawless-slack

docs.rs docs crates.io version

Transport protocol agnostic Slack client for Rust.

Motivation

Rust code can run in many places, from tiny embedded systems, all they way to the browser. Those environments are very different from each other. Some require you to roll your own TCP implementation, others don't even give you access to low-level primitives like TCP.

flawless-slack is an attempt to build a Slack client that works equally well "everywhere". It was born out of a need for a Slack client inside the flawless durable execution engine. The engine runs Rust compiled to WebAssembly and doesn't provide raw access to TCP streams, nor access to non-blocking syscalls that an async executor could use. This disqualifies most other Slack client libraries out there.

By default, flawless-slack will use reqwest::blocking as a transport layer on systems that are not WebAssembly. When compiling to wasm32-unknown-unknown it will use the flawless implementation. However, all default transport layers can be disabled and directly provided by you, in case you want to use it in a custom environment.

Quick start

The Slack client takes 2 arguments, a secret token and an HTTP client implementation. If you would like to use the client inside flawless, you can use the provided FlawlessHttpClient:

use flawless_slack::{http_client::flawless_http_client::FlawlessHttpClient, SlackClient};

let secret_token = "<SECRET>".to_owned();
let slack_client = SlackClient::new(secret_token, FlawlessHttpClient {});

slack_client.send_message("#general","Hello World!").ok();

Dependencies

~0.7–12MB
~161K SLoC