pub struct NotificationService { /* private fields */ }Expand description
Maps commerce events to transactional emails and delivers them via a configurable backend.
Implementations§
Source§impl NotificationService
impl NotificationService
Sourcepub fn new(config: NotificationConfig, backend: Box<dyn EmailBackend>) -> Self
pub fn new(config: NotificationConfig, backend: Box<dyn EmailBackend>) -> Self
Create a new notification service.
Sourcepub fn with_recipient_resolver(self, resolver: RecipientResolver) -> Self
pub fn with_recipient_resolver(self, resolver: RecipientResolver) -> Self
Set a custom recipient resolver function.
The resolver receives a CommerceEvent and should return the
recipient email address, or None to skip sending.
Sourcepub const fn config(&self) -> &NotificationConfig
pub const fn config(&self) -> &NotificationConfig
Get the service configuration.
Sourcepub fn process_event(
&self,
event: &CommerceEvent,
) -> Result<Option<Uuid>, String>
pub fn process_event( &self, event: &CommerceEvent, ) -> Result<Option<Uuid>, String>
Process a commerce event, potentially sending an email notification.
Returns Ok(Some(message_id)) if an email was sent, Ok(None) if
the event does not map to an email template or the template is
disabled, and Err if delivery failed.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for NotificationService
impl !UnwindSafe for NotificationService
impl Freeze for NotificationService
impl Send for NotificationService
impl Sync for NotificationService
impl Unpin for NotificationService
impl UnsafeUnpin for NotificationService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more