From fe85f44fd09a6ee2de9830773bc63f48894f7f65 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 20 Oct 2021 09:42:34 -0400 Subject: [PATCH] Remove try_lock from StorageHandle. --- crates/tor-persist/src/handle.rs | 6 ------ crates/tor-persist/src/testing.rs | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/crates/tor-persist/src/handle.rs b/crates/tor-persist/src/handle.rs index d04185f68..1661b49dd 100644 --- a/crates/tor-persist/src/handle.rs +++ b/crates/tor-persist/src/handle.rs @@ -22,9 +22,6 @@ pub trait StorageHandle { /// Return true if we have the lock; see [`StateMgr::can_store`]. fn can_store(&self) -> bool; - - /// Try to acquire the lock; see [`StateMgr::can_store`]. - fn try_lock(&self) -> Result; } /// Type wrapper for a reference-counted `dyn` [`StorageHandle`]. @@ -69,9 +66,6 @@ where fn can_store(&self) -> bool { self.mgr.can_store() } - fn try_lock(&self) -> Result { - Ok(self.mgr.try_lock()?.held()) - } } impl StorageHandleImpl diff --git a/crates/tor-persist/src/testing.rs b/crates/tor-persist/src/testing.rs index d35ef2712..b1b1e0daf 100644 --- a/crates/tor-persist/src/testing.rs +++ b/crates/tor-persist/src/testing.rs @@ -176,7 +176,7 @@ mod test { let h1: DynStorageHandle = mgr.clone().create_handle("foo"); let h2: DynStorageHandle = mgr.clone().create_handle("bar"); - let h3: DynStorageHandle = mgr.create_handle("baz"); + let h3: DynStorageHandle = mgr.clone().create_handle("baz"); let v1 = Ex1 { v1: 1, v2: 2 }; let s1 = Ex2 { @@ -189,7 +189,7 @@ mod test { }; assert!(matches!(h1.store(&v1), Err(Error::NoLock))); - assert!(h1.try_lock().unwrap()); + assert!(mgr.try_lock().unwrap().held()); assert!(h1.can_store()); assert!(h1.store(&v1).is_ok());