Crate lazy_async_promise
source ·Expand description
Primitives for combining tokio and immediate mode guis
List of primitives
The following primitives are implemented:
ImmediateValuePromise
: An immediately updating async-enabled single value promiseProgressTrackedImValProm
: A progress/status emitting enhanced wrapper forImmediateValuePromise
LazyVecPromise
: A lazily evaluated, partially readable and async-enabled vector-backed promiseLazyValuePromise
: A lazily evaluated and async-enabled single value promise
See these items for their respective documentation.
What to use
A general usage guide would be:
- You just want one value when ready? Use:
ImmediateValuePromise
(for laziness wrap inOption
) - If you need status update support for that, use
ProgressTrackedImValProm
- You want several items of the same kind / streamed? Use:
LazyVecPromise
- You want one item when ready and need lazy evaluation or have intermediate results? Use:
LazyValuePromise
Modules
- Use this to get all macros
Macros
- Send new data via the sender
- Setting the given progress using a given sender.
- Set state to
DataState::UpToDate
- Setting the given progress using a given sender.
- Error checking in async updater functions is tedious - this helps out by resolving results and sending errors on error. Result will be unwrapped if no error occurs.
Structs
- Strong type to keep the boxed error. You can just deref it to get the inside box.
- A promise which can be easily created and stored.
- A single lazy-async updated value
- A lazy, async and partially readable vector promise
- a f64 type which is constrained to the range of 0.0 and 1.0
- A progress and status enabling wrapper for
ImmediateValuePromise
- A status update struct containing the issue-date, progress and a message You can use any struct that can be transferred via tokio mpsc channels.
Enums
- Represents a processing state.
- The return state of a
ImmediateValuePromise
, contains the error, the value or that it is still updating - The message-type to send from the updater to the main thread. There’s only two variants,
NewData
which allows to send new data orStateChange
which allows to signal readiness or error.
Traits
- Trait for directly accessing the cache underneath any promise
- Maybe this should rather be called “LazyUpdating”? Implementors can react to polling by queueing an update if needed. Update should force an update.
Type Definitions
- Type alias for futures with BoxedSendError