fn init_storage(&self, config: Option<&str>, credentials: Option<&str>) -> Result<(), WalletStorageError> {
        let config = config
            .map(serde_json::from_str::<PostgresConfig>)
            .map_or(Ok(None), |v| v.map(Some))
            .map_err(|err| CommonError::InvalidStructure(format!("Cannot deserialize config: {:?}", err)))?;
        let credentials = credentials
            .map(serde_json::from_str::<PostgresCredentials>)
            .map_or(Ok(None), |v| v.map(Some))
            .map_err(|err| CommonError::InvalidStructure(format!("Cannot deserialize credentials: {:?}", err)))?;

        let config = match config {
            Some(config) => config,
            None => return Err(WalletStorageError::ConfigError)
        };
        let credentials = match credentials {
            Some(credentials) => credentials,
            None => return Err(WalletStorageError::ConfigError)
        };

        match config.wallet_scheme {
            Some(scheme) => match scheme {
                WalletScheme::DatabasePerWallet => {
                    debug!("Initialising postgresql using DatabasePerWallet strategy.");
                    set_wallet_strategy(Box::new(DatabasePerWalletStrategy {}));
                }
                WalletScheme::MultiWalletSingleTable => {
                    debug!("Initialising postgresql using MultiWalletSingleTable strategy.");
                    set_wallet_strategy(Box::new(MultiWalletSingleTableStrategy {}));
                }
                WalletScheme::MultiWalletMultiTable => {
                    debug!("Initialising postgresql using MultiWalletMultiTable strategy.");
                    set_wallet_strategy(Box::new(MultiWalletMultiTableStrategy {}));
                }
                WalletScheme::MultiWalletSingleTableSharedPool => {
                    if (&config as &PostgresConfig).min_idle_count() > 0 {
                        // TODO: This restriction can be removed  but we would have make sure that
                        // we don't attempt to construct connection pool before we have constructed
                        // database. Currently we are creating database (if doesn't exists) in
                        // strategy.init_storage(&config, &credentials) at the end of this function.
                        error!("MultiWalletSingleTableSharedPool does not support 'min_idle_count' \
                               (or its deprecated equivalent 'min_idle_time') to be > 0");
                        return Err(ConfigError)
                    }
                    debug!("Initialising postgresql using MultiWalletSingleTableSharedPool strategy.");
                    let pool = create_connection_pool(&config, &credentials)?;
                    set_wallet_strategy(Box::new(MultiWalletSingleTableStrategySharedPool { pool }));
                }
            },
            None => {
                debug!("Initialising postgresql but strategy was not specified in storage \
                        configuration. Using DatabasePerWallet strategy by default.");
                set_wallet_strategy(Box::new(DatabasePerWalletStrategy {}));
            }
        };
        let r1 = SELECTED_STRATEGY.read().unwrap();
        r1.as_ref().init_storage(&config, &credentials)
    }
///
/// Initializes the wallets database and creates the necessary tables for all wallets
/// This needs to be called once at the very beginning, I'm not entirely sure the best way to enforce it
///
/// # Arguments
///
///  * `storage_config` - config containing the location of Postgres DB files
///  * `storage_credentials` - DB credentials
///
/// # Returns
///
/// Result that can be either:
///
///  * `()`
///  * `WalletStorageError`
///
/// # Errors
///
/// Any of the following `WalletStorageError` type_ of errors can be throw by this method:
///
///  * `WalletStorageError::NotFound` - File with the provided id not found
///  * `IOError(..)` - Deletion of the file form the file-system failed
///
Initializes the wallets database and creates the necessary tables for all wallets
This needs to be called once at the very beginning, I'm not entirely sure the best way to enforce it
Initializes the wallets database and creates the necessary tables for all wallets This needs to be called once at the very beginning I ' m not entirely sure the best way to enforce it
fn init_storage(&self, config: Option<&str>, credentials: Option<&str>) -> Result<(), WalletStorageError> {
        let config = config
            .map(serde_json::from_str::<PostgresConfig>)
            .map_or(Ok(None), |v| v.map(Some))
            .map_err(|err| CommonError::InvalidStructure(format!("Cannot deserialize config: {:?}", err)))?;
        let credentials = credentials
            .map(serde_json::from_str::<PostgresCredentials>)
            .map_or(Ok(None), |v| v.map(Some))
            .map_err(|err| CommonError::InvalidStructure(format!("Cannot deserialize credentials: {:?}", err)))?;
        let config = match config {
            Some(config) => config,
            None => return Err(WalletStorageError::ConfigError)
        };
        let credentials = match credentials {
            Some(credentials) => credentials,
            None => return Err(WalletStorageError::ConfigError)
        };
        match config.wallet_scheme {
            Some(scheme) => match scheme {
                WalletScheme::DatabasePerWallet => {
                    debug!("Initialising postgresql using DatabasePerWallet strategy.");
                    set_wallet_strategy(Box::new(DatabasePerWalletStrategy {}));
                }
                WalletScheme::MultiWalletSingleTable => {
                    debug!("Initialising postgresql using MultiWalletSingleTable strategy.");
                    set_wallet_strategy(Box::new(MultiWalletSingleTableStrategy {}));
                }
                WalletScheme::MultiWalletMultiTable => {
                    debug!("Initialising postgresql using MultiWalletMultiTable strategy.");
                    set_wallet_strategy(Box::new(MultiWalletMultiTableStrategy {}));
                }
                WalletScheme::MultiWalletSingleTableSharedPool => {
                    if (&config as &PostgresConfig).min_idle_count() > 0 {
                        // TODO: This restriction can be removed  but we would have make sure that
                        // we don't attempt to construct connection pool before we have constructed
                        // database. Currently we are creating database (if doesn't exists) in
                        // strategy.init_storage(&config, &credentials) at the end of this function.
                        error!("MultiWalletSingleTableSharedPool does not support 'min_idle_count' \
                               (or its deprecated equivalent 'min_idle_time') to be > 0");
                        return Err(ConfigError)
                    }
                    debug!("Initialising postgresql using MultiWalletSingleTableSharedPool strategy.");
                    let pool = create_connection_pool(&config, &credentials)?;
                    set_wallet_strategy(Box::new(MultiWalletSingleTableStrategySharedPool { pool }));
                }
            },
            None => {
                debug!("Initialising postgresql but strategy was not specified in storage \
                        configuration. Using DatabasePerWallet strategy by default.");
                set_wallet_strategy(Box::new(DatabasePerWalletStrategy {}));
            }
        };
        let r1 = SELECTED_STRATEGY.read().unwrap();
        r1.as_ref().init_storage(&config, &credentials)
    }
fn init_storage ( & self , config : Option < & str > , credentials : Option < & str > ) -> Result < ( ) , WalletStorageError > { let config = config . map ( serde_json :: from_str :: < PostgresConfig > ) . map_or ( Ok ( None ) , | v | v . map ( Some ) ) . map_err ( | err | CommonError :: InvalidStructure ( format ! ( " " err ) ) ) ? ; let credentials = credentials . map ( serde_json :: from_str :: < PostgresCredentials > ) . map_or ( Ok ( None ) , | v | v . map ( Some ) ) . map_err ( | err | CommonError :: InvalidStructure ( format ! ( " " err ) ) ) ? ; let config = match config { Some ( config ) => config , None => return Err ( WalletStorageError :: ConfigError ) } ; let credentials = match credentials { Some ( credentials ) => credentials , None => return Err ( WalletStorageError :: ConfigError ) } ; match config . wallet_scheme { Some ( scheme ) => match scheme { WalletScheme :: DatabasePerWallet => { debug ! ( " " ) ; set_wallet_strategy ( Box :: new ( DatabasePerWalletStrategy { } ) ) ; } WalletScheme :: MultiWalletSingleTable => { debug ! ( " " ) ; set_wallet_strategy ( Box :: new ( MultiWalletSingleTableStrategy { } ) ) ; } WalletScheme :: MultiWalletMultiTable => { debug ! ( " " ) ; set_wallet_strategy ( Box :: new ( MultiWalletMultiTableStrategy { } ) ) ; } WalletScheme :: MultiWalletSingleTableSharedPool => { if ( & config as & PostgresConfig ) . min_idle_count ( ) > 0 { // TODO: This restriction can be removed  but we would have make sure that // we don't attempt to construct connection pool before we have constructed // database. Currently we are creating database (if doesn't exists) in // strategy.init_storage(&config, &credentials) at the end of this function. error ! ( " \
 " ) ; return Err ( ConfigError ) } debug ! ( " " ) ; let pool = create_connection_pool ( & config , & credentials ) ? ; set_wallet_strategy ( Box :: new ( MultiWalletSingleTableStrategySharedPool { pool } ) ) ; } } , None => { debug ! ( " \
 " ) ; set_wallet_strategy ( Box :: new ( DatabasePerWalletStrategy { } ) ) ; } } ; let r1 = SELECTED_STRATEGY . read ( ) . unwrap ( ) ; r1 . as_ref ( ) . init_storage ( & config , & credentials ) }
Initializes the wallets database and creates the necessary tables for all wallets
This needs to be called once at the very beginning, I'm not entirely sure the best way to enforce it
Initializes the wallets database and creates the necessary tables for all wallets This needs to be called once at the very beginning I ' m not entirely sure the best way to enforce it
&self
config
Option<&str>
credentials
Option<&str>
Result that can be either.

`()`
`WalletStorageError`
Result that can be either . ` () ` ` WalletStorageError `
&self
config
Option<&str>
credentials
Option<&str>
errors
Any of the following `WalletStorageError` type_ of errors can be throw by this method.

`WalletStorageError::NotFound` - File with the provided id not found
`IOError(..)` - Deletion of the file form the file-system failed
Any of the following ` WalletStorageError ` type_ of errors can be throw by this method . ` WalletStorageError :: NotFound ` - File with the provided id not found ` IOError ( .. ) ` - Deletion of the file form the file - system failed