AcquireError

Struct AcquireError 

Source
#[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: P

The params that was used in the acquire request

Implementations§

Source§

impl AcquireError<Uncloseable>

Source

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,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<P> Display for AcquireError<P>

Source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<P> PartialEq for AcquireError<P>
where P: PartialEq,

Source§

fn eq(&self, other: &AcquireError<P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<P> Eq for AcquireError<P>
where P: Eq,

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.