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

auto-future

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

1 stable release

1.0.0 Feb 1, 2023

#848 in Asynchronous

Download history 5692/week @ 2024-01-10 6614/week @ 2024-01-17 7299/week @ 2024-01-24 7090/week @ 2024-01-31 7330/week @ 2024-02-07 6976/week @ 2024-02-14 8312/week @ 2024-02-21 7869/week @ 2024-02-28 8223/week @ 2024-03-06 6564/week @ 2024-03-13 7347/week @ 2024-03-20 5663/week @ 2024-03-27 6755/week @ 2024-04-03 5941/week @ 2024-04-10 7140/week @ 2024-04-17 8096/week @ 2024-04-24

29,040 downloads per month
Used in 23 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