fn add(&self, type_: &[u8], id: &[u8], value: &EncryptedValue, tags: &[Tag]) -> IndyResult<()> {
        let tx: transaction::Transaction = transaction::Transaction::new(&self.conn, rusqlite::TransactionBehavior::Deferred)?;
        let res = tx.prepare_cached("INSERT INTO items (type, name, value, key) VALUES (?1, ?2, ?3, ?4)")?
            .insert(&[&type_.to_vec(), &id.to_vec(), &value.data, &value.key]);

        let id = match res {
            Ok(entity) => entity,
            Err(err) => return Err(IndyError::from(err))
        };

        if !tags.is_empty() {
            let mut stmt_e = tx.prepare_cached("INSERT INTO tags_encrypted (item_id, name, value) VALUES (?1, ?2, ?3)")?;
            let mut stmt_p = tx.prepare_cached("INSERT INTO tags_plaintext (item_id, name, value) VALUES (?1, ?2, ?3)")?;

            for tag in tags {
                match *tag {
                    Tag::Encrypted(ref tag_name, ref tag_data) => stmt_e.execute(rusqlite::params![&id, tag_name, tag_data])?,
                    Tag::PlainText(ref tag_name, ref tag_data) => stmt_p.execute(rusqlite::params![&id, tag_name, tag_data])?
                };
            }
        }

        tx.commit()?;
        Ok(())
    }
///
/// inserts value and tags into storage.
/// Returns Result with () on success or
/// Result with IndyError in case of failure.
///
///
/// # Arguments
///
///  * `type_` - type of the item in storage
///  * `id` - id of the item in storage
///  * `value` - value of the item in storage
///  * `value_key` - key used to encrypt the value
///  * `tags` - tags assigned to the value
///
/// # Returns
///
/// Result that can be either:
///
///  * `()`
///  * `IndyError`
///
/// # Errors
///
/// Any of the following `IndyError` class of errors can be throw by this method:
///
///  * `IndyError::Closed` - Storage is closed
///  * `IndyError::ItemAlreadyExists` - Item is already present in database
///  * `IOError("IO error during storage operation:...")` - Failed connection or SQL query
///
inserts value and tags into storage.
Returns Result with () on success or
Result with IndyError in case of failure.
inserts value and tags into storage . Returns Result with () on success or Result with IndyError in case of failure .
fn add(&self, type_: &[u8], id: &[u8], value: &EncryptedValue, tags: &[Tag]) -> IndyResult<()> {
        let tx: transaction::Transaction = transaction::Transaction::new(&self.conn, rusqlite::TransactionBehavior::Deferred)?;
        let res = tx.prepare_cached("INSERT INTO items (type, name, value, key) VALUES (?1, ?2, ?3, ?4)")?
            .insert(&[&type_.to_vec(), &id.to_vec(), &value.data, &value.key]);
        let id = match res {
            Ok(entity) => entity,
            Err(err) => return Err(IndyError::from(err))
        };
        if !tags.is_empty() {
            let mut stmt_e = tx.prepare_cached("INSERT INTO tags_encrypted (item_id, name, value) VALUES (?1, ?2, ?3)")?;
            let mut stmt_p = tx.prepare_cached("INSERT INTO tags_plaintext (item_id, name, value) VALUES (?1, ?2, ?3)")?;
            for tag in tags {
                match *tag {
                    Tag::Encrypted(ref tag_name, ref tag_data) => stmt_e.execute(rusqlite::params![&id, tag_name, tag_data])?,
                    Tag::PlainText(ref tag_name, ref tag_data) => stmt_p.execute(rusqlite::params![&id, tag_name, tag_data])?
                };
            }
        }
        tx.commit()?;
        Ok(())
    }
fn add ( & self , type_ : & [ u8 ] , id : & [ u8 ] , value : & EncryptedValue , tags : & [ Tag ] ) -> IndyResult < ( ) > { let tx : transaction :: Transaction = transaction :: Transaction :: new ( & self . conn , rusqlite :: TransactionBehavior :: Deferred ) ? ; let res = tx . prepare_cached ( " " ) ? . insert ( & [ & type_ . to_vec ( ) , & id . to_vec ( ) , & value . data , & value . key ] ) ; let id = match res { Ok ( entity ) => entity , Err ( err ) => return Err ( IndyError :: from ( err ) ) } ; if ! tags . is_empty ( ) { let mut stmt_e = tx . prepare_cached ( " " ) ? ; let mut stmt_p = tx . prepare_cached ( " " ) ? ; for tag in tags { match * tag { Tag :: Encrypted ( ref tag_name , ref tag_data ) => stmt_e . execute ( rusqlite :: params ! [ id tag_name tag_data ] ) ? , Tag :: PlainText ( ref tag_name , ref tag_data ) => stmt_p . execute ( rusqlite :: params ! [ id tag_name tag_data ] ) ? } ; } } tx . commit ( ) ? ; Ok ( ( ) ) }
inserts value and tags into storage.
inserts value and tags into storage .
&self
type_
&[u8]
id
&[u8]
value
&EncryptedValue
tags
&[Tag]
Result that can be either.


Result that can be either .
&self
type_
&[u8]
id
&[u8]
value
&EncryptedValue
tags
&[Tag]
errors
Any of the following `IndyError` class of errors can be throw by this method.

`IndyError::Closed` - Storage is closed
`IndyError::ItemAlreadyExists` - Item is already present in database
`IOError("IO error during storage operation:...")` - Failed connection or SQL query
Any of the following ` IndyError ` class of errors can be throw by this method . ` IndyError :: Closed ` - Storage is closed ` IndyError :: ItemAlreadyExists ` - Item is already present in database ` IOError ( " IO error during storage operation : ... " ) ` - Failed connection or SQL query