pub struct EmailApi { /* private fields */ }Expand description
Email API facade — typed API in [KernelHandle].
Constructed during kernel assembly (only when [email] is configured)
and stored in KernelHandle.email.
Implementations§
Source§impl EmailApi
impl EmailApi
Sourcepub fn new(
smtp: SmtpClient,
template_dir: PathBuf,
state_store: Arc<StateStore>,
event_bus: Option<EventBus>,
rate_limit: usize,
) -> Self
pub fn new( smtp: SmtpClient, template_dir: PathBuf, state_store: Arc<StateStore>, event_bus: Option<EventBus>, rate_limit: usize, ) -> Self
Create a new EmailApi.
Sourcepub async fn send(
&self,
subject: &str,
html: &str,
text: Option<&str>,
) -> Result<SendReceipt>
pub async fn send( &self, subject: &str, html: &str, text: Option<&str>, ) -> Result<SendReceipt>
Send an email (delegated to SmtpClient).
Sourcepub async fn test_connection(&self) -> Result<()>
pub async fn test_connection(&self) -> Result<()>
Test the SMTP connection.
Sourcepub fn default_to(&self) -> &str
pub fn default_to(&self) -> &str
The default recipient address (user’s own email).
Sourcepub fn load_template(&self, name: &str) -> Result<String>
pub fn load_template(&self, name: &str) -> Result<String>
Load a template by name.
Templates are stored as email_templates/<name>.html.
Sourcepub fn list_templates(&self) -> Result<Vec<String>>
pub fn list_templates(&self) -> Result<Vec<String>>
List all available template names.
Sourcepub async fn save_sent_record<T: Serialize>(&self, record: &T) -> Result<()>
pub async fn save_sent_record<T: Serialize>(&self, record: &T) -> Result<()>
Save a sent email record to the state store.
Filename format: {timestamp}_{short_id}.json for rate-limit parsing.
Sourcepub async fn count_recent_sent(&self, hours: u64) -> Result<usize>
pub async fn count_recent_sent(&self, hours: u64) -> Result<usize>
Count emails sent in the last hours hours (for rate limiting).
Expects filenames: YYYYMMDD_HHMMSS_shortid.json
Sourcepub fn notify_sent(
&self,
subject: String,
message_id: String,
template_name: Option<String>,
)
pub fn notify_sent( &self, subject: String, message_id: String, template_name: Option<String>, )
Publish an EmailSent event to the event bus.
Sourcepub fn rate_limit(&self) -> usize
pub fn rate_limit(&self) -> usize
Rate limit (emails per hour).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for EmailApi
impl !UnwindSafe for EmailApi
impl Freeze for EmailApi
impl Send for EmailApi
impl Sync for EmailApi
impl Unpin for EmailApi
impl UnsafeUnpin for EmailApi
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