auto-future

Crates.ioauto-future
lib.rsauto-future
version1.0.0
sourcesrc
created_at2023-02-01 00:02:08.601571
updated_at2023-02-01 00:02:08.601571
descriptionFor quickly making a struct into a future via an async fn
homepage
repositoryhttps://github.com/JosephLenton/auto-future
max_upload_size
id773136
size5,074
Joseph Lenton (JosephLenton)

documentation

https://docs.rs/auto-future/latest/auto-future

README

Auto Future
a means for easily building futurable structs

crate docs

This is for quickly making structs futurable, where the future implementation is an underlying async fn.

See this example for details ...

  use ::auto_future::AutoFuture;

  struct ExampleStruct;

  impl ExampleStruct {
    async fn do_async_work(self) -> u32 {
      // perform a bunch of awaited calls ...

      123
    }
  }

  impl IntoFuture for ExampleStruct {
      type Output = u32;
      type IntoFuture = AutoFuture<u32>;

      fn into_future(self) -> Self::IntoFuture {
          let raw_future = self.do_async_work();
          AutoFuture::new(raw_future)
      }
  }
Commit count: 2

cargo fmt