How can I define an async method in a trait?
On stable Rust, async fn cannot be used in traits. There is ongoing work that will make this possible in the future, but the easiest solution currently is to use the async-trait crate: #[async_trait] trait Readable { async fn readable(&self) -> io::Result<()>; } #[async_trait] impl Readable for Reader { async fn readable(&self) -> io::Result<()> { … Read more