pub fn from_url(url: &Url) -> Self {
        let protocol = url.scheme();
        let host = url.host_str().unwrap_or(DEFAULT_HOST);
        let port = url.port().unwrap_or(DEFAULT_PORT);
        let username = if url.username().is_empty() {
            DEFAULT_USERNAME
        } else {
            url.username()
        };
        let password = if let Some(passwd) = url.password() {
            passwd.to_owned()
        } else if let Ok(passwd) = env::var(ENV_ROOT_PASSWORD) {
            passwd
        } else {
            DEFAULT_PASSWORD.to_owned()
        };
        //TODO parse database name from url path segments
        let database_name = None;
        DataSource {
            protocol: protocol.to_owned(),
            host: host.to_owned(),
            port,
            database_name,
            authentication: Authentication::Basic(Credentials::new(username.to_owned(), password)),
            timeout: Duration::from_secs(DEFAULT_TIMEOUT),
        }
    }
/// Creates a new `DataSource` with the parameters taken from the given URL.
Creates a new `DataSource` with the parameters taken from the given URL.
Creates a new ` DataSource ` with the parameters taken from the given URL .
pub fn from_url(url: &Url) -> Self {
        let protocol = url.scheme();
        let host = url.host_str().unwrap_or(DEFAULT_HOST);
        let port = url.port().unwrap_or(DEFAULT_PORT);
        let username = if url.username().is_empty() {
            DEFAULT_USERNAME
        } else {
            url.username()
        };
        let password = if let Some(passwd) = url.password() {
            passwd.to_owned()
        } else if let Ok(passwd) = env::var(ENV_ROOT_PASSWORD) {
            passwd
        } else {
            DEFAULT_PASSWORD.to_owned()
        };
        //TODO parse database name from url path segments
        let database_name = None;
        DataSource {
            protocol: protocol.to_owned(),
            host: host.to_owned(),
            port,
            database_name,
            authentication: Authentication::Basic(Credentials::new(username.to_owned(), password)),
            timeout: Duration::from_secs(DEFAULT_TIMEOUT),
        }
    }
pub fn from_url ( url : & Url ) -> Self { let protocol = url . scheme ( ) ; let host = url . host_str ( ) . unwrap_or ( DEFAULT_HOST ) ; let port = url . port ( ) . unwrap_or ( DEFAULT_PORT ) ; let username = if url . username ( ) . is_empty ( ) { DEFAULT_USERNAME } else { url . username ( ) } ; let password = if let Some ( passwd ) = url . password ( ) { passwd . to_owned ( ) } else if let Ok ( passwd ) = env :: var ( ENV_ROOT_PASSWORD ) { passwd } else { DEFAULT_PASSWORD . to_owned ( ) } ; //TODO parse database name from url path segments let database_name = None ; DataSource { protocol : protocol . to_owned ( ) , host : host . to_owned ( ) , port , database_name , authentication : Authentication :: Basic ( Credentials :: new ( username . to_owned ( ) , password ) ) , timeout : Duration :: from_secs ( DEFAULT_TIMEOUT ) , } }
Creates a new `DataSource` with the parameters taken from the given URL.
Creates a new ` DataSource ` with the parameters taken from the given URL .
url
&Url
url
&Url