Crate flawless_slack

source ·
Expand description

§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();

Modules§

Structs§

  • Represents a block in a Slack message.
  • Represents a Slack channel.
  • Represents an element in a Slack message block.
  • Represents a Slack message.
  • Represents a Slack client that interacts with the Slack API using the provided HTTP client.

Enums§

  • Represents errors that can occur during interactions with the Slack API.