Articles tagged #async-fn-in-trait

Async fn in trait, for real this time

async_trait's one weird type ascription trick

Now that I got the Log in with GitHub feature working, let's explore what this would've looked like with the async_trait crate.

First up, the trait definition:

/// Something that can refresh credentials
#[async_trait::async_trait]
pub trait CredentialsRefresher {
    async fn refresh(&   -> eyre

Async fn in trait... not

Async fn in trait... not

I was planning on showing the in-progress async_fn_in_trait feature in the context of my website, but it turns out, I can't!

My website uses two databases: one local SQLite database for content, and a shared Postgres database for user credentials, preferences etc. Migrations are run on startup, and each migration implements one of the following traits:

Go back to the homepage.