[][src]Struct rusoto_core::RusotoFuture

pub struct RusotoFuture<T, E> { /* fields omitted */ }

Future that is returned from all rusoto service APIs.

Mocking

To mock service traits, you can use RusotoFuture::from_future to create RusotoFuture instance. You can also use the From implementation on the Result value.

This example is not tested
use std::time::{Duration, Instant};
use futures::prelude::*;
use rusoto_core::RusotoFuture;
use rusoto_s3::*;
use tokio_timer::Delay;

pub struct S3Mock;

impl S3 for S3Mock {
    fn abort_multipart_upload(
        &self,
        _input: AbortMultipartUploadRequest,
    ) -> RusotoFuture<AbortMultipartUploadOutput, AbortMultipartUploadError> {
        unimplemented!();
    }

    // ...

    fn put_object(&self, input: PutObjectRequest) -> RusotoFuture<PutObjectOutput, PutObjectError> {
        if input.bucket == "foo" {
            let deadline = Instant::now() + Duration::from_secs(3);
            let output = PutObjectOutput {
                ..Default::default()
            };
            RusotoFuture::from_future(
                Delay::new(deadline)
                    .map_err(|e| PutObjectError::Unknown(e.to_string()))
                    .map(|_| output)
            )
        } else {
            Err(PutObjectError::Validation("Invalid bucket".to_string())).into()
        }
    }

    // ...
}

Methods

impl<T, E> RusotoFuture<T, E>[src]

pub fn with_timeout(self, timeout: Duration) -> Self[src]

Set the timeout on the future to the provided duration.

Unlike set_timeout this method can be easily chained:

This example is not tested
let future = s3.list_buckets()
    .with_timeout(Duration::from_secs(10));

This is only guaranteed to take effect when called before the future is polled for the first time.

pub fn set_timeout(&mut self, timeout: Duration)[src]

Set the timeout on the future to the provided duration.

This is only guaranteed to take effect when called before the future is polled for the first time.

pub fn clear_timeout(&mut self)[src]

Clear the timeout on the future.

This is only guaranteed to take effect when called before the future is polled for the first time.

pub fn sync(self) -> RusotoResult<T, E> where
    T: Send + 'static,
    E: Send + 'static, 
[src]

Blocks the current thread until the future has resolved.

This is meant to provide a simple way for non-async consumers to work with rusoto.

pub fn from_future<F>(fut: F) -> Self where
    F: IntoFuture<Item = T, Error = RusotoError<E>>,
    F::Future: Send + 'static, 
[src]

Wraps the provided future, mainly to mock the service response.

Caution

This is not intended to be used outside of the test case. In production, Box is recommended.

Trait Implementations

impl<T: Send + 'static, E: Send + 'static> From<Result<T, RusotoError<E>>> for RusotoFuture<T, E>[src]

impl<T, E> Future for RusotoFuture<T, E>[src]

type Item = T

The type of value that this future will resolved with if it is successful. Read more

type Error = RusotoError<E>

The type of error that this future will resolve with if it fails in a normal fashion. Read more

Auto Trait Implementations

impl<T, E> Send for RusotoFuture<T, E>

impl<T, E> !Sync for RusotoFuture<T, E>

impl<T, E> Unpin for RusotoFuture<T, E>

impl<T, E> !UnwindSafe for RusotoFuture<T, E>

impl<T, E> !RefUnwindSafe for RusotoFuture<T, E>

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<F> IntoFuture for F where
    F: Future
[src]

type Future = F

The future that this type can be converted into.

type Item = <F as Future>::Item

The item that the future may resolve with.

type Error = <F as Future>::Error

The error that the future may resolve with.

impl<T> FutureExt for T where
    T: Future + ?Sized
[src]

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self