Skip to main content

qubit_lock/lock/
try_lock_error.rs

1/*******************************************************************************
2 *
3 *    Copyright (c) 2025 - 2026.
4 *    Haixing Hu, Qubit Co. Ltd.
5 *
6 *    All rights reserved.
7 *
8 ******************************************************************************/
9//! # Try Lock Error
10//!
11//! Error type for non-blocking lock acquisition on synchronous locks.
12//!
13//! # Author
14//!
15//! Haixing Hu
16
17/// Non-blocking lock acquisition error.
18///
19/// This error type is used by `try_read` and `try_write` to distinguish
20/// lock contention from poisoned lock states.
21#[derive(Debug, Clone, Copy, PartialEq, Eq)]
22pub enum TryLockError {
23    /// The lock is currently held by another thread.
24    WouldBlock,
25    /// The lock is poisoned due to a panic while the lock was held.
26    Poisoned,
27}