The bane of my existence: Supporting both async and sync code in Rust

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • stm32-hal

    This library provides access to STM32 peripherals in Rust.

  • unasync

    The async transformation code.

  • Nice! This is similar to the solution here: https://github.com/python-trio/unasync

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • rfcs

    RFCs for changes to Rust

  • In the early days of Rust there was a debate about whether to support "green threads" and in doing that require runtime support. It was actually implemented and included for a time but it creates problems when trying to do library or embedded code. At the time Go for example chose to go that route, and it was both nice (goroutines are nice to write and well supported) and expensive (effectively requires GC etc). I don't remember the details but there is a Rust RFC from when they removed green threads:

    https://github.com/rust-lang/rfcs/blob/0806be4f282144cfcd55b...

  • k8s-openapi

    Rust definitions of the resource types in the Kubernetes client API

  • Another option is to implement your API in a sans-io form. Since k8s-openapi was mentioned (albeit for a different reason), I'll point out that its API gave you a request value that you could send using whatever sync or async HTTP client you want to use. It also gave you a corresponding function to parse the response, that you would call with the response bytes however you got them from your client.

    https://github.com/Arnavion/k8s-openapi/blob/v0.19.0/README....

    (Past tense because I removed all the API features from k8s-openapi after that release, for unrelated reasons.)

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts