concurrency_traits/queue/
reverse.rs

1#[cfg(feature = "alloc")]
2use crate::queue::{AsyncPeekQueue, AsyncQueue};
3use crate::queue::{PeekQueue, Queue, TryPeekQueue, TryQueue};
4#[cfg(feature = "alloc")]
5use alloc::boxed::Box;
6#[cfg(feature = "alloc")]
7use async_trait::async_trait;
8
9/// A queue that can try to be read in reverse.
10pub trait TryReverseQueue: TryQueue {
11    /// Non blocking version of `receive_back`
12    fn try_pop_back(&self) -> Option<Self::Item>;
13}
14/// A queue that can be read in reverse.
15pub trait ReverseQueue: TryReverseQueue + Queue {
16    /// Reads from the back of the queue
17    fn pop_back(&self) -> Self::Item;
18}
19/// An asynchronous queue that can be read in reverse
20#[cfg(feature = "alloc")]
21#[async_trait]
22pub trait AsyncReverseQueue: TryReverseQueue + AsyncQueue {
23    /// Reads the back of the queue
24    async fn pop_back_async(&self) -> Self::Item;
25}
26
27/// A queue that can try to be peeked from behind
28pub trait TryPeekReverseQueue: TryPeekQueue + TryReverseQueue {
29    /// Peeks the rear item without blocking
30    fn try_peek_back(&self) -> Option<Self::Peeked>;
31}
32/// A queue that can be peeked from behind
33pub trait PeekReverseQueue: PeekQueue + ReverseQueue + TryPeekReverseQueue {
34    /// Peeks the rear item of the queue blocking until available
35    fn peek_back(&self) -> Self::Peeked;
36}
37/// A queue that can be peeked from behind asynchronously
38#[cfg(feature = "alloc")]
39#[async_trait]
40pub trait AsyncPeekReverseQueue: AsyncPeekQueue + AsyncReverseQueue {
41    /// Peeks the rear item of the queue blocking until available
42    async fn peek_back_async(&self) -> Self::Peeked;
43}