Skip to main content

Crate larust_mail

Crate larust_mail 

Source
Expand description

Mail sending - Laravel’s Mail::to($user)->send(new WelcomeMail($user)), re-exported through larust_support::mail (see crates/larust-support/src/lib.rs) so generated apps depend only on larust-support, never on this crate directly.

fake’s exports (fake, assert_sent, assert_not_sent, SentMail) are deliberately not re-exported through larust_support::mail - they’re testing-only (calling fake() from real app code would silently and permanently stop that process from ever sending real mail again). larust-testing reaches them by depending on this crate directly instead.

Structs§

MailBuilder
MailJob
Framework-owned - fields are pub(crate), so this is only ever built by MailBuilder::queue, never constructed (or queued) directly by app code. registry.register::<larust_support::mail::MailJob>() is a real registration, no different from any app-defined Job’s - it’s just that xr new’s scaffold writes that line into every generated app’s queue:work branch by default, rather than leaving it as a hint the app author must remember to add.
SentMail
A rendered, already-sent (recorded, not dispatched) email - the output of a Mailable, not the typed instance itself. Recording the instance would require Mailable: 'static, which would force every Mailable (including the real WelcomeMail<'a>, which borrows its User) to own its data instead of borrowing - a breaking constraint this design avoids entirely.

Traits§

Mailable
A single email type (Laravel’s Mailable classes) - implemented once per email the app sends. Both methods are required, with no default body: a trait-level default would reintroduce the same “silent gap instead of compile error” failure mode Policy<U>’s own doc comment already treats as worth avoiding - forgetting to write a real subject or body should fail to compile, not silently send a blank email.

Functions§

assert_not_sent
Panics if any recorded M satisfies predicate. Same lock-then-drop- before-asserting shape as assert_sent, for the same reason.
assert_sent
Panics unless at least one recorded M satisfies predicate.
fake
Activates recording - every send() call for the rest of this process records instead of dispatching (log/smtp), regardless of mail_driver. Idempotent: a second call in the same process is a no-op (first-writer-wins, matching every other process-wide registry in this codebase - larust_orm::connect(), the route-name registry, the event-listener registry). The recorded list from the first activation keeps accumulating; nothing resets it.
mail
Entry point for Laravel’s Mail::to($user)->send(new WelcomeMail($user)).