#future #async

auto-future

For quickly making a struct into a future via an async fn

1 stable release

1.0.0 Feb 1, 2023

#853 in Asynchronous

Download history 16109/week @ 2024-07-21 16488/week @ 2024-07-28 16472/week @ 2024-08-04 16509/week @ 2024-08-11 18612/week @ 2024-08-18 17969/week @ 2024-08-25 19095/week @ 2024-09-01 17714/week @ 2024-09-08 17623/week @ 2024-09-15 20579/week @ 2024-09-22 20751/week @ 2024-09-29 24263/week @ 2024-10-06 27360/week @ 2024-10-13 26612/week @ 2024-10-20 28615/week @ 2024-10-27 30811/week @ 2024-11-03

115,256 downloads per month
Used in 38 crates (2 directly)

MIT license

4KB

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)
      }
  }

No runtime deps