diff options
author | HampusM <hampus@hampusmat.com> | 2025-01-05 22:03:34 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2025-01-05 22:03:34 +0100 |
commit | a44e663eb6d4aaf567dd35f2676014ba5aaa9e00 (patch) | |
tree | cd81d1f61b33e1905d6b3def851e5be18838556b /ecs/src/lock.rs | |
parent | cd385ddedc767c953f24109ec3ffe0a07d247ff5 (diff) |
feat(ecs): allow control over component mutability in query
Diffstat (limited to 'ecs/src/lock.rs')
-rw-r--r-- | ecs/src/lock.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ecs/src/lock.rs b/ecs/src/lock.rs index fbc6842..135f654 100644 --- a/ecs/src/lock.rs +++ b/ecs/src/lock.rs @@ -28,7 +28,7 @@ where pub fn read_nonblock(&self) -> Result<ReadGuard<Value>, Error> { let guard = self.inner.try_read().or_else(|err| match err { - TryLockError::WouldBlock => Err(Error::Unavailable), + TryLockError::WouldBlock => Err(Error::ReadUnavailable), TryLockError::Poisoned(poison_err) => Ok(poison_err.into_inner()), })?; @@ -45,7 +45,7 @@ where pub fn write_nonblock(&self) -> Result<WriteGuard<Value>, Error> { let guard = self.inner.try_write().or_else(|err| match err { - TryLockError::WouldBlock => Err(Error::Unavailable), + TryLockError::WouldBlock => Err(Error::WriteUnavailable), TryLockError::Poisoned(poison_err) => Ok(poison_err.into_inner()), })?; @@ -69,8 +69,11 @@ where #[derive(Debug, thiserror::Error)] pub enum Error { - #[error("Lock is unavailable")] - Unavailable, + #[error("Lock is unavailable for reading")] + ReadUnavailable, + + #[error("Lock is unavailable for writing")] + WriteUnavailable, } #[derive(Debug)] |