简体   繁体   中英

How do I most idiomatically write an async IO library in Rust for no_std platforms?

I'm building a library to be used on a no_std platform which allows you to do some common network-related IO, such as making HTTP requests or reading from/writing to Websockets.

Now, I would like this library to be a well-behaved citizen so that it can be easily included in other no_std applications. I hence want to package the library by implementing reasonable traits etc. The library would allow me to not have to use alloc , so supporting non- alloc no_std would be ideal.

These are the options I have looked at:

  • embedded_hal and nb : These crates are really low level (no generic traits like Read and Write or anything higher level) and the async model doesn't seem to be compatible with async/await
  • genio / core_io /...: These don't support async IO at all.
  • embrio : Seems interesting but it seems like using it would tie me to one specific environment, making the library less portable.
  • tokio v0.2.x: I would love to use it but there is no no_std support at all.
  • futures::io v0.3.x: Again, would love to use it but there is no no_std support.

Which async IO abstraction should I use in a no_std environment? If there is no good option right now, which one should I bet on/help out with for the future?

Take a look a look at embassy-rs . There is a very active community. Currently, embassy-rs supports;

  • Hardware abstraction layers
  • Time
  • Networking
  • Bluetooth
  • Lora
  • USB
  • DFU

All built on rust async. There are also some really nice macros to generate static buffers for tasks, so you don't need alloc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM