Skip to main content

AcquireOutcome

Enum AcquireOutcome 

Source
pub enum AcquireOutcome<'ao> {
    Success(Token<'ao>),
    Failure(Shared<Receiver<()>>),
}
Expand description

The outcome from trying to acquire a Token for a Line.

Variants§

§

Success(Token<'ao>)

The line could be acquired and returned a token to hold on to.

The token must remain in scope, as it will release the line when dropped.

§

Failure(Shared<Receiver<()>>)

The line could not be acquired as another consumer is holding a token for it.

This variant includes a Shared future that resolves when the current token holder drops it and releases the line.

Implementations§

Source§

impl<'ao> AcquireOutcome<'ao>

Source

pub fn or_token(self, token: Option<Token<'ao>>) -> Self

Returns the AcquireOutcome if it’s a success, otherwise returns a success with the provided token if it’s not None.

If the current AcquireOutcome is a failure, and the provided token is None, the failure is returned.

§Design considerations

One way to make this method more straightforward could have been to make token be a Token, not an Option, but the current signature was picked to simplify the consumers (which store the token, if any, in an Option).

Auto Trait Implementations§

§

impl<'ao> Freeze for AcquireOutcome<'ao>

§

impl<'ao> !RefUnwindSafe for AcquireOutcome<'ao>

§

impl<'ao> !Send for AcquireOutcome<'ao>

§

impl<'ao> !Sync for AcquireOutcome<'ao>

§

impl<'ao> Unpin for AcquireOutcome<'ao>

§

impl<'ao> UnsafeUnpin for AcquireOutcome<'ao>

§

impl<'ao> !UnwindSafe for AcquireOutcome<'ao>

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, 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.