Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cakekindel/slack-blocks-rs
slack messages at warp speed!
https://github.com/cakekindel/slack-blocks-rs
data-structures json library models rust rust-crate rust-library slack slack-block-kit slack-messages
Last synced: about 2 months ago
JSON representation
slack messages at warp speed!
- Host: GitHub
- URL: https://github.com/cakekindel/slack-blocks-rs
- Owner: cakekindel
- License: apache-2.0
- Created: 2020-05-16T16:40:51.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-08-29T17:41:34.000Z (over 1 year ago)
- Last Synced: 2024-09-19T06:39:57.992Z (3 months ago)
- Topics: data-structures, json, library, models, rust, rust-crate, rust-library, slack, slack-block-kit, slack-messages
- Language: Rust
- Homepage: https://docs.rs/slack-blocks/latest
- Size: 459 KB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
[![crates.io](https://img.shields.io/crates/v/slack-blocks.svg)](https://crates.io/crates/slack-blocks)
[![docs.rs](https://docs.rs/slack-blocks/badge.svg)](https://docs.rs/slack-blocks/latest)
![Maintenance](https://img.shields.io/badge/maintenance-activly--developed-brightgreen.svg)# slack-blocks
This crate brings Slack's terrific [Block Kit 🔗] to
the Rust ecosystem.Inside, you'll find models for all of Slack's Layout Blocks,
Block Elements, and Composition Objects. Each structure has Slack's API
documentation copied in-place so you don't have to leave your editor to
remember the details of the block kit API.Every model has builders that leverage Rust's type system
to help you provide every required field, so you can be confident in your app.### Troubleshooting common compiler errors
`Method build not found for ...Builder` - Dig into the error message,
you'll find something like `RequiredMethodNotCalled`,
meaning you need to call `.foo()` before you can call `.build()`!## Example
Using an example from Slack's Documentation:
```json
{
"type": "section",
"text": {
"text": "*Sally* has requested you set the deadline for the Nano launch project",
"type": "mrkdwn"
},
"accessory": {
"type": "datepicker",
"action_id": "datepicker123",
"initial_date": "1990-04-28",
"placeholder": {
"type": "plain_text",
"text": "Select a date"
}
}
}
```You can use raw Builders like so:
```rust
use slack_blocks::{text::ToSlackMarkdown, blocks::Section, elems::DatePicker};let section = Section::builder()
.text("*Sally* has requested you set the deadline for the Nano launch project".markdown())
.accessory(DatePicker::builder()
.action_id("datepicker123")
.initial_date((28, 4, 1990))
.placeholder("Select a date")
.build()
)
.build();
```Or enable the `unstable` feature and use xml macros:
```rust
use slack_blocks::blox::*;let pick_date = blox! {
};let section = blox! {
"*Sally* has requested you set the deadline for the Nano launch project"
};
```[Block Kit 🔗]: https://api.slack.com/block-kit
[`cargo-make`]: https://github.com/sagiegurari/cargo-make/
[issues]: https://github.com/cakekindel/slack-blocks-rs/issues/
[Conventional Commits]: https://www.conventionalcommits.org/en/v1.0.0/## License
Licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT)at your option.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally
submitted for inclusion in the work by you, as defined in the Apache-2.0
license, shall be dual licensed as above, without any additional terms or
conditions.