Debian Codegraph @

third_party/rust/tokio-util/src/time/wheel/stack.rs

raw
1 use std::borrow::Borrow;
2 use std::cmp::Eq;
3 use std::hash::Hash;
4
5 /// Abstracts the stack operations needed to track timeouts.
6 pub(crate) trait Stack: Default {
7 /// Type of the item stored in the stack
8 type Owned: Borrow<Self::Borrowed>;
9
10 /// Borrowed item
11 type Borrowed: Eq + Hash;
12
13 /// Item storage, this allows a slab to be used instead of just the heap
14 type Store;
15
16 /// Returns `true` if the stack is empty
17 fn is_empty(&self) -> bool;
18
19 /// Push an item onto the stack
20 fn push(&mut self, item: Self::Owned, store: &mut Self::Store);
21
22 /// Pop an item from the stack
23 fn pop(&mut self, store: &mut Self::Store) -> Option<Self::Owned>;
24
25 fn remove(&mut self, item: &Self::Borrowed, store: &mut Self::Store);
26
27 fn when(item: &Self::Borrowed, store: &Self::Store) -> u64;
28 }