eventuals

Struct Eventual

Source
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,

Source

pub fn new() -> (EventualWriter<T>, Self)

Create a reader/writer pair.

Source

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.

Source

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.

Source

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.
Source

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)

Source

pub fn value_immediate(&self) -> Option<T>

Get a snapshot of the current value of this Eventual, if any, without waiting.

Trait Implementations§

Source§

impl<T> Clone for Eventual<T>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> IntoReader for &Eventual<T>
where T: Value,

Source§

impl<T> IntoReader for Eventual<T>
where T: Value,

Auto Trait Implementations§

§

impl<T> Freeze for Eventual<T>

§

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§

Source§

impl<T> Any for T
where T: "static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<E> EventualExt for E
where E: IntoReader,

Source§

fn map<F, O, Fut>(self, f: F) -> Eventual<O>
where F: "static + Send + FnMut(Self::Output) -> Fut, O: Value, Fut: Send + Future<Output = O>,

Source§

fn throttle(self, duration: Duration) -> Eventual<Self::Output>

Source§

fn pipe<F>(self, f: F) -> PipeHandle
where F: "static + Send + FnMut(Self::Output),

Source§

fn pipe_async<F, Fut>(self, f: F) -> PipeHandle
where F: "static + Send + FnMut(Self::Output) -> Fut, Fut: Send + Future<Output = ()>,

Source§

fn map_with_retry<F, E, Ok, Err, Fut, FutE>( self, f: F, on_err: E, ) -> Eventual<Ok>
where F: "static + Send + FnMut(Self::Output) -> Fut, E: "static + Send + Sync + FnMut(Err) -> FutE, Ok: Value, Err: Value, Fut: Send + Future<Output = Result<Ok, Err>>, FutE: Send + Future<Output = ()>,

Source§

fn init_with(self, value: Self::Output) -> Eventual<Self::Output>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<E, Ok, Err> TryEventualExt<Ok, Err> for E
where E: IntoReader<Output = Result<Ok, Err>>, Ok: Value, Err: Value,

Source§

fn handle_errors<F>(self, f: F) -> Eventual<Ok>
where F: "static + Send + FnMut(Err),

👎Deprecated: Not deterministic. This is a special case of filter. Retry should be better
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.