[][src]Struct egg_mode::media::UploadFuture

#[must_use = "futures do nothing unless polled"]
pub struct UploadFuture<'a> { /* fields omitted */ }

A Future that represents an in-progress media upload.

This struct is obtained from an UploadBuilder. See those docs for specifics on creating one, and the module docs for more information on how to upload media in general.

Errors

Because UploadFuture represents a potentially long-running upload, it's set up so that if it fails at any point in the process, it will retry its last action upon its next poll. This also includes keeping its place in terms of how many chunks it's uploaded so far.

There's a complicating factor for this, though: Twitter only allows an upload session to be active for a limited time. UploadFuture keeps track of when the session expires, and restarts the upload if it's polled from an error state when the time has elapsed. (Note that timeout is checked only in case of errors. If the last action was a successful one, it will send off the next action to Twitter, likely receiving an error for that, after which it will restart the upload.) This timeout is reflected in the UploadError it returns in any error case.

To allow for better handling of individual errors and better retry logic, the UploadError also includes a mention of which state the UploadFuture was in before encountering the error. If the Future was attempting to upload an individual chunk, or finalizing the upload session, and the Future encountered a network error, it should be safe to retry the Future if network conditions improve before the timeout elapses. (The precise Error which was encountered is also included in the returned UploadError.)

(Proper mechanisms for actually integrating retry logic into your application is beyond the scope of this library. There are dedicated libraries for retry logic, or you can use the built-in shared function on all Futuress to get a cloneable handle to a Future so you can keep a handle to send back into an executor. This is all just to say that an UploadFuture is not invalidated when it returns an Err from poll.)

Lifetimes

The lifetime parameter to UploadFuture is based on the data (and alt text) given to the UploadBuilder that created it. If an owned Vec (and either no alt text or an owned String) was given to the UploadBuilder, this future will have a 'static lifetime.

Trait Implementations

impl<'a> Future for UploadFuture<'a>[src]

type Output = Result<MediaHandle, UploadError>

The type of value produced on completion.

Auto Trait Implementations

impl<'a> !RefUnwindSafe for UploadFuture<'a>

impl<'a> !Send for UploadFuture<'a>

impl<'a> !Sync for UploadFuture<'a>

impl<'a> Unpin for UploadFuture<'a>

impl<'a> !UnwindSafe for UploadFuture<'a>

Blanket Implementations

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

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

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

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

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

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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<F, T, E> TryFuture for F where
    F: Future<Output = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<Fut> TryFutureExt for Fut where
    Fut: TryFuture + ?Sized
[src]

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<V, T> VZip<V> for T where
    V: MultiLane<T>,