pub enum FutureState<T, E = String> {
Idle,
Pending,
Resolved(T),
Error(E),
}Expand description
Represents the current state of a future operation
Variants§
Idle
The future has not been started yet
Pending
The future is currently pending (actively running)
Resolved(T)
The future has resolved successfully with a value
Error(E)
The future has failed with an error
Implementations§
Source§impl<T, E> FutureState<T, E>
impl<T, E> FutureState<T, E>
Sourcepub fn is_pending(&self) -> bool
pub fn is_pending(&self) -> bool
Returns true if the future is currently pending
Sourcepub fn is_resolved(&self) -> bool
pub fn is_resolved(&self) -> bool
Returns true if the future has resolved successfully
Sourcepub fn map<U, F>(self, f: F) -> FutureState<U, E>where
F: FnOnce(T) -> U,
pub fn map<U, F>(self, f: F) -> FutureState<U, E>where
F: FnOnce(T) -> U,
Maps the resolved value to a new type
Sourcepub fn map_err<F, G>(self, f: F) -> FutureState<T, G>where
F: FnOnce(E) -> G,
pub fn map_err<F, G>(self, f: F) -> FutureState<T, G>where
F: FnOnce(E) -> G,
Maps the error to a new type
Trait Implementations§
Source§impl<T: Clone, E: Clone> Clone for FutureState<T, E>
impl<T: Clone, E: Clone> Clone for FutureState<T, E>
Source§fn clone(&self) -> FutureState<T, E>
fn clone(&self) -> FutureState<T, E>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T, E> Default for FutureState<T, E>
impl<T, E> Default for FutureState<T, E>
Source§fn default() -> FutureState<T, E>
fn default() -> FutureState<T, E>
Returns the “default value” for a type. Read more
Source§impl<T, E> From<Result<T, E>> for FutureState<T, E>
impl<T, E> From<Result<T, E>> for FutureState<T, E>
impl<T: PartialEq, E: PartialEq> StructuralPartialEq for FutureState<T, E>
Auto Trait Implementations§
impl<T, E> Freeze for FutureState<T, E>
impl<T, E> RefUnwindSafe for FutureState<T, E>where
T: RefUnwindSafe,
E: RefUnwindSafe,
impl<T, E> Send for FutureState<T, E>
impl<T, E> Sync for FutureState<T, E>
impl<T, E> Unpin for FutureState<T, E>
impl<T, E> UnsafeUnpin for FutureState<T, E>where
T: UnsafeUnpin,
E: UnsafeUnpin,
impl<T, E> UnwindSafe for FutureState<T, E>where
T: UnwindSafe,
E: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more