Ensure writable transactions work correctly
This commit is contained in:
parent
f6f54cf4f4
commit
ca57df132e
3 changed files with 36 additions and 36 deletions
|
@ -44,7 +44,7 @@ impl<'a> Transaction<'a> {
|
||||||
// Cancel a transaction
|
// Cancel a transaction
|
||||||
pub fn cancel(&mut self) -> Result<(), Error> {
|
pub fn cancel(&mut self) -> Result<(), Error> {
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Mark this transaction as done
|
// Mark this transaction as done
|
||||||
|
@ -57,11 +57,11 @@ impl<'a> Transaction<'a> {
|
||||||
// Commit a transaction
|
// Commit a transaction
|
||||||
pub fn commit(&mut self) -> Result<(), Error> {
|
pub fn commit(&mut self) -> Result<(), Error> {
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check to see if transaction is writable
|
// Check to see if transaction is writable
|
||||||
if self.rw {
|
if self.rw == false {
|
||||||
return Err(Error::TxReadonlyError);
|
return Err(Error::TxReadonlyError);
|
||||||
}
|
}
|
||||||
// Mark this transaction as done
|
// Mark this transaction as done
|
||||||
|
@ -77,11 +77,11 @@ impl<'a> Transaction<'a> {
|
||||||
K: Into<Key>,
|
K: Into<Key>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check to see if transaction is writable
|
// Check to see if transaction is writable
|
||||||
if self.rw {
|
if self.rw == false {
|
||||||
return Err(Error::TxReadonlyError);
|
return Err(Error::TxReadonlyError);
|
||||||
}
|
}
|
||||||
// Remove the key
|
// Remove the key
|
||||||
|
@ -95,7 +95,7 @@ impl<'a> Transaction<'a> {
|
||||||
K: Into<Key>,
|
K: Into<Key>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check the key
|
// Check the key
|
||||||
|
@ -109,7 +109,7 @@ impl<'a> Transaction<'a> {
|
||||||
K: Into<Key>,
|
K: Into<Key>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Get the key
|
// Get the key
|
||||||
|
@ -124,11 +124,11 @@ impl<'a> Transaction<'a> {
|
||||||
V: Into<Val>,
|
V: Into<Val>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check to see if transaction is writable
|
// Check to see if transaction is writable
|
||||||
if self.rw {
|
if self.rw == false {
|
||||||
return Err(Error::TxReadonlyError);
|
return Err(Error::TxReadonlyError);
|
||||||
}
|
}
|
||||||
// Set the key
|
// Set the key
|
||||||
|
@ -143,11 +143,11 @@ impl<'a> Transaction<'a> {
|
||||||
V: Into<Val>,
|
V: Into<Val>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check to see if transaction is writable
|
// Check to see if transaction is writable
|
||||||
if self.rw {
|
if self.rw == false {
|
||||||
return Err(Error::TxReadonlyError);
|
return Err(Error::TxReadonlyError);
|
||||||
}
|
}
|
||||||
// Set the key
|
// Set the key
|
||||||
|
@ -161,7 +161,7 @@ impl<'a> Transaction<'a> {
|
||||||
K: Into<Key>,
|
K: Into<Key>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Convert the range to bytes
|
// Convert the range to bytes
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl<'a> Transaction<'a> {
|
||||||
// Cancel a transaction
|
// Cancel a transaction
|
||||||
pub fn cancel(&mut self) -> Result<(), Error> {
|
pub fn cancel(&mut self) -> Result<(), Error> {
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Mark this transaction as done
|
// Mark this transaction as done
|
||||||
|
@ -57,11 +57,11 @@ impl<'a> Transaction<'a> {
|
||||||
// Commit a transaction
|
// Commit a transaction
|
||||||
pub fn commit(&mut self) -> Result<(), Error> {
|
pub fn commit(&mut self) -> Result<(), Error> {
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check to see if transaction is writable
|
// Check to see if transaction is writable
|
||||||
if self.rw {
|
if self.rw == false {
|
||||||
return Err(Error::TxReadonlyError);
|
return Err(Error::TxReadonlyError);
|
||||||
}
|
}
|
||||||
// Mark this transaction as done
|
// Mark this transaction as done
|
||||||
|
@ -77,11 +77,11 @@ impl<'a> Transaction<'a> {
|
||||||
K: Into<Key>,
|
K: Into<Key>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check to see if transaction is writable
|
// Check to see if transaction is writable
|
||||||
if self.rw {
|
if self.rw == false {
|
||||||
return Err(Error::TxReadonlyError);
|
return Err(Error::TxReadonlyError);
|
||||||
}
|
}
|
||||||
// Remove the key
|
// Remove the key
|
||||||
|
@ -95,7 +95,7 @@ impl<'a> Transaction<'a> {
|
||||||
K: Into<Key>,
|
K: Into<Key>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check the key
|
// Check the key
|
||||||
|
@ -109,7 +109,7 @@ impl<'a> Transaction<'a> {
|
||||||
K: Into<Key>,
|
K: Into<Key>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Get the key
|
// Get the key
|
||||||
|
@ -124,11 +124,11 @@ impl<'a> Transaction<'a> {
|
||||||
V: Into<Val>,
|
V: Into<Val>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check to see if transaction is writable
|
// Check to see if transaction is writable
|
||||||
if self.rw {
|
if self.rw == false {
|
||||||
return Err(Error::TxReadonlyError);
|
return Err(Error::TxReadonlyError);
|
||||||
}
|
}
|
||||||
// Set the key
|
// Set the key
|
||||||
|
@ -143,11 +143,11 @@ impl<'a> Transaction<'a> {
|
||||||
V: Into<Val>,
|
V: Into<Val>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check to see if transaction is writable
|
// Check to see if transaction is writable
|
||||||
if self.rw {
|
if self.rw == false {
|
||||||
return Err(Error::TxReadonlyError);
|
return Err(Error::TxReadonlyError);
|
||||||
}
|
}
|
||||||
// Set the key
|
// Set the key
|
||||||
|
@ -161,7 +161,7 @@ impl<'a> Transaction<'a> {
|
||||||
K: Into<Key>,
|
K: Into<Key>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Convert the range to bytes
|
// Convert the range to bytes
|
||||||
|
|
|
@ -56,7 +56,7 @@ impl Transaction {
|
||||||
// Cancel a transaction
|
// Cancel a transaction
|
||||||
pub async fn cancel(&mut self) -> Result<(), Error> {
|
pub async fn cancel(&mut self) -> Result<(), Error> {
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Mark this transaction as done
|
// Mark this transaction as done
|
||||||
|
@ -69,11 +69,11 @@ impl Transaction {
|
||||||
// Commit a transaction
|
// Commit a transaction
|
||||||
pub async fn commit(&mut self) -> Result<(), Error> {
|
pub async fn commit(&mut self) -> Result<(), Error> {
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check to see if transaction is writable
|
// Check to see if transaction is writable
|
||||||
if self.rw {
|
if self.rw == false {
|
||||||
return Err(Error::TxReadonlyError);
|
return Err(Error::TxReadonlyError);
|
||||||
}
|
}
|
||||||
// Mark this transaction as done
|
// Mark this transaction as done
|
||||||
|
@ -89,11 +89,11 @@ impl Transaction {
|
||||||
K: Into<Key>,
|
K: Into<Key>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check to see if transaction is writable
|
// Check to see if transaction is writable
|
||||||
if self.rw {
|
if self.rw == false {
|
||||||
return Err(Error::TxReadonlyError);
|
return Err(Error::TxReadonlyError);
|
||||||
}
|
}
|
||||||
// Delete the key
|
// Delete the key
|
||||||
|
@ -107,7 +107,7 @@ impl Transaction {
|
||||||
K: Into<Key>,
|
K: Into<Key>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check the key
|
// Check the key
|
||||||
|
@ -121,7 +121,7 @@ impl Transaction {
|
||||||
K: Into<Key>,
|
K: Into<Key>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Get the key
|
// Get the key
|
||||||
|
@ -136,11 +136,11 @@ impl Transaction {
|
||||||
V: Into<Val>,
|
V: Into<Val>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check to see if transaction is writable
|
// Check to see if transaction is writable
|
||||||
if self.rw {
|
if self.rw == false {
|
||||||
return Err(Error::TxReadonlyError);
|
return Err(Error::TxReadonlyError);
|
||||||
}
|
}
|
||||||
// Set the key
|
// Set the key
|
||||||
|
@ -155,11 +155,11 @@ impl Transaction {
|
||||||
V: Into<Val>,
|
V: Into<Val>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Check to see if transaction is writable
|
// Check to see if transaction is writable
|
||||||
if self.rw {
|
if self.rw == false {
|
||||||
return Err(Error::TxReadonlyError);
|
return Err(Error::TxReadonlyError);
|
||||||
}
|
}
|
||||||
// Set the key
|
// Set the key
|
||||||
|
@ -173,7 +173,7 @@ impl Transaction {
|
||||||
K: Into<Key>,
|
K: Into<Key>,
|
||||||
{
|
{
|
||||||
// Check to see if transaction is closed
|
// Check to see if transaction is closed
|
||||||
if self.ok {
|
if self.ok == true {
|
||||||
return Err(Error::TxFinishedError);
|
return Err(Error::TxFinishedError);
|
||||||
}
|
}
|
||||||
// Convert the range to bytes
|
// Convert the range to bytes
|
||||||
|
|
Loading…
Reference in a new issue