Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AsyncTransport Send + Sync type bounds? #770

Open
jhillyerd opened this issue May 29, 2022 · 0 comments · May be fixed by #772
Open

Add AsyncTransport Send + Sync type bounds? #770

jhillyerd opened this issue May 29, 2022 · 0 comments · May be fixed by #772

Comments

@jhillyerd
Copy link
Contributor

jhillyerd commented May 29, 2022

Is your feature request related to a problem? Please describe.
I'm finding the type bounds required to have a testable function (that accepts both async SMTP and async stub transports) somewhat clunky. I'm quite new to rust, so perhaps I'm doing it wrong, but the compiler told me I needed to have all these bounds on my function:

use lettre::{AsyncTransport, Message};

pub async fn send_alert<T>(mailer: &T, subject: &str, body: &str) -> anyhow::Result<()>
where
    T: AsyncTransport + Send + Sync,
    <T as AsyncTransport>::Error: 'static + Send + Sync,
    <T as AsyncTransport>::Error: std::error::Error,
{
    let email = Message::builder()

Describe the solution you'd like
I feel AsyncTransport should specify these bounds itself. At least for errors, requiring Send + Sync seems pretty reasonable.

Describe alternatives you've considered
Likely making my own trait if I need more mailing funcs.

Additional context
#356 & this is on 0.10.0-rc.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants