From a44e663eb6d4aaf567dd35f2676014ba5aaa9e00 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 5 Jan 2025 22:03:34 +0100 Subject: feat(ecs): allow control over component mutability in query --- ecs/src/lock.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'ecs/src/lock.rs') 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, 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, 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)] -- cgit v1.2.3-18-g5258