Rust Async Rant.

So transforming scootaloo in an async app (for fun and headache).

My main issue with async is now this: because Rust, async blocks have the same constraint as threads.

Meaning, they need to own everything they do, meaning you need to do a lot of clones of things to make them owned by the async block.

And if you want to get a result from you async block, guess what? Yep, that’s right mpsc with multi-channel comms…

So now about scootaloo (with an async branch).

Elefren (Mastodon’s API for Rust) is not async, so I can’t do much on this.

Media are downloaded in an async loop (good), but I cannot push them to Mastodon in the same loop (remember : everything needs to be owned by the async block so no reference to a global here) so I have to push their local path through a comm channel to be catched by another loop that blocks (!) to upload them.

Feeling a bit nasty…

Maybe I should try to get out the big guns and put the mastodon variable inside a Arc<Mutex<>> (so now it really will be unreadable !).

Follow

After a quick doc reading, @mortal you are actually right regarding Mutex.
I got a problem with Mutex but maybe it was due to the data stored inside. I will never know.

Sign in to participate in the conversation
NintendojoFR

Ceci est l'instance du site NintendojoFR. Elle est réservée aux membres de la rédaction et à nos chers lecteurs qui souhaitent avoir un compte.