#future #async #quickly #auto #fn #struct

auto-future

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

1 stable release

1.0.0 Feb 1, 2023

#898 in Asynchronous

Download history 1931/week @ 2023-11-23 2298/week @ 2023-11-30 2623/week @ 2023-12-07 3181/week @ 2023-12-14 3810/week @ 2023-12-21 4542/week @ 2023-12-28 6139/week @ 2024-01-04 5629/week @ 2024-01-11 6774/week @ 2024-01-18 7413/week @ 2024-01-25 6967/week @ 2024-02-01 7426/week @ 2024-02-08 6891/week @ 2024-02-15 8592/week @ 2024-02-22 7792/week @ 2024-02-29 5907/week @ 2024-03-07

30,401 downloads per month
Used in 16 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