ferro_notifications/
lib.rs

1//! # Ferro Notifications
2//!
3//! Multi-channel notification system for the Ferro framework.
4//!
5//! Provides a Laravel-inspired notification system with support for:
6//! - Mail notifications via SMTP
7//! - Database notifications for in-app delivery
8//! - Slack webhook notifications
9//!
10//! ## Example
11//!
12//! ```rust,ignore
13//! use ferro_notifications::{Notification, Notifiable, Channel, MailMessage};
14//!
15//! // Define a notification
16//! struct OrderShipped {
17//!     order_id: i64,
18//!     tracking: String,
19//! }
20//!
21//! impl Notification for OrderShipped {
22//!     fn via(&self) -> Vec<Channel> {
23//!         vec![Channel::Mail, Channel::Database]
24//!     }
25//!
26//!     fn to_mail(&self) -> Option<MailMessage> {
27//!         Some(MailMessage::new()
28//!             .subject("Your order has shipped!")
29//!             .body(format!("Tracking: {}", self.tracking)))
30//!     }
31//! }
32//!
33//! // Make User notifiable
34//! struct User {
35//!     email: String,
36//! }
37//!
38//! impl Notifiable for User {
39//!     fn route_notification_for(&self, channel: Channel) -> Option<String> {
40//!         match channel {
41//!             Channel::Mail => Some(self.email.clone()),
42//!             _ => None,
43//!         }
44//!     }
45//! }
46//!
47//! // Send the notification
48//! let user = User { email: "user@example.com".into() };
49//! user.notify(OrderShipped {
50//!     order_id: 123,
51//!     tracking: "ABC123".into(),
52//! }).await?;
53//! ```
54
55mod channel;
56mod channels;
57mod dispatcher;
58mod error;
59mod notifiable;
60mod notification;
61
62pub use channel::Channel;
63pub use channels::{DatabaseMessage, MailMessage, SlackAttachment, SlackField, SlackMessage};
64pub use dispatcher::{MailConfig, NotificationConfig, NotificationDispatcher};
65pub use error::Error;
66pub use notifiable::{ChannelResult, DatabaseNotificationStore, Notifiable, StoredNotification};
67pub use notification::Notification;
68
69/// Re-export async_trait for convenience.
70pub use async_trait::async_trait;