arcium-primitives 0.4.2

Arcium primitives
Documentation
use std::future::Future;

/// A convenience for futures that return `Result` values that includes
/// a variety of adapters tailored to such futures. The original futures::TryFuture
/// trait does not require the future output to be a `Result` with corresponding
/// types, which makes it less useful in many cases.
///
/// Additionally, we bind this future to be `Send` and `Sync` to ensure it can be used
/// in a multi-threaded context.
pub trait TryFuture: Future<Output = Result<Self::Ok, Self::Error>> + Send {
    /// The type of successful values yielded by this future
    type Ok;

    /// The type of failures yielded by this future
    type Error;
}

impl<F, T, E> TryFuture for F
where
    F: ?Sized + Future<Output = Result<T, E>> + Send,
{
    type Ok = T;
    type Error = E;
}

/// A helper trait to designate a future that is `Send` and `'static`, meaning it does not depend on
/// any other lifetime parameters that might otherwise be automatically captured by the compiler.
pub trait StaticFuture<Output>: Future<Output = Output> + Send + 'static {}

impl<T: Future + Send + 'static> StaticFuture<T::Output> for T {}