feat(core): add ConnectOptions::parse for convenience

This commit is contained in:
Ryan Leckey 2021-01-10 19:52:19 -08:00
parent 6c8d68e9d0
commit 8562dba0dc
No known key found for this signature in database
GPG Key ID: F8AA68C235AB08C9
2 changed files with 11 additions and 0 deletions

View File

@ -11,6 +11,12 @@ where
Rt: Runtime,
Self::Connection: crate::Connection<Rt, Options = Self> + Connection<Rt>,
{
/// Parse a connection URL into connection options.
#[inline]
fn parse(url: &str) -> crate::Result<Self> {
<Self as crate::ConnectOptions<Rt>>::parse(url)
}
/// Establish a connection to the database.
///
/// For detailed information, refer to the asynchronous version of

View File

@ -12,6 +12,11 @@ where
{
type Connection: Connection<Rt> + ?Sized;
/// Parse a connection URL into connection options.
fn parse(url: &str) -> crate::Result<Self> {
url.parse()
}
/// Establish a new connection to the database.
#[cfg(feature = "async")]
fn connect(&self) -> futures_util::future::BoxFuture<'_, crate::Result<Self::Connection>>