Crates.io | lazy_async_promise |
lib.rs | lazy_async_promise |
version | 0.6.0 |
source | src |
created_at | 2022-10-05 18:33:54.613624 |
updated_at | 2024-10-17 19:34:07.527958 |
description | Primitives for lazily getting data from futures with tokio for immediate mode guis |
homepage | https://github.com/ChrisRega/lazy_async_promise |
repository | https://github.com/ChrisRega/lazy_async_promise |
max_upload_size | |
id | 680680 |
size | 54,068 |
This crate currently only features simple primitives for getting computation time off the main thread using tokio:
LazyVecPromise
for a vector-backed storage which can be displayed while the task in progress.LazyValuePromise
for a single value future that can be updated during task-progress. My usage was for iterative
algorithms where the intermediate results were interesting for display.As the name suggests the two of them are lazily evaluated and nothing happens until they are polled for the first time.
For single values which are either available or not there's ImmediateValuePromise
which triggers computation
immediately.
There's not in-calculation value read out, so either it's finished or not.
After heavy usage, I currently tend to use ImmediateValuePromise
wrapped in Option
for most lazy values, too.
Especially when no intermediate values are needed, it's technically sufficient and simpler.
Also, since 0.4.0 it's very convenient to use now, see the docs for examples.
Another example usage of this crate with a small egui/eframe blog-reader can be found here
Changelog:
0.6.0
get_result
and take_result
to everything that implements DirectCacheAccess
(Thanks @tomellm)0.5.0
0.4.0:
0.3.1:
0.3.0:
into_boxed
trait in favor of supporting the regular From
trait which allows direct usage of the ?-Operator
in ImmediateValuePromise
LazyVecPromise
and LazyValuePromise
Progress
strong type which ensures values between 0.0 and 1.0