Impl IntoConnectParams for Url

This commit is contained in:
Steven Fackler 2014-05-16 20:47:03 -07:00
parent b9efef80fd
commit 0aac8225be

View File

@ -248,6 +248,16 @@ impl IntoConnectParams for PostgresConnectParams {
}
impl<'a> IntoConnectParams for &'a str {
fn into_connect_params(self) -> Result<PostgresConnectParams,
PostgresConnectError> {
match url::from_str(self) {
Ok(url) => url.into_connect_params(),
Err(err) => return Err(InvalidUrl(err)),
}
}
}
impl IntoConnectParams for Url {
fn into_connect_params(self) -> Result<PostgresConnectParams,
PostgresConnectError> {
let Url {
@ -257,10 +267,7 @@ impl<'a> IntoConnectParams for &'a str {
path,
query: options,
..
} = match url::from_str(self) {
Ok(url) => url,
Err(err) => return Err(InvalidUrl(err))
};
} = self;
let maybe_path = url::decode_component(host.as_slice());
let target = if maybe_path.as_slice().starts_with("/") {