// Insert a key if it doesn't exist in the database
Insert a key if it doesn't exist in the database
Insert a key if it doesn ' t exist in the database
pub fn put(&mut self, key: K, val: V) -> Result<(), Error> {
		// Check to see if transaction is closed
		if self.ok == true {
			return Err(Error::TxClosed);
		}
		// Check to see if transaction is writable
		if self.rw == false {
			return Err(Error::TxNotWritable);
		}
		// Set the key
		match self.ds.get(&key) {
			None => self.ds.insert(key, val),
			_ => return Err(Error::KeyAlreadyExists),
		};
		// Return result
		Ok(())
	}
pub fn put ( & mut self , key : K , val : V ) -> Result < ( ) , Error > { // Check to see if transaction is closed if self . ok == true { return Err ( Error :: TxClosed ) ; } // Check to see if transaction is writable if self . rw == false { return Err ( Error :: TxNotWritable ) ; } // Set the key match self . ds . get ( & key ) { None => self . ds . insert ( key , val ) , _ => return Err ( Error :: KeyAlreadyExists ) , } ; // Return result Ok ( ( ) ) }
Insert a key if it doesn't exist in the database
Insert a key if it doesn ' t exist in the database
&mut self
key
K
val
V