1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
//! Client connection lifecycle and request hooks.
//!
//! This module defines callback types for client-side connection lifecycle
//! events and per-request middleware hooks. Lifecycle hooks fire at connection
//! boundaries (setup, teardown, error). Request hooks fire on every outgoing
//! frame and every incoming frame, enabling symmetric instrumentation with
//! the server's middleware stack.
use ;
use BytesMut;
use ClientError;
/// A boxed future that is `Send` with a specified lifetime.
///
/// This type alias reduces verbosity in handler type signatures.
pub type BoxFuture<'a, T> = ;
/// Handler invoked when a client connection is established.
///
/// Called after the TCP connection is established and preamble exchange (if
/// configured) succeeds. The handler can perform authentication or other setup
/// tasks and returns connection-specific state stored for the connection's
/// lifetime.
///
/// # Examples
///
/// ```rust,no_run
/// use std::sync::Arc;
///
/// use wireframe::client::ClientConnectionSetupHandler;
///
/// struct SessionState {
/// session_id: u64,
/// }
///
/// let setup: ClientConnectionSetupHandler<SessionState> =
/// Arc::new(|| Box::pin(async { SessionState { session_id: 42 } }));
/// ```
pub type ClientConnectionSetupHandler<C> = ;
/// Handler invoked when a client connection is closed.
///
/// Called when the connection is explicitly closed via
/// [`WireframeClient::close`](super::WireframeClient::close). The handler
/// receives the connection state produced by the setup handler.
///
/// # Examples
///
/// ```rust,no_run
/// use std::sync::Arc;
///
/// use wireframe::client::ClientConnectionTeardownHandler;
///
/// struct SessionState {
/// session_id: u64,
/// }
///
/// let teardown: ClientConnectionTeardownHandler<SessionState> = Arc::new(|state| {
/// Box::pin(async move {
/// println!("Session {} closed", state.session_id);
/// })
/// });
/// ```
pub type ClientConnectionTeardownHandler<C> =
;
/// Handler invoked when the client encounters an error.
///
/// Called when an error occurs during send, receive, or call operations. The
/// handler receives a reference to the error for logging or recovery actions.
/// The handler is invoked before the error is returned to the caller.
///
/// # Examples
///
/// ```rust,no_run
/// use std::sync::Arc;
///
/// use wireframe::client::ClientErrorHandler;
///
/// let error_handler: ClientErrorHandler = Arc::new(|err| {
/// Box::pin(async move {
/// eprintln!("Client error: {err}");
/// })
/// });
/// ```
pub type ClientErrorHandler =
;
/// Configuration for client lifecycle hooks.
///
/// This struct holds the optional lifecycle callbacks configured via the
/// builder. It is used internally to pass hook configuration from the builder
/// to the client runtime.
pub
/// Hook invoked after serialization, before a frame is written to the
/// transport.
///
/// The hook receives a mutable reference to the serialized bytes, allowing
/// inspection or modification (e.g., prepending an authentication token,
/// logging frame size, incrementing a metrics counter).
///
/// # Examples
///
/// ```rust
/// use std::sync::{
/// Arc,
/// atomic::{AtomicUsize, Ordering},
/// };
///
/// use wireframe::client::BeforeSendHook;
///
/// let counter = Arc::new(AtomicUsize::new(0));
/// let count = counter.clone();
/// let hook: BeforeSendHook = Arc::new(move |_bytes: &mut Vec<u8>| {
/// count.fetch_add(1, Ordering::Relaxed);
/// });
/// ```
pub type BeforeSendHook = ;
/// Hook invoked after a frame is read from the transport, before
/// deserialization.
///
/// The hook receives a mutable reference to the raw bytes, allowing
/// inspection or modification before the deserializer processes them.
///
/// # Examples
///
/// ```rust
/// use std::sync::{
/// Arc,
/// atomic::{AtomicUsize, Ordering},
/// };
///
/// use wireframe::client::AfterReceiveHook;
///
/// let counter = Arc::new(AtomicUsize::new(0));
/// let count = counter.clone();
/// let hook: AfterReceiveHook = Arc::new(move |_bytes: &mut bytes::BytesMut| {
/// count.fetch_add(1, Ordering::Relaxed);
/// });
/// ```
pub type AfterReceiveHook = ;
/// Configuration for client request/response hooks.
///
/// Stores hooks that fire on every outgoing frame (after serialization) and
/// every incoming frame (before deserialization). Multiple hooks of each type
/// may be registered; they execute in registration order.
pub