Last active
January 2, 2020 19:54
-
-
Save saghm/dfac14987fe01d3705e89de602f9709e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[cfg(all(feature = "tokio-runtime", feature = "async-std-runtime"))] | |
compile_error!( | |
"exactly one of the `tokio-runtime` and `async-std-runtime` features must be chosen" | |
); | |
#[cfg(all(not(feature = "tokio-runtime"), not(feature = "async-std-runtime")))] | |
compile_error!( | |
"exactly one of the `tokio-runtime` and `async-std-runtime` features must be chosen" | |
); | |
use std::future::Future; | |
use mongodb::{error::Result, options::StreamAddress}; | |
trait AsyncRuntimeHandle { | |
type AsyncRead; | |
type AsyncWrite; | |
type Mutex; | |
type MutexGuard; | |
type TcpStream: AsyncRead + AsyncWrite; | |
type ToSocketAddrs; | |
fn new() -> Self; | |
fn tcp_stream_new( | |
addresses: impl IntoIterator<Item = StreamAddress>, | |
) -> Result<Self::TcpStream>; | |
fn spawn_task<F, H, T>(future: F) -> H | |
where | |
H: Future<Output = T>, | |
F: Future<Output = T> + Send + 'static, | |
T: Send + 'static; | |
} | |
#[cfg(feature = "async-std-runtime")] | |
mod async_std; | |
#[cfg(feature = "tokio-runtime")] | |
mod tokio; | |
#[cfg(feature = "async-std-runtime")] | |
use async_std::AsyncRuntime; | |
#[cfg(feature = "tokio-runtime")] | |
use tokio::AsyncRuntime; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment