I've been trying to figure out how to solve a problem, but to no avail - so I'll pose it here:
All I want to do is send an email after a user has invited someone to an event. However, I don't want to wait for the email to be send before telling the user the invite was created successfully (on invite, the database is updated so the invitee will see it on next login).
Thus, I tried to use tokio's task system to
task::spawn the function that sends the email from the function that tells the user the invite was successful. I'm using rocket.rs, and when I tried to put
#[tokio::main] above my main function, I got an error about task::spawn having to be called from the context of a tokio runtime.
Surely there must be a simpler way of doing this than trial and error putting
#[tokio::main] on top of each function in my program until tokio executes the code. I've looked into clokwerk as well, but that seems to be for scheduling recurring tasks (e.g. once per week), not one-off tasks such as notification emails.
Thanks in advance for any help.