Skip to main content

serenade_notifier/
lib.rs

1//! SMS and push notification channels (Symfony Notifier shaped).
2//!
3//! Types: [`Notification`], [`Channel`], [`SmsMessage`], [`PushMessage`].
4//! Transports: [`NullTransport`], [`MemoryTransport`], [`SmsOnlyTransport`].
5//! DI: [`RegisterDefaultNotifierPass`] seeds [`DEFAULT_NOTIFIER_SERVICE`].
6//!
7//! # Examples
8//!
9//! ```
10//! use serenade_notifier::{MemoryTransport, Notification, Transport};
11//!
12//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
13//! let transport = MemoryTransport::new();
14//! transport.send(&Notification::sms("+15551212", "hello"))?;
15//! assert_eq!(transport.sent().len(), 1);
16//! # Ok(())
17//! # }
18//! ```
19
20mod channel;
21mod compile_pass;
22mod error;
23mod memory;
24mod notification;
25mod null;
26mod sms_only;
27mod transport;
28
29pub use channel::Channel;
30pub use compile_pass::{
31    DEFAULT_NOTIFIER_SERVICE, NOTIFIER_TRANSPORT_TAG, NotifierService, RegisterDefaultNotifierPass,
32};
33pub use error::NotifierError;
34pub use memory::MemoryTransport;
35pub use notification::{Notification, PushMessage, SmsMessage};
36pub use null::NullTransport;
37pub use sms_only::SmsOnlyTransport;
38pub use transport::Transport;
39
40/// Compile-time crate version for diagnostics.
41#[must_use]
42pub const fn version() -> &'static str {
43    env!("CARGO_PKG_VERSION")
44}
45
46#[cfg(test)]
47mod tests;