pub enum AcquireOutcome<'ao> {
Success(Token<'ao>),
Failure(Shared<Receiver<()>>),
}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>
impl<'ao> AcquireOutcome<'ao>
Sourcepub fn or_token(self, token: Option<Token<'ao>>) -> Self
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).