pub struct Eventual<T> { /* private fields */ }std only.Expand description
Represents a computation result that may eventually appear. Semantically equivalent to a Future, but doesn’t necessarily require an Async ecosystem around it.
Implementations§
Source§impl<T> Eventual<T>
impl<T> Eventual<T>
Sourcepub fn new_loaded(val: T) -> Self
pub fn new_loaded(val: T) -> Self
Creates a new already completed task with the specified value
Sourcepub fn set(&self, val: Option<T>)
pub fn set(&self, val: Option<T>)
Sets the completion status of this task. Some becomes EventualStatus::Complete,
None becomes EventualStatus::CompleteEmpty
Sets the completed status to EventualStatus::Complete using the specified value.
Sourcepub fn get(&self) -> EventualStatus<Arc<T>>
pub fn get(&self) -> EventualStatus<Arc<T>>
Gets the current status of this task. This is the primary method to poll over. See the module docs for an example.
Sourcepub fn take(&self) -> Option<Arc<T>>
pub fn take(&self) -> Option<Arc<T>>
If the task is complete, take the Arc out of storage. Further calls to get or take will
return None
Sourcepub fn start(&self)
pub fn start(&self)
Move the task state from NotReady or CompleteEmpty to Running. Does nothing if already
complete.
Sourcepub fn is_ready(&self) -> bool
pub fn is_ready(&self) -> bool
True if this task is complete with EventualStatus::CompleteEmpty or EventualStatus::Complete
Sourcepub fn is_pending(&self) -> bool
pub fn is_pending(&self) -> bool
True if this task has status [EventualStatus::NotRunning] or EventualStatus::Running
Sourcepub fn block_until_ready(&self) -> EventualStatus<Arc<T>>
pub fn block_until_ready(&self) -> EventualStatus<Arc<T>>
Blocks until this task transitions into EventualStatus::CompleteEmpty or
EventualStatus::Complete. If already in this state, quick returns.