binary-options-tools-core 0.1.5

The core of the `binary-options-tools` crate and the python library `BinaryOptionsToolsV2`.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::time::Duration;

use crate::error::{BinaryOptionsResult, BinaryOptionsToolsError};
use core::future::Future;

pub async fn timeout<F, T>(duration: Duration, future: F, task: String) -> BinaryOptionsResult<T>
where
    F: Future<Output = BinaryOptionsResult<T>>,
{
    let res = tokio::select! {
        _ = tokio::time::sleep(duration) => Err(BinaryOptionsToolsError::TimeoutError { task, duration }),
        result = future => match result {
            Ok(value) => Ok(value),
            Err(err) => Err(err),
        },
    };
    res
}