Crates.io | flawless-slack |
lib.rs | flawless-slack |
version | 1.0.0-alpha.16+croatian-pine-marten |
source | src |
created_at | 2024-02-22 11:12:06.62356 |
updated_at | 2024-02-26 10:39:56.610107 |
description | Transport protocol agnostic Slack client for Rust. |
homepage | |
repository | |
max_upload_size | |
id | 1149206 |
size | 16,572 |
Transport protocol agnostic Slack client for Rust.
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.
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();