[−][src]Struct tiny_future::Future
A future result with an optional shared state
Implementations
impl<T, U> Future<T, U>
[src]
pub fn with_state(shared_state: U) -> Self
[src]
Creates a new Future<T, U>
with shared_state
as shared-state
pub fn set(&self, result: T) -> Result<(), State>
[src]
Sets the future
pub fn cancel(&self)
[src]
Cancels (poisons) the future
This is useful to indicate that the future is obsolete and should not be set
anymore
pub fn get_state(&self) -> State
[src]
Returns the future's state
pub fn is_waiting(&self) -> bool
[src]
Checks if the future is still waiting or has been set/canceled
pub fn try_get(&self) -> Result<T, State>
[src]
Tries to get the future's result
If the future is ready, it is consumed and T
is returned;
if the future is not ready, Error::InvalidState(State)
is returned
pub fn try_get_timeout(&self, timeout: Duration) -> Result<T, State>
[src]
Tries to get the future's result
If the future is ready or or becomes ready before the timeout occurres, it is consumed
and T
is returned; if the future is not ready, Error::InvalidState(State)
is returned
pub fn get(&self) -> Result<T, State>
[src]
Gets the future's result
Warning: this function will block until a result becomes available
pub fn get_shared_state(&self) -> U where
U: Clone,
[src]
U: Clone,
Get a clone of the current shared state
pub fn set_shared_state(&self, shared_state: U)
[src]
Replace the current shared state
pub fn access_shared_state<F: FnOnce(&mut U)>(&self, modifier: F)
[src]
Provides exclusive access to the shared state within modifier
until modifier
returns
pub fn access_shared_state_param<V, F: FnOnce(&mut U, V)>(
&self,
modifier: F,
parameter: V
)
[src]
&self,
modifier: F,
parameter: V
)
Provides exclusive access to the shared state within modifier
until modifier
returns
pub fn detach(&self)
[src]
Detaches the future so it won't be canceled if there is only one instance left
Useful if you either don't want that your future is ever canceled or if there's always only one instance (e.g. if you wrap it into a reference-counting container)
impl<T> Future<T, ()>
[src]
Trait Implementations
impl<T, U> Clone for Future<T, U>
[src]
pub fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T, U> Default for Future<T, U> where
U: Default,
[src]
U: Default,
impl<T, U> Drop for Future<T, U>
[src]
impl<T: Send, U: Send> Send for Future<T, U>
[src]
impl<T, U> Sync for Future<T, U>
[src]
Auto Trait Implementations
impl<T, U = ()> !RefUnwindSafe for Future<T, U>
impl<T, U> Unpin for Future<T, U>
impl<T, U = ()> !UnwindSafe for Future<T, U>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,