From ace5a5241d9ba9bf2b957124941954d147e1fc84 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Thu, 16 Dec 2021 12:15:21 -0700 Subject: [PATCH] switch error type on `lock` fn --- patch-db/src/model.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/patch-db/src/model.rs b/patch-db/src/model.rs index bbc9bc0..ca78a35 100644 --- a/patch-db/src/model.rs +++ b/patch-db/src/model.rs @@ -9,7 +9,7 @@ use json_ptr::JsonPointer; use serde::{Deserialize, Serialize}; use serde_json::Value; -use crate::locker::{LockError, LockType}; +use crate::locker::LockType; use crate::{DbHandle, DiffPatch, Error, Revision}; #[derive(Debug)] @@ -65,12 +65,8 @@ impl Model where T: Serialize + for<'de> Deserialize<'de>, { - pub async fn lock( - &self, - db: &mut Db, - lock_type: LockType, - ) -> Result<(), LockError> { - db.lock(self.ptr.clone(), lock_type).await + pub async fn lock(&self, db: &mut Db, lock_type: LockType) -> Result<(), Error> { + Ok(db.lock(self.ptr.clone(), lock_type).await?) } pub async fn get(&self, db: &mut Db, lock: bool) -> Result, Error> { @@ -232,12 +228,8 @@ impl Deserialize<'de>> HasModel for Box { #[derive(Debug)] pub struct OptionModel Deserialize<'de>>(T::Model); impl Deserialize<'de>> OptionModel { - pub async fn lock( - &self, - db: &mut Db, - lock_type: LockType, - ) -> Result<(), LockError> { - db.lock(self.0.as_ref().clone(), lock_type).await + pub async fn lock(&self, db: &mut Db, lock_type: LockType) -> Result<(), Error> { + Ok(db.lock(self.0.as_ref().clone(), lock_type).await?) } pub async fn get(