0

I'm still very new to Rust and therefore still trying to make sense of a lot of things.

I noticed Axum can now have the Tokio feature disabled, in order to compile it to WebAssembly, and deploy it to something like CloudFlare Workers.

But how does that work exactly, does that mean it's no longer asynchronous?

cafce25
  • 15,907
  • 4
  • 25
  • 31
  • "[...] in order to compile it to WebAssembly, and deploy it to something like CloudFlare Workers." May I ask where you have that information from? I can't find anything on this – Jonas Fassbender Mar 16 '23 at 15:11
  • 1
    I read about it here: https://tokio.rs/blog/2022-11-25-announcing-axum-0-6-0, and here: https://github.com/tokio-rs/axum/pull/1382 – whit3.oc7opus Mar 16 '23 at 15:39

1 Answers1

1

A function is asynchronous if it is defined as such (async keyword) or returns a Future with the former more or less being syntax sugar for the latter, tokio is merely a runtime to run futures for you (it polls them until they are finished), it's presence is orthogonal to something being asynchronous.

cafce25
  • 15,907
  • 4
  • 25
  • 31
  • I think I should have worded the question a bit better - can it still execute asynchronous code, if Tokio was to be disabled? – whit3.oc7opus Mar 16 '23 at 13:56
  • 1
    @whit3.oc7opus yes you can but you either need to use a different asynchronous runtime other than tokio or poll your futures yourself. AFAICT, [`workers-rs`](https://github.com/cloudflare/workers-rs) is the runtime and SDK for CloudFlare Workers in Rust, which I assume you are looking for based on your question. – Jonas Fassbender Mar 16 '23 at 15:14