3
3
4
4
use std:: time:: Duration ;
5
5
6
- use serde:: Deserialize ;
6
+ use serde:: { Deserialize , Serialize } ;
7
7
8
8
use crate :: { bson:: oid:: ObjectId , bson_util, options:: ServerAddress } ;
9
9
@@ -20,12 +20,12 @@ fn empty_address() -> ServerAddress {
20
20
}
21
21
22
22
/// Event emitted when a connection pool is created.
23
- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
23
+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
24
24
#[ non_exhaustive]
25
25
pub struct PoolCreatedEvent {
26
26
/// The address of the server that the pool's connections will connect to.
27
27
#[ serde( default = "self::empty_address" ) ]
28
- #[ serde( skip ) ]
28
+ #[ serde( skip_deserializing ) ]
29
29
pub address : ServerAddress ,
30
30
31
31
/// The options used for the pool.
@@ -34,7 +34,7 @@ pub struct PoolCreatedEvent {
34
34
35
35
/// Contains the options for creating a connection pool. While these options are specified at the
36
36
/// client-level, `ConnectionPoolOptions` is exposed for the purpose of CMAP event handling.
37
- #[ derive( Clone , Default , Deserialize , Debug , PartialEq ) ]
37
+ #[ derive( Clone , Default , Deserialize , Debug , PartialEq , Serialize ) ]
38
38
#[ serde( rename_all = "camelCase" ) ]
39
39
#[ non_exhaustive]
40
40
pub struct ConnectionPoolOptions {
@@ -62,46 +62,46 @@ pub struct ConnectionPoolOptions {
62
62
}
63
63
64
64
/// Event emitted when a connection pool becomes ready.
65
- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
65
+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
66
66
#[ non_exhaustive]
67
67
pub struct PoolReadyEvent {
68
68
/// The address of the server that the pool's connections will connect to.
69
69
#[ serde( default = "self::empty_address" ) ]
70
- #[ serde( skip ) ]
70
+ #[ serde( skip_deserializing ) ]
71
71
pub address : ServerAddress ,
72
72
}
73
73
74
74
/// Event emitted when a connection pool is cleared.
75
- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
75
+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
76
76
#[ non_exhaustive]
77
77
pub struct PoolClearedEvent {
78
78
/// The address of the server that the pool's connections will connect to.
79
79
#[ serde( default = "self::empty_address" ) ]
80
- #[ serde( skip ) ]
80
+ #[ serde( skip_deserializing ) ]
81
81
pub address : ServerAddress ,
82
82
83
83
/// If the connection is to a load balancer, the id of the selected backend.
84
84
pub service_id : Option < ObjectId > ,
85
85
}
86
86
87
87
/// Event emitted when a connection pool is cleared.
88
- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
88
+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
89
89
#[ non_exhaustive]
90
90
pub struct PoolClosedEvent {
91
91
/// The address of the server that the pool's connections will connect to.
92
92
#[ serde( default = "self::empty_address" ) ]
93
- #[ serde( skip ) ]
93
+ #[ serde( skip_deserializing ) ]
94
94
pub address : ServerAddress ,
95
95
}
96
96
97
97
/// Event emitted when a connection is created.
98
- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
98
+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
99
99
#[ serde( rename_all = "camelCase" ) ]
100
100
#[ non_exhaustive]
101
101
pub struct ConnectionCreatedEvent {
102
102
/// The address of the server that the connection will connect to.
103
103
#[ serde( default = "self::empty_address" ) ]
104
- #[ serde( skip ) ]
104
+ #[ serde( skip_deserializing ) ]
105
105
pub address : ServerAddress ,
106
106
107
107
/// The unique ID of the connection. This is not used for anything internally, but can be used
@@ -112,13 +112,13 @@ pub struct ConnectionCreatedEvent {
112
112
113
113
/// Event emitted when a connection is ready to be used. This indicates that all the necessary
114
114
/// prerequisites for using a connection (handshake, authentication, etc.) have been completed.
115
- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
115
+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
116
116
#[ serde( rename_all = "camelCase" ) ]
117
117
#[ non_exhaustive]
118
118
pub struct ConnectionReadyEvent {
119
119
/// The address of the server that the connection is connected to.
120
120
#[ serde( default = "self::empty_address" ) ]
121
- #[ serde( skip ) ]
121
+ #[ serde( skip_deserializing ) ]
122
122
pub address : ServerAddress ,
123
123
124
124
/// The unique ID of the connection. This is not used for anything internally, but can be used
@@ -128,13 +128,13 @@ pub struct ConnectionReadyEvent {
128
128
}
129
129
130
130
/// Event emitted when a connection is closed.
131
- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
131
+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
132
132
#[ serde( rename_all = "camelCase" ) ]
133
133
#[ non_exhaustive]
134
134
pub struct ConnectionClosedEvent {
135
135
/// The address of the server that the connection was connected to.
136
136
#[ serde( default = "self::empty_address" ) ]
137
- #[ serde( skip ) ]
137
+ #[ serde( skip_deserializing ) ]
138
138
pub address : ServerAddress ,
139
139
140
140
/// The unique ID of the connection. This is not used for anything internally, but can be used
@@ -147,7 +147,7 @@ pub struct ConnectionClosedEvent {
147
147
}
148
148
149
149
/// The reasons that a connection may be closed.
150
- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
150
+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
151
151
#[ serde( rename_all = "camelCase" ) ]
152
152
#[ non_exhaustive]
153
153
pub enum ConnectionClosedReason {
@@ -168,30 +168,30 @@ pub enum ConnectionClosedReason {
168
168
}
169
169
170
170
/// Event emitted when a thread begins checking out a connection to use for an operation.
171
- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
171
+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
172
172
#[ non_exhaustive]
173
173
pub struct ConnectionCheckoutStartedEvent {
174
174
/// The address of the server that the connection will connect to.
175
175
#[ serde( default = "self::empty_address" ) ]
176
- #[ serde( skip ) ]
176
+ #[ serde( skip_deserializing ) ]
177
177
pub address : ServerAddress ,
178
178
}
179
179
180
180
/// Event emitted when a thread is unable to check out a connection.
181
- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
181
+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
182
182
#[ non_exhaustive]
183
183
pub struct ConnectionCheckoutFailedEvent {
184
184
/// The address of the server that the connection would have connected to.
185
185
#[ serde( default = "self::empty_address" ) ]
186
- #[ serde( skip ) ]
186
+ #[ serde( skip_deserializing ) ]
187
187
pub address : ServerAddress ,
188
188
189
189
/// The reason a connection was unable to be checked out.
190
190
pub reason : ConnectionCheckoutFailedReason ,
191
191
}
192
192
193
193
/// The reasons a connection may not be able to be checked out.
194
- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
194
+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
195
195
#[ serde( rename_all = "camelCase" ) ]
196
196
#[ non_exhaustive]
197
197
pub enum ConnectionCheckoutFailedReason {
@@ -204,13 +204,13 @@ pub enum ConnectionCheckoutFailedReason {
204
204
}
205
205
206
206
/// Event emitted when a connection is successfully checked out.
207
- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
207
+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
208
208
#[ serde( rename_all = "camelCase" ) ]
209
209
#[ non_exhaustive]
210
210
pub struct ConnectionCheckedOutEvent {
211
211
/// The address of the server that the connection will connect to.
212
212
#[ serde( default = "self::empty_address" ) ]
213
- #[ serde( skip ) ]
213
+ #[ serde( skip_deserializing ) ]
214
214
pub address : ServerAddress ,
215
215
216
216
/// The unique ID of the connection. This is not used for anything internally, but can be used
@@ -220,13 +220,13 @@ pub struct ConnectionCheckedOutEvent {
220
220
}
221
221
222
222
/// Event emitted when a connection is checked back into a connection pool.
223
- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
223
+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
224
224
#[ serde( rename_all = "camelCase" ) ]
225
225
#[ non_exhaustive]
226
226
pub struct ConnectionCheckedInEvent {
227
227
/// The address of the server that the connection was connected to.
228
228
#[ serde( default = "self::empty_address" ) ]
229
- #[ serde( skip ) ]
229
+ #[ serde( skip_deserializing ) ]
230
230
pub address : ServerAddress ,
231
231
232
232
/// The unique ID of the connection. This is not used for anything internally, but can be used
0 commit comments