Struct eventual::Future [] [src]

#[must_use = "futures are lazy and do nothing unless consumed"]
pub struct Future<T: Send + 'static, E: Send + 'static> { /* fields omitted */ }

Methods

impl<T: Send + 'static, E: Send + 'static> Future<T, E>
[src]

Returns a future that will immediately succeed with the supplied value.

use eventual::*;

Future::<i32, ()>::of(1).and_then(|val| {
    assert!(val == 1);
    Ok(val + 1)
});

Returns a future that will immediately fail with the supplied error.

use eventual::*;

Future::error("hi").or_else(|err| {
    assert!(err == "hi");
    Ok::<(), ()>(())
}).fire();

Returns a future that won't kick off its async action until a consumer registers interest.

use eventual::*;

let post = Future::lazy(|| {
    // Imagine a call to an HTTP lib, like so:
    // http::get("/posts/1")
    Ok("HTTP response")
});

// the HTTP request has not happened yet

// later...

post.and_then(|p| {
    println!("{:?}", p);
});
// the HTTP request has now happened

Returns a new future with an identical value as the original. If the original future fails, apply the given function on the error and use the result as the error of the new future.

impl<T: Send + 'static> Future<T, ()>
[src]

Returns a Future representing the completion of the given closure. The closure will be executed on a newly spawned thread.

use eventual::*;

let future = Future::spawn(|| {
    // Represents an expensive computation
    (0..100).fold(0, |v, i| v + 1)
});

assert_eq!(100, future.await().unwrap());

impl<T: Send + 'static, E: Send + 'static> Future<Option<(T, Stream<T, E>)>, E>
[src]

An adapter that converts any future into a one-value stream

Trait Implementations

impl<T: Send + 'static, E: Send + 'static> Async for Future<T, E>
[src]

Returns true if expect will succeed.

Returns true if the async value is ready and has failed

Get the underlying value if present

Invokes the given function when the Async instance is ready to be consumed. Read more

Blocks the thread until the async value is complete and returns the result. Read more

Get the underlying value if present, panic otherwise

Invoke the callback with the resolved Async result.

Trigger the computation without waiting for the result

This method returns a future whose completion value depends on the completion value of the original future. Read more

This method returns a future whose completion value depends on the completion value of the original future. Read more

This method returns a future whose completion value depends on the completion value of the original future. Read more

This method returns a future whose completion value depends on the completion value of the original future. Read more

impl<T: Send + 'static, E: Send + 'static> Pair for Future<T, E>
[src]

impl<T: Send + 'static, E: Send + 'static> Debug for Future<T, E>
[src]

Formats the value using the given formatter.

impl<T: Send, E: Send> Drop for Future<T, E>
[src]

A method called when the value goes out of scope. Read more