Skip to main content

hookburn_slack/
lib.rs

1// crates/hookburn-slack/src/lib.rs
2#![deny(missing_docs)]
3
4//! Slack webhook client for Hookburn.
5//!
6//! This crate provides a client for sending messages to Slack via incoming webhooks.
7//! It implements the `WebhookSender` trait and can be used directly or through
8//! the unified `hookburn` crate.
9//!
10//! # Example
11//!
12//! ```rust,no_run
13//! use hookburn_slack::{SlackClient, SlackMessage};
14//!
15//! #[tokio::main]
16//! async fn main() -> Result<(), hookburn_slack::SlackError> {
17//!     let client = SlackClient::new("https://hooks.slack.com/services/T/B/X")?;
18//!
19//!     let message = SlackMessage::builder()
20//!         .text("Hello from Hookburn!")
21//!         .build()?;
22//!
23//!     client.send(&message).await
24//! }
25//! ```
26
27/// HTTP client with retry support and timeout handling.
28pub mod client;
29
30/// Common error types for the hookburn ecosystem.
31pub mod error;
32
33/// Service-agnostic message types and conversion traits.
34pub mod message;
35
36/// Service metadata and builder traits for service creation.
37pub mod service;
38
39pub use client::{SlackClient, SlackClientBuilder};
40pub use error::SlackError;
41pub use message::{
42    SlackActionsBlock, SlackAttachment, SlackAttachmentField, SlackBlock, SlackButton,
43    SlackContextBlock, SlackElement, SlackHeaderBlock, SlackMessage, SlackMessageBuilder,
44    SlackSectionBlock, SlackText, SlackTextType,
45};
46pub use service::{SlackMessageConverter, SlackSenderWrapper, SlackService};
47
48/// Register the Slack service with the global registry.
49///
50/// This function is called by the `hookburn` crate when the `slack` feature is enabled.
51/// It returns a `SlackService` that implements the `ServiceBuilder` trait.
52///
53/// # Example
54///
55/// ```rust,no_run
56/// use hookburn_slack::register_service;
57/// use hookburn_core::WebhookRegistry;
58///
59/// let mut registry = WebhookRegistry::new();
60/// registry.register(register_service());
61/// ```
62pub fn register_service() -> SlackService {
63    SlackService::new()
64}