Skip to main content

hookburn_core/
lib.rs

1// crates/hookburn-core/src/lib.rs
2
3//! # Hookburn Core
4//!
5//! Shared types and traits for the hookburn webhook ecosystem.
6//!
7//! This crate provides the foundation for building webhook clients that work
8//! with multiple services (Discord, Slack, Teams, etc.). It defines common
9//! interfaces, message types, and utilities that service crates can implement.
10//!
11//! # Features
12//!
13//! - **Unified API**: Send messages to any webhook service through a common trait
14//! - **Generic Messages**: Service-agnostic message types with conversion support
15//! - **Service Registry**: Discover and create webhook clients dynamically
16//! - **Retry Policies**: Automatic retries with exponential backoff and jitter
17//! - **HTTP Client**: Configurable HTTP client with timeout support
18//!
19//! # Example
20//!
21//! ```rust,no_run
22//! use hookburn_core::{WebhookSender, GenericMessage, WebhookService};
23//!
24//! // Create a service-specific sender (e.g., Discord)
25//! // let sender = ...;
26//!
27//! // Send a generic message
28//! let msg = GenericMessage::new("Hello from Hookburn!")
29//!     .with_username("MyBot");
30//!
31//! // sender.send(&msg).await?;
32//! # Ok::<(), Box<dyn std::error::Error>>(())
33//! ```
34//!
35//! # Crate Organization
36//!
37//! | Module | Purpose |
38//! |--------|---------|
39//! | `builder` | HTTP client builder with configurable timeouts |
40//! | `client` | HTTP client wrapper with retry support |
41//! | `error` | Common error types for all services |
42//! | `message` | Generic message types and conversion trait |
43//! | `registry` | Service discovery and registration |
44//! | `retry` | Retry policies with exponential backoff |
45//! | `sender` | Core `WebhookSender` trait for all services |
46//! | `service` | Service metadata and builder trait |
47//! | `webhook_service` | Generic service wrapper for easy usage |
48
49#![deny(missing_docs)]
50
51/// HTTP client builder with configurable timeouts.
52pub mod builder;
53
54/// HTTP client with retry support and timeout handling.
55pub mod client;
56
57/// Common error types for the hookburn ecosystem.
58pub mod error;
59
60/// Service-agnostic message types and conversion traits.
61pub mod message;
62
63/// Service registry for discovering and creating webhook clients.
64pub mod registry;
65
66/// Retry policies with exponential backoff and jitter.
67pub mod retry;
68
69/// Core `WebhookSender` trait implemented by all services.
70pub mod sender;
71
72/// Service metadata and builder traits for service creation.
73pub mod service;
74
75/// Generic webhook service wrapper implementation.
76pub mod webhook_service;
77
78// Re-exports
79
80/// HTTP client builder for configuring timeouts and connection settings.
81pub use builder::HttpClientBuilder;
82
83/// HTTP client with retry support and shared connection pool.
84pub use client::HttpClient;
85
86/// Common error type used across all hookburn services.
87pub use error::CoreError;
88
89/// Generic message types for service-agnostic webhook sending.
90pub use message::{GenericEmbed, GenericMessage, MessageConverter};
91
92/// Service registry for discovering and creating webhook clients.
93pub use registry::WebhookRegistry;
94
95/// Retry policy with exponential backoff and optional jitter.
96pub use retry::RetryPolicy;
97
98/// Core trait for sending webhook messages to any service.
99pub use sender::WebhookSender;
100
101/// Service metadata, configuration, and builder traits.
102pub use service::{Platform, ServiceBuilder, ServiceConfig, ServiceInfo};
103
104/// Generic webhook service wrapper that sends `GenericMessage`.
105pub use webhook_service::{BoxedWebhookSender, WebhookService};