laravel-rust 0.1.0

Laravel for Rust: a full-stack Rust web framework, inspired by PHP Laravel
Documentation
//! Notify users by email, text message, Slack, and package [channels](Channel).
//!
//! When something happens that a user should hear about, such as a paid invoice, a notification
//! tells them on each channel they use. A notification is a struct with [`#[notification]`](macro@crate::notification) on the impl
//! holding its `mail`, `sms`, `slack`, and `#[via(Channel)]` methods. The attribute implements
//! [`Notification`], [`ToMail`], [`ToSms`], and [`ToChannel`] from them. `notification::to`
//! names the notifiables, and `send` or `queue` delivers the notification to each of them:
//!
//! ```no_run
//! use laravel::mail::{Address, Mailable};
//! use laravel::notification;
//! use laravel::notification::{ReceivesMail, ReceivesSms};
//! use laravel::sms::PhoneNumber;
//!
//! pub struct User { pub name: String, pub email: String, pub phone: Option<String> }
//!
//! impl ReceivesMail for User {
//!     fn mail_address(&self) -> Option<Address> {
//!         Some(Address::new(&self.email).with_name(&self.name))
//!     }
//! }
//!
//! impl ReceivesSms for User {
//!     fn sms_number(&self) -> Option<PhoneNumber> {
//!         self.phone.as_deref().map(PhoneNumber::new)
//!     }
//! }
//!
//! #[derive(Mailable)]
//! #[mail(subject = "Invoice #{invoice_id} is paid")]
//! pub struct InvoicePaidEmail { pub name: String, pub invoice_id: u64 }
//!
//! pub struct InvoicePaid { pub invoice_id: u64 }
//!
//! #[notification]
//! impl InvoicePaid {
//!     fn mail(&self, user: &User) -> impl Mailable {
//!         InvoicePaidEmail { name: user.name.clone(), invoice_id: self.invoice_id }
//!     }
//!
//!     fn sms(&self, _user: &User) -> String {
//!         format!("Invoice #{} is paid.", self.invoice_id)
//!     }
//! }
//!
//! # async fn example(user: User, team: Vec<User>) -> laravel::Result<()> {
//! notification::to(&user).send(InvoicePaid { invoice_id: 42 }).await?;
//! notification::to(&team).queue(InvoicePaid { invoice_id: 42 }).await?;
//! # Ok(()) }
//! ```
//!
//! A method that can fail to build its message, such as one that links to a route, returns a
//! `laravel::Result` of it instead. The traits always return a `Result`, and the attribute wraps
//! the message of a method that doesn't. The [notifications guide] covers notifiables, choosing
//! channels for each notifiable, package channels, and testing with [`fake`](fake()).
//!
//! [notifications guide]: https://github.com/laravel/rust-framework/blob/0.x/docs/notifications.md

#[doc(hidden)]
pub use laravel_notifications::notification::__Deliver;
pub(crate) use laravel_notifications::notification::*;
#[doc(inline)]
pub use laravel_notifications::notification::{
    Channel, Channels, Delivers, Mail, Notifiables, Notification, NotificationFake, NotifiedBy, PendingNotification,
    PendingQueue, PendingSend, Receives, ReceivesMail, ReceivesSlack, ReceivesSms, Selected, SentNotification, Slack,
    Sms, ToChannel, ToMail, ToSms, channel, fake, to,
};