reifydb_transaction/interceptor/
chain.rs1use std::sync::Arc;
5
6pub struct InterceptorChain<I: ?Sized> {
8 pub(crate) interceptors: Vec<Arc<I>>,
9}
10
11impl<I: ?Sized> InterceptorChain<I> {
12 pub fn new() -> Self {
13 Self {
14 interceptors: Vec::new(),
15 }
16 }
17
18 pub fn add(&mut self, interceptor: Arc<I>) {
19 self.interceptors.push(interceptor);
20 }
21
22 pub fn is_empty(&self) -> bool {
23 self.interceptors.is_empty()
24 }
25
26 pub fn len(&self) -> usize {
27 self.interceptors.len()
28 }
29
30 pub fn clear(&mut self) {
31 self.interceptors.clear()
32 }
33}
34
35impl<I: ?Sized> Default for InterceptorChain<I> {
36 fn default() -> Self {
37 Self::new()
38 }
39}
40
41impl<I: ?Sized> Clone for InterceptorChain<I> {
42 fn clone(&self) -> Self {
43 Self {
44 interceptors: self.interceptors.clone(),
45 }
46 }
47}