3 ms·
> For 2, hopefully those traits will eventually be standardized in std. We got async functions in traits, but we can't create trait objects with these traits y
by andrewl-hn 2y ago
> For 2, hopefully those traits will eventually be standardized in std.
We got async functions in traits, but we can't create trait objects with these traits yet without using a separate crate and without boxing. Once it will be possible this would mean that projects like embassy can rely on these traits in environments that don't allow heap allocations. Another relevant feature is async iterators / streams. This would be the point when these traits will be standardized. We are probably 1-2 years away at this point.
Tokio and other runtimes meanwhile made effort to be ready for when these traits become standard: tokio keeps all relevant `read` and `write` methods in custom `AsyncReadExt` / `AsyncWriteExt` traits so that when a standard version of these methods appears people won't end up with conflicting implementations and broken code.
Great post: it's something I wanted to write for the past 2 years or so and I'm glad this post exists now. Thank you so much!