pub enum TryAcquireError<P, C>where
C: IsCloseable,{
NoPermits(P),
Closed(<C as IsCloseable>::AcquireError<P>),
}Expand description
The error returned by try_acquire
§NoPermits
struct Counter(usize);
impl flag_bearer::SemaphoreState for Counter {
type Params = ();
type Permit = ();
fn acquire(&mut self, _: Self::Params) -> Result<Self::Permit, Self::Params> {
if self.0 > 0 {
self.0 -= 1;
Ok(())
} else {
Err(())
}
}
fn release(&mut self, _: Self::Permit) {
self.0 += 1;
}
}
let s = flag_bearer::new_fifo().with_state(Counter(0));
match s.try_acquire(()) {
Err(flag_bearer::TryAcquireError::NoPermits(_)) => {},
_ => unreachable!(),
}§Closed
struct Counter(usize);
impl flag_bearer::SemaphoreState for Counter {
type Params = ();
type Permit = ();
fn acquire(&mut self, _: Self::Params) -> Result<Self::Permit, Self::Params> {
if self.0 > 0 {
self.0 -= 1;
Ok(())
} else {
Err(())
}
}
fn release(&mut self, _: Self::Permit) {
self.0 += 1;
}
}
let s = flag_bearer::new_fifo().closeable().with_state(Counter(1));
// closing the semaphore makes all current and new acquire() calls return an error.
s.close();
match s.try_acquire(()) {
Err(flag_bearer::TryAcquireError::Closed(_)) => {},
_ => unreachable!(),
}The error returned by SemaphoreQueue::try_acquire.
Variants§
NoPermits(P)
The semaphore had no permits to give out right now.
Closed(<C as IsCloseable>::AcquireError<P>)
The semaphore is closed.
Trait Implementations§
Source§impl<P, C> Debug for TryAcquireError<P, C>
impl<P, C> Debug for TryAcquireError<P, C>
Source§impl<P, C> Display for TryAcquireError<P, C>where
C: IsCloseable,
impl<P, C> Display for TryAcquireError<P, C>where
C: IsCloseable,
Source§impl<P, C> PartialEq for TryAcquireError<P, C>
impl<P, C> PartialEq for TryAcquireError<P, C>
impl<P, C> Eq for TryAcquireError<P, C>
impl<P, C> StructuralPartialEq for TryAcquireError<P, C>where
C: IsCloseable,
Auto Trait Implementations§
impl<P, C> Freeze for TryAcquireError<P, C>
impl<P, C> RefUnwindSafe for TryAcquireError<P, C>
impl<P, C> Send for TryAcquireError<P, C>
impl<P, C> Sync for TryAcquireError<P, C>
impl<P, C> Unpin for TryAcquireError<P, C>
impl<P, C> UnwindSafe for TryAcquireError<P, C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more