///
/// Creates the SQLite DB file with the provided name in the path specified in the config file,
/// and initializes the encryption keys needed for encryption and decryption of data.
///
/// # Arguments
///
///  * `id` - name of the SQLite DB file
///  * `config` - config containing the location of SQLite DB files
///  * `credentials` - DB credentials
///  * `metadata` - encryption keys that need to be stored in the newly created DB
///
/// # Returns
///
/// Result that can be either:
///
///  * `()`
///  * `IndyError`
///
/// # Errors
///
/// Any of the following `IndyError` type_ of errors can be throw by this method:
///
///  * `AlreadyExists` - File with a given name already exists on the path
///  * `IOError("IO error during storage operation:...")` - Connection to the DB failed
///  * `IOError("Error occurred while creating wallet file:..)"` - Creation of schema failed
///  * `IOError("Error occurred while inserting the keys...")` - Insertion of keys failed
///  * `IOError(..)` - Deletion of the file form the file-system failed
///
Creates the SQLite DB file with the provided name in the path specified in the config file,
and initializes the encryption keys needed for encryption and decryption of data.
Creates the SQLite DB file with the provided name in the path specified in the config file and initializes the encryption keys needed for encryption and decryption of data .
fn create_storage(&self, id: &str, config: Option<&str>, _credentials: Option<&str>, metadata: &[u8]) -> IndyResult<()> {
        let config = config
            .map(serde_json::from_str::<Config>)
            .map_or(Ok(None), |v| v.map(Some))
            .to_indy(IndyErrorKind::InvalidStructure, "Malformed config json")?;
        let db_path = SQLiteStorageType::_db_path(id, config.as_ref());
        if db_path.exists() {
            return Err(err_msg(IndyErrorKind::WalletAlreadyExists, format!("Wallet database file already exists: {:?}", db_path)));
        }
        fs::DirBuilder::new()
            .recursive(true)
            .create(db_path.parent().unwrap())?;
        let conn = rusqlite::Connection::open(db_path.as_path())?;
        match conn.execute_batch(_CREATE_SCHEMA) {
            Ok(_) => match conn.execute("INSERT OR REPLACE INTO metadata(value) VALUES(?1)", &[&metadata.to_vec()]) {
                Ok(_) => Ok(()),
                Err(error) => {
                    std::fs::remove_file(db_path)?;
                    Err(error.into())
                }
            },
            Err(error) => {
                std::fs::remove_file(db_path)?;
                Err(error.into())
            }
        }
    }
fn create_storage ( & self , id : & str , config : Option < & str > , _credentials : Option < & str > , metadata : & [ u8 ] ) -> IndyResult < ( ) > { let config = config . map ( serde_json :: from_str :: < Config > ) . map_or ( Ok ( None ) , | v | v . map ( Some ) ) . to_indy ( IndyErrorKind :: InvalidStructure , " " ) ? ; let db_path = SQLiteStorageType :: _db_path ( id , config . as_ref ( ) ) ; if db_path . exists ( ) { return Err ( err_msg ( IndyErrorKind :: WalletAlreadyExists , format ! ( " " db_path ) ) ) ; } fs :: DirBuilder :: new ( ) . recursive ( true ) . create ( db_path . parent ( ) . unwrap ( ) ) ? ; let conn = rusqlite :: Connection :: open ( db_path . as_path ( ) ) ? ; match conn . execute_batch ( _CREATE_SCHEMA ) { Ok ( _ ) => match conn . execute ( " " , & [ & metadata . to_vec ( ) ] ) { Ok ( _ ) => Ok ( ( ) ) , Err ( error ) => { std :: fs :: remove_file ( db_path ) ? ; Err ( error . into ( ) ) } } , Err ( error ) => { std :: fs :: remove_file ( db_path ) ? ; Err ( error . into ( ) ) } } }
Creates the SQLite DB file with the provided name in the path specified in the config file,
and initializes the encryption keys needed for encryption and decryption of data.
Creates the SQLite DB file with the provided name in the path specified in the config file and initializes the encryption keys needed for encryption and decryption of data .
Result that can be either.


Result that can be either .
&self
id
&str
config
Option<&str>
_credentials
Option<&str>
metadata
&[u8]
errors
Any of the following `IndyError` type_ of errors can be throw by this method.

`AlreadyExists` - File with a given name already exists on the path
`IOError("IO error during storage operation:...")` - Connection to the DB failed
`IOError("Error occurred while creating wallet file:..)"` - Creation of schema failed
`IOError("Error occurred while inserting the keys...")` - Insertion of keys failed
`IOError(..)` - Deletion of the file form the file-system failed
Any of the following ` IndyError ` type_ of errors can be throw by this method . ` AlreadyExists ` - File with a given name already exists on the path ` IOError ( " IO error during storage operation : ... " ) ` - Connection to the DB failed ` IOError ( " Error occurred while creating wallet file : .. ) " ` - Creation of schema failed ` IOError ( " Error occurred while inserting the keys ... " ) ` - Insertion of keys failed ` IOError ( .. ) ` - Deletion of the file form the file - system failed