About
pecs is a plugin for Bevy that allows you
to execute code asynchronously by chaining multple promises as part of Bevy's ecs enviroment.
pecsstands for Promise Entity Component System.
Resources:
Features
- promise chaining with
then() - state passing (
statefor promises is likeselffor items) - complete type inference (the next promise knows the type of the previous result)
- out-of-the-box timer and http promises via
asynmod and statefulstate.asyn() - custom promise registretion (add any asyn function you want!)
system paramsfetching (promiseasyn!funcs accepts the same params the bevy systems does)- nested promises (with chaining, obviously)
- combining promises with any/all for tuple/vec of promises via stateles
Promise::any()/Promise::all()or statefulstate.any()/state.all() - state mapping via
with(value)/map(func)(change state type/value over chain calls) - result mapping via
with_ok(value)/map_ok(func)(change result type/value over chain calls)
Example
use *;
use *;
There is otput of the above example, pay some attention to time stamps:
18.667 INFO bevy_render::renderer: AdapterInfo { ... }
18.835 INFO simple: Wait a second..
19.842 INFO simple: How large is is the Bevy main web page?
19.924 INFO simple: It is 17759 bytes!
19.924 INFO simple: It tooks 1.09s to do this job.
19.924 INFO simple: Exiting now
Work in Progress
This repo is more like an experimental-proof-of-concept than a production-ready library. API could and will change. App will crash (there are some untested unsafe blocks), some promises will silently drop (there are stil no unit tests), documentation is incomplete and so on. But. But. Examples works like a charm. And this fact gives us a lot of hope.
License
The pecs is dual-licensed under either:
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
This means you can select the license you prefer! This dual-licensing approach is the de-facto standard in the Rust ecosystem and there are very good reasons to include both.