5 releases
| 1.0.0-alpha.16+croatian-pine-marten | Feb 26, 2024 |
|---|---|
| 1.0.0-alpha.15+croatian-pine-marten | Feb 23, 2024 |
| 1.0.0-alpha.14+croatian-pine-marten | Feb 22, 2024 |
#3 in #flawless
194 downloads per month
15KB
209 lines
flawless-slack
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.6–13MB
~155K SLoC