sqlx_xugu/options/
connect.rs

1use crate::connection::XuguConnection;
2use crate::XuguConnectOptions;
3use futures_core::future::BoxFuture;
4use log::LevelFilter;
5use sqlx_core::connection::ConnectOptions;
6use sqlx_core::{Error, Url};
7use std::time::Duration;
8
9impl ConnectOptions for XuguConnectOptions {
10    type Connection = XuguConnection;
11
12    fn from_url(url: &Url) -> Result<Self, Error> {
13        Self::parse_from_url(url)
14    }
15
16    fn to_url_lossy(&self) -> Url {
17        self.build_url()
18    }
19
20    fn connect(&self) -> BoxFuture<'_, Result<Self::Connection, Error>>
21    where
22        Self::Connection: Sized,
23    {
24        Box::pin(async {
25            let conn = XuguConnection::establish(self).await?;
26            Ok(conn)
27        })
28    }
29
30    fn log_statements(mut self, level: LevelFilter) -> Self {
31        self.log_settings.log_statements(level);
32        self
33    }
34
35    fn log_slow_statements(mut self, level: LevelFilter, duration: Duration) -> Self {
36        self.log_settings.log_slow_statements(level, duration);
37        self
38    }
39}