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
sourceimpl<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 where
F: 'static + Send + FnOnce(EventualWriter<T>) -> Fut,
Fut: Future<Output = Result<Never, Closed>> + Send,
pub fn spawn<F, Fut>(f: F) -> Self where
F: 'static + Send + FnOnce(EventualWriter<T>) -> Fut,
Fut: Future<Output = Result<Never, Closed>> + Send,
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.
Trait Implementations
sourceimpl<T> IntoReader for &Eventual<T> where
T: Value,
impl<T> IntoReader for &Eventual<T> where
T: Value,
type Output = T
fn into_reader(self) -> EventualReader<Self::Output>
sourceimpl<T> IntoReader for Eventual<T> where
T: Value,
impl<T> IntoReader for Eventual<T> where
T: Value,
type Output = T
fn into_reader(self) -> EventualReader<Self::Output>
Auto Trait Implementations
impl<T> !RefUnwindSafe for Eventual<T>
impl<T> Send for Eventual<T> where
T: Send,
impl<T> Sync for Eventual<T> where
T: Send,
impl<T> Unpin for Eventual<T>
impl<T> !UnwindSafe for Eventual<T>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more