Impl IntoConnectParams for Url
This commit is contained in:
parent
b9efef80fd
commit
0aac8225be
15
src/lib.rs
15
src/lib.rs
@ -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("/") {
|
||||
|
Loading…
Reference in New Issue
Block a user