guard.rs 554 B

12345678910111213141516
  1. pub trait UnlockableGuard {
  2. type Unlocked: UnlockedGuard<Guard = Self>;
  3. #[must_use = "The returned `UnlockedGuard` must be used to relock the lock."]
  4. fn unlock(self) -> Self::Unlocked;
  5. }
  6. /// # Safety
  7. /// Implementors of this trait MUST ensure that the lock is correctly unlocked if
  8. /// the lock is stateful and dropped accidentally.
  9. pub unsafe trait UnlockedGuard: Send {
  10. type Guard: UnlockableGuard;
  11. #[must_use = "Throwing away the relocked guard is pointless."]
  12. fn relock(self) -> impl Future<Output = Self::Guard> + Send;
  13. }