1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::executor::Executor;
use crate::url::Url;
use futures_core::future::BoxFuture;
use futures_util::TryFutureExt;
use std::convert::TryInto;
pub trait Connection: Executor + Send + 'static {
fn open<T>(url: T) -> BoxFuture<'static, crate::Result<Self>>
where
T: TryInto<Url, Error = crate::Error>,
Self: Sized;
fn close(self) -> BoxFuture<'static, crate::Result<()>>;
fn ping(&mut self) -> BoxFuture<crate::Result<()>> {
Box::pin(self.execute("SELECT 1", Default::default()).map_ok(|_| ()))
}
}