From 8562dba0dc64cb978eec19cca5f9a7101444a383 Mon Sep 17 00:00:00 2001 From: Ryan Leckey Date: Sun, 10 Jan 2021 19:52:19 -0800 Subject: [PATCH] feat(core): add ConnectOptions::parse for convenience --- sqlx-core/src/blocking/options.rs | 6 ++++++ sqlx-core/src/options.rs | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/sqlx-core/src/blocking/options.rs b/sqlx-core/src/blocking/options.rs index d900a5b7..460582bd 100644 --- a/sqlx-core/src/blocking/options.rs +++ b/sqlx-core/src/blocking/options.rs @@ -11,6 +11,12 @@ where Rt: Runtime, Self::Connection: crate::Connection + Connection, { + /// Parse a connection URL into connection options. + #[inline] + fn parse(url: &str) -> crate::Result { + >::parse(url) + } + /// Establish a connection to the database. /// /// For detailed information, refer to the asynchronous version of diff --git a/sqlx-core/src/options.rs b/sqlx-core/src/options.rs index 8b7f3522..00f97e51 100644 --- a/sqlx-core/src/options.rs +++ b/sqlx-core/src/options.rs @@ -12,6 +12,11 @@ where { type Connection: Connection + ?Sized; + /// Parse a connection URL into connection options. + fn parse(url: &str) -> crate::Result { + url.parse() + } + /// Establish a new connection to the database. #[cfg(feature = "async")] fn connect(&self) -> futures_util::future::BoxFuture<'_, crate::Result>