1use std::fmt;
4use std::time::Duration;
5
6pub trait HandleEvent: fmt::Debug + Sync + Send {
8 #[allow(unused_variables)]
12 fn handle_acquire(&self, event: AcquireEvent) {}
13
14 #[allow(unused_variables)]
18 fn handle_release(&self, event: ReleaseEvent) {}
19
20 #[allow(unused_variables)]
24 fn handle_checkout(&self, event: CheckoutEvent) {}
25
26 #[allow(unused_variables)]
30 fn handle_timeout(&self, event: TimeoutEvent) {}
31
32 #[allow(unused_variables)]
34 fn handle_checkin(&self, event: CheckinEvent) {}
35}
36
37#[derive(#[automatically_derived]
impl ::core::marker::Copy for NopEventHandler { }Copy, #[automatically_derived]
impl ::core::clone::Clone for NopEventHandler {
#[inline]
fn clone(&self) -> NopEventHandler { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for NopEventHandler {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::write_str(f, "NopEventHandler")
}
}Debug)]
39pub struct NopEventHandler;
40
41impl HandleEvent for NopEventHandler {}
42
43#[derive(#[automatically_derived]
impl ::core::fmt::Debug for AcquireEvent {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "AcquireEvent",
"id", &&self.id)
}
}Debug)]
45pub struct AcquireEvent {
46 pub(crate) id: u64,
47}
48
49impl AcquireEvent {
50 #[inline]
52 pub fn connection_id(&self) -> u64 {
53 self.id
54 }
55}
56
57#[derive(#[automatically_derived]
impl ::core::fmt::Debug for ReleaseEvent {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "ReleaseEvent",
"id", &self.id, "age", &&self.age)
}
}Debug)]
59pub struct ReleaseEvent {
60 pub(crate) id: u64,
61 pub(crate) age: Duration,
62}
63
64impl ReleaseEvent {
65 #[inline]
67 pub fn connection_id(&self) -> u64 {
68 self.id
69 }
70
71 #[inline]
73 pub fn age(&self) -> Duration {
74 self.age
75 }
76}
77
78#[derive(#[automatically_derived]
impl ::core::fmt::Debug for CheckoutEvent {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "CheckoutEvent",
"id", &self.id, "duration", &&self.duration)
}
}Debug)]
80pub struct CheckoutEvent {
81 pub(crate) id: u64,
82 pub(crate) duration: Duration,
83}
84
85impl CheckoutEvent {
86 #[inline]
88 pub fn connection_id(&self) -> u64 {
89 self.id
90 }
91
92 #[inline]
94 pub fn duration(&self) -> Duration {
95 self.duration
96 }
97}
98
99#[derive(#[automatically_derived]
impl ::core::fmt::Debug for TimeoutEvent {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field1_finish(f, "TimeoutEvent",
"timeout", &&self.timeout)
}
}Debug)]
101pub struct TimeoutEvent {
102 pub(crate) timeout: Duration,
103}
104
105impl TimeoutEvent {
106 #[inline]
108 pub fn timeout(&self) -> Duration {
109 self.timeout
110 }
111}
112
113#[derive(#[automatically_derived]
impl ::core::fmt::Debug for CheckinEvent {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field2_finish(f, "CheckinEvent",
"id", &self.id, "duration", &&self.duration)
}
}Debug)]
115pub struct CheckinEvent {
116 pub(crate) id: u64,
117 pub(crate) duration: Duration,
118}
119
120impl CheckinEvent {
121 #[inline]
123 pub fn connection_id(&self) -> u64 {
124 self.id
125 }
126
127 #[inline]
129 pub fn duration(&self) -> Duration {
130 self.duration
131 }
132}