pub struct Faucet<T> { /* private fields */ }Implementations§
Source§impl<T> Faucet<T>
impl<T> Faucet<T>
Sourcepub fn new_with_cancellation(
max_len: usize,
cancellation: CancellationToken,
) -> Self
pub fn new_with_cancellation( max_len: usize, cancellation: CancellationToken, ) -> Self
Creates a new faucet with a maximum queue length and a cancellation source.
Providing an existing cancellation token is useful when you have a “parent” cancellation token.
Cancelling the token will prevent any additional values from being pushed onto the queue, and will drain any values already in the queue.
pub fn capacity(&self) -> usize
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn end(&self)
pub fn end(&self)
Cancels the faucet, preventing any additional values from being pushed onto the queue. Any values already in the queue will be drained.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns true if the faucet has been cancelled and has no more values remaining in the queue to be drained.
Sourcepub fn is_pending(&self) -> bool
pub fn is_pending(&self) -> bool
Returns true if the faucet is either: (a) accepting values, or (b) is cancelled but has not been fully drained.
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Returns true if the faucet has been cancelled and will not accept any additional values pushed onto the queue.
pub async fn cancelled(&self)
Sourcepub async fn push(&self, value: T) -> ControlFlow<(), ()>
pub async fn push(&self, value: T) -> ControlFlow<(), ()>
Pushes a value onto the queue or waits until space is available.
Sourcepub fn try_push(&self, value: T) -> Result<(), T>
pub fn try_push(&self, value: T) -> Result<(), T>
Attempts to push a value onto the queue, returning an error with the original value if the queue is full.