pub struct Eventual<T> { /* private fields */ }
Expand description
The entry point for getting the latest snapshots of values written by an EventualWriter. It supports multiple styles of observation.
Implementations§
Source§impl<T> Eventual<T>where
T: Value,
impl<T> Eventual<T>where
T: Value,
Sourcepub fn new() -> (EventualWriter<T>, Self)
pub fn new() -> (EventualWriter<T>, Self)
Create a reader/writer pair.
Sourcepub fn from_value(value: T) -> Self
pub fn from_value(value: T) -> Self
Create an eventual having a final value. This is useful for creating “mock” eventuals to pass into consumers.
Sourcepub fn spawn<F, Fut>(f: F) -> Self
pub fn spawn<F, Fut>(f: F) -> Self
A helper for spawning a task which writes to an eventual. These are used extensively within the library for eventuals which update continuously over time.
Sourcepub fn subscribe(&self) -> EventualReader<T>
pub fn subscribe(&self) -> EventualReader<T>
Subscribe to present and future snapshots of the value in this Eventual. Generally speaking the observations of snapshots take into account the state of the reader such that:
- The same observation is not made redundantly (same value twice in a row)
- The observations always move forward in time
- The final observation will always be eventually consistent with the final write.
Sourcepub fn value(&self) -> ValueFuture<T>
pub fn value(&self) -> ValueFuture<T>
Get a future that resolves with a snapshot of the present value of the Eventual, if any, or a future snapshot if none is available. Which snapshot is returned depends on when the Future is polled (as opposed to when the Future is created)
Sourcepub fn value_immediate(&self) -> Option<T>
pub fn value_immediate(&self) -> Option<T>
Get a snapshot of the current value of this Eventual, if any, without waiting.