// open a wallet based on wallet storage strategy
open a wallet based on wallet storage strategy
open a wallet based on wallet storage strategy
fn open_wallet(&self, id: &str, config: &PostgresConfig, credentials: &PostgresCredentials) -> Result<Box<PostgresStorage>, WalletStorageError> {
        let url = PostgresStorageType::_postgres_url(id, &config, &credentials);
        // don't need a connection, but connect just to verify we can
        let _conn = match postgres::Connection::connect(&url[..], config.tls()) {
            Ok(conn) => conn,
            Err(_) => return Err(WalletStorageError::NotFound)
        };
        // TODO close _conn
        let manager = match PostgresConnectionManager::new(&url[..], config.r2d2_tls()) {
            Ok(manager) => manager,
            Err(_) => return Err(WalletStorageError::NotFound)
        };
        let pool = match r2d2::Pool::builder()
            .min_idle(Some(config.min_idle_count()))
            .max_size(config.max_connections())
            .idle_timeout(Some(Duration::new(config.connection_timeout(), 0)))
            .build(manager) {
            Ok(pool) => pool,
            Err(_) => return Err(WalletStorageError::NotFound)
        };
        Ok(Box::new(PostgresStorage {
            pool: pool,
            wallet_id: id.to_string(),
        }))
    }
fn open_wallet ( & self , id : & str , config : & PostgresConfig , credentials : & PostgresCredentials ) -> Result < Box < PostgresStorage > , WalletStorageError > { let url = PostgresStorageType :: _postgres_url ( id , & config , & credentials ) ; // don't need a connection, but connect just to verify we can let _conn = match postgres :: Connection :: connect ( & url [ .. ] , config . tls ( ) ) { Ok ( conn ) => conn , Err ( _ ) => return Err ( WalletStorageError :: NotFound ) } ; // TODO close _conn let manager = match PostgresConnectionManager :: new ( & url [ .. ] , config . r2d2_tls ( ) ) { Ok ( manager ) => manager , Err ( _ ) => return Err ( WalletStorageError :: NotFound ) } ; let pool = match r2d2 :: Pool :: builder ( ) . min_idle ( Some ( config . min_idle_count ( ) ) ) . max_size ( config . max_connections ( ) ) . idle_timeout ( Some ( Duration :: new ( config . connection_timeout ( ) , 0 ) ) ) . build ( manager ) { Ok ( pool ) => pool , Err ( _ ) => return Err ( WalletStorageError :: NotFound ) } ; Ok ( Box :: new ( PostgresStorage { pool : pool , wallet_id : id . to_string ( ) , } ) ) }
open a wallet based on wallet storage strategy
open a wallet based on wallet storage strategy
&self
id
&str
config
&PostgresConfig
credentials
&PostgresCredentials