#[non_exhaustive]pub struct AcquireError<P> {
pub params: P,
}Expand description
The error returned by Acquire if the semaphore queue was 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();
let _err = s.acquire(()).await.unwrap_err();Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.params: PThe params that was used in the acquire request
Implementations§
Source§impl AcquireError<Uncloseable>
impl AcquireError<Uncloseable>
Sourcepub fn never(self) -> !
pub fn never(self) -> !
Since the SemaphoreQueue is Uncloseable, there can
never be an acquire error. This allows for unwrapping with type-safety.
Trait Implementations§
Source§impl<P> Debug for AcquireError<P>where
P: Debug,
impl<P> Debug for AcquireError<P>where
P: Debug,
Source§impl<P> Display for AcquireError<P>
impl<P> Display for AcquireError<P>
Source§impl<P> PartialEq for AcquireError<P>where
P: PartialEq,
impl<P> PartialEq for AcquireError<P>where
P: PartialEq,
impl<P> Eq for AcquireError<P>where
P: Eq,
impl<P> StructuralPartialEq for AcquireError<P>
Auto Trait Implementations§
impl<P> Freeze for AcquireError<P>where
P: Freeze,
impl<P> RefUnwindSafe for AcquireError<P>where
P: RefUnwindSafe,
impl<P> Send for AcquireError<P>where
P: Send,
impl<P> Sync for AcquireError<P>where
P: Sync,
impl<P> Unpin for AcquireError<P>where
P: Unpin,
impl<P> UnwindSafe for AcquireError<P>where
P: UnwindSafe,
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