33
44use std:: time:: Duration ;
55
6- use serde:: Deserialize ;
6+ use serde:: { Deserialize , Serialize } ;
77
88use crate :: { bson:: oid:: ObjectId , bson_util, options:: ServerAddress } ;
99
@@ -20,12 +20,12 @@ fn empty_address() -> ServerAddress {
2020}
2121
2222/// Event emitted when a connection pool is created.
23- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
23+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
2424#[ non_exhaustive]
2525pub struct PoolCreatedEvent {
2626 /// The address of the server that the pool's connections will connect to.
2727 #[ serde( default = "self::empty_address" ) ]
28- #[ serde( skip ) ]
28+ #[ serde( skip_deserializing ) ]
2929 pub address : ServerAddress ,
3030
3131 /// The options used for the pool.
@@ -34,7 +34,7 @@ pub struct PoolCreatedEvent {
3434
3535/// Contains the options for creating a connection pool. While these options are specified at the
3636/// 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 ) ]
3838#[ serde( rename_all = "camelCase" ) ]
3939#[ non_exhaustive]
4040pub struct ConnectionPoolOptions {
@@ -62,46 +62,46 @@ pub struct ConnectionPoolOptions {
6262}
6363
6464/// Event emitted when a connection pool becomes ready.
65- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
65+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
6666#[ non_exhaustive]
6767pub struct PoolReadyEvent {
6868 /// The address of the server that the pool's connections will connect to.
6969 #[ serde( default = "self::empty_address" ) ]
70- #[ serde( skip ) ]
70+ #[ serde( skip_deserializing ) ]
7171 pub address : ServerAddress ,
7272}
7373
7474/// Event emitted when a connection pool is cleared.
75- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
75+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
7676#[ non_exhaustive]
7777pub struct PoolClearedEvent {
7878 /// The address of the server that the pool's connections will connect to.
7979 #[ serde( default = "self::empty_address" ) ]
80- #[ serde( skip ) ]
80+ #[ serde( skip_deserializing ) ]
8181 pub address : ServerAddress ,
8282
8383 /// If the connection is to a load balancer, the id of the selected backend.
8484 pub service_id : Option < ObjectId > ,
8585}
8686
8787/// Event emitted when a connection pool is cleared.
88- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
88+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
8989#[ non_exhaustive]
9090pub struct PoolClosedEvent {
9191 /// The address of the server that the pool's connections will connect to.
9292 #[ serde( default = "self::empty_address" ) ]
93- #[ serde( skip ) ]
93+ #[ serde( skip_deserializing ) ]
9494 pub address : ServerAddress ,
9595}
9696
9797/// Event emitted when a connection is created.
98- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
98+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
9999#[ serde( rename_all = "camelCase" ) ]
100100#[ non_exhaustive]
101101pub struct ConnectionCreatedEvent {
102102 /// The address of the server that the connection will connect to.
103103 #[ serde( default = "self::empty_address" ) ]
104- #[ serde( skip ) ]
104+ #[ serde( skip_deserializing ) ]
105105 pub address : ServerAddress ,
106106
107107 /// The unique ID of the connection. This is not used for anything internally, but can be used
@@ -112,13 +112,13 @@ pub struct ConnectionCreatedEvent {
112112
113113/// Event emitted when a connection is ready to be used. This indicates that all the necessary
114114/// prerequisites for using a connection (handshake, authentication, etc.) have been completed.
115- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
115+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
116116#[ serde( rename_all = "camelCase" ) ]
117117#[ non_exhaustive]
118118pub struct ConnectionReadyEvent {
119119 /// The address of the server that the connection is connected to.
120120 #[ serde( default = "self::empty_address" ) ]
121- #[ serde( skip ) ]
121+ #[ serde( skip_deserializing ) ]
122122 pub address : ServerAddress ,
123123
124124 /// The unique ID of the connection. This is not used for anything internally, but can be used
@@ -128,13 +128,13 @@ pub struct ConnectionReadyEvent {
128128}
129129
130130/// Event emitted when a connection is closed.
131- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
131+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
132132#[ serde( rename_all = "camelCase" ) ]
133133#[ non_exhaustive]
134134pub struct ConnectionClosedEvent {
135135 /// The address of the server that the connection was connected to.
136136 #[ serde( default = "self::empty_address" ) ]
137- #[ serde( skip ) ]
137+ #[ serde( skip_deserializing ) ]
138138 pub address : ServerAddress ,
139139
140140 /// The unique ID of the connection. This is not used for anything internally, but can be used
@@ -147,7 +147,7 @@ pub struct ConnectionClosedEvent {
147147}
148148
149149/// The reasons that a connection may be closed.
150- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
150+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
151151#[ serde( rename_all = "camelCase" ) ]
152152#[ non_exhaustive]
153153pub enum ConnectionClosedReason {
@@ -168,30 +168,30 @@ pub enum ConnectionClosedReason {
168168}
169169
170170/// 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 ) ]
172172#[ non_exhaustive]
173173pub struct ConnectionCheckoutStartedEvent {
174174 /// The address of the server that the connection will connect to.
175175 #[ serde( default = "self::empty_address" ) ]
176- #[ serde( skip ) ]
176+ #[ serde( skip_deserializing ) ]
177177 pub address : ServerAddress ,
178178}
179179
180180/// 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 ) ]
182182#[ non_exhaustive]
183183pub struct ConnectionCheckoutFailedEvent {
184184 /// The address of the server that the connection would have connected to.
185185 #[ serde( default = "self::empty_address" ) ]
186- #[ serde( skip ) ]
186+ #[ serde( skip_deserializing ) ]
187187 pub address : ServerAddress ,
188188
189189 /// The reason a connection was unable to be checked out.
190190 pub reason : ConnectionCheckoutFailedReason ,
191191}
192192
193193/// 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 ) ]
195195#[ serde( rename_all = "camelCase" ) ]
196196#[ non_exhaustive]
197197pub enum ConnectionCheckoutFailedReason {
@@ -204,13 +204,13 @@ pub enum ConnectionCheckoutFailedReason {
204204}
205205
206206/// Event emitted when a connection is successfully checked out.
207- #[ derive( Clone , Debug , Deserialize , PartialEq ) ]
207+ #[ derive( Clone , Debug , Deserialize , PartialEq , Serialize ) ]
208208#[ serde( rename_all = "camelCase" ) ]
209209#[ non_exhaustive]
210210pub struct ConnectionCheckedOutEvent {
211211 /// The address of the server that the connection will connect to.
212212 #[ serde( default = "self::empty_address" ) ]
213- #[ serde( skip ) ]
213+ #[ serde( skip_deserializing ) ]
214214 pub address : ServerAddress ,
215215
216216 /// The unique ID of the connection. This is not used for anything internally, but can be used
@@ -220,13 +220,13 @@ pub struct ConnectionCheckedOutEvent {
220220}
221221
222222/// 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 ) ]
224224#[ serde( rename_all = "camelCase" ) ]
225225#[ non_exhaustive]
226226pub struct ConnectionCheckedInEvent {
227227 /// The address of the server that the connection was connected to.
228228 #[ serde( default = "self::empty_address" ) ]
229- #[ serde( skip ) ]
229+ #[ serde( skip_deserializing ) ]
230230 pub address : ServerAddress ,
231231
232232 /// The unique ID of the connection. This is not used for anything internally, but can be used
0 commit comments