Skip to main content

lark_webhook_notify/
lib.rs

1//! Send rich notification cards to [Lark (Feishu)](https://www.feishu.cn) group bots
2//! via incoming webhooks.
3//!
4//! ## Getting started
5//!
6//! ```no_run
7//! use lark_webhook_notify::{LarkWebhookNotifier, job_complete, LanguageCode};
8//!
9//! # fn main() -> lark_webhook_notify::Result<()> {
10//! let notifier = LarkWebhookNotifier::from_params(
11//!     "https://open.feishu.cn/open-apis/bot/v2/hook/...",
12//!     "your_signing_secret",
13//! )?;
14//!
15//! let card = job_complete(
16//!     "my-training-job", true, 0,
17//!     Some("experiments"), None, None, None, None, None,
18//!     LanguageCode::En,
19//! );
20//! notifier.send_template(&card)?;
21//! # Ok(())
22//! # }
23//! ```
24//!
25//! ## Architecture
26//!
27//! The library has three layers:
28//!
29//! 1. **Workflow functions** ([`workflow`]) — high-level, opinionated notifications for
30//!    common pipeline events (network submission, job lifecycle, comparisons, etc.).
31//!    Use these for the fastest path to a good-looking notification.
32//!
33//! 2. **Template structs** ([`templates`]) — mid-level structs implementing [`LarkTemplate`].
34//!    Instantiate directly when you need to set every field explicitly, or subclass with
35//!    your own `impl LarkTemplate`.
36//!
37//! 3. **[`CardBuilder`]** — fluent builder for fully custom cards. Accepts any combination
38//!    of markdown, columns, collapsible panels, and raw block values.
39//!
40//! All three layers produce a value that implements [`LarkTemplate`], which you pass to
41//! [`LarkWebhookNotifier::send_template`].
42
43pub mod blocks;
44pub mod builder;
45pub mod client;
46pub mod config;
47pub mod convenience;
48pub mod error;
49pub mod templates;
50pub mod workflow;
51
52// Re-export the main public API
53pub use blocks::{BgStyle, ColumnWidth, HAlign, TextAlign, TextSize, VAlign};
54pub use builder::CardBuilder;
55pub use client::LarkWebhookNotifier;
56pub use config::LarkWebhookSettings;
57pub use convenience::{
58    send_alert, send_simple_message, send_task_failure, send_task_notification, send_task_result,
59    send_task_start,
60};
61pub use error::{LarkWebhookError, Result};
62pub use templates::{
63    AlertTemplate, CardContent, ColorTheme, GenericCardTemplate, LanguageCode, LarkTemplate,
64    LegacyTaskTemplate, RawContentTemplate, ReportFailureTaskTemplate, ReportTaskResultTemplate,
65    SeverityLevel, SimpleMessageTemplate, StartTaskTemplate, get_translation,
66};
67pub use workflow::{
68    TaskSetProgress, comparison_complete, config_upload_complete, create_custom_template,
69    job_complete, job_submission_complete, job_submission_failure, job_submission_start,
70    network_submission_complete, network_submission_failure, network_submission_start,
71    result_collection_complete, result_collection_start, task_set_progress,
72};