Skip to main content

scylla_cql/frame/response/
mod.rs

1//! CQL responses sent by the server.
2
3pub mod authenticate;
4pub mod custom_type_parser;
5pub mod error;
6pub mod event;
7pub mod result;
8pub mod supported;
9
10use std::sync::Arc;
11
12pub use error::Error;
13pub use supported::Supported;
14
15use crate::frame::TryFromPrimitiveError;
16use crate::frame::frame_errors::ResultMetadataAndRowsCountParseError;
17use crate::frame::protocol_features::ProtocolFeatures;
18use crate::frame::response::result::ResultMetadata;
19
20use super::frame_errors::CqlResponseParseError;
21
22/// Possible CQL responses received from the server
23// Why is it distinct from [ResponseOpcode]?
24// TODO(2.0): merge this with `ResponseOpcode`.
25#[derive(Debug, Copy, Clone)]
26#[non_exhaustive]
27pub enum CqlResponseKind {
28    /// Indicates an error processing a request.
29    Error,
30
31    /// Indicates that the server is ready to process queries. This message will be
32    /// sent by the server either after a STARTUP message if no authentication is
33    /// required (if authentication is required, the server indicates readiness by
34    /// sending a AUTH_RESPONSE message).
35    Ready,
36
37    ///  Indicates that the server requires authentication, and which authentication
38    /// mechanism to use.
39    ///
40    /// The authentication is SASL based and thus consists of a number of server
41    /// challenges (AUTH_CHALLENGE) followed by client responses (AUTH_RESPONSE).
42    /// The initial exchange is however bootstrapped by an initial client response.
43    /// The details of that exchange (including how many challenge-response pairs
44    /// are required) are specific to the authenticator in use. The exchange ends
45    /// when the server sends an AUTH_SUCCESS message or an ERROR message.
46    ///
47    /// This message will be sent following a STARTUP message if authentication is
48    /// required and must be answered by a AUTH_RESPONSE message from the client.
49    Authenticate,
50
51    /// Indicates which startup options are supported by the server. This message
52    /// comes as a response to an OPTIONS message.
53    Supported,
54
55    /// The result to a query (QUERY, PREPARE, EXECUTE or BATCH messages).
56    /// It has multiple kinds:
57    /// - Void: for results carrying no information.
58    /// - Rows: for results to select queries, returning a set of rows.
59    /// - Set_keyspace: the result to a `USE` statement.
60    /// - Prepared: result to a PREPARE message.
61    /// - Schema_change: the result to a schema altering statement.
62    Result,
63
64    /// An event pushed by the server. A client will only receive events for the
65    /// types it has REGISTER-ed to. The valid event types are:
66    /// - "TOPOLOGY_CHANGE": events related to change in the cluster topology.
67    ///   Currently, events are sent when new nodes are added to the cluster, and
68    ///   when nodes are removed.
69    /// - "STATUS_CHANGE": events related to change of node status. Currently,
70    ///   up/down events are sent.
71    /// - "SCHEMA_CHANGE": events related to schema change.
72    ///   The type of changed involved may be one of "CREATED", "UPDATED" or
73    ///   "DROPPED".
74    Event,
75
76    /// A server authentication challenge (see AUTH_RESPONSE for more details).
77    /// Clients are expected to answer the server challenge with an AUTH_RESPONSE
78    /// message.
79    AuthChallenge,
80
81    /// Indicates the success of the authentication phase.
82    AuthSuccess,
83}
84
85impl std::fmt::Display for CqlResponseKind {
86    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
87        let kind_str = match self {
88            CqlResponseKind::Error => "ERROR",
89            CqlResponseKind::Ready => "READY",
90            CqlResponseKind::Authenticate => "AUTHENTICATE",
91            CqlResponseKind::Supported => "SUPPORTED",
92            CqlResponseKind::Result => "RESULT",
93            CqlResponseKind::Event => "EVENT",
94            CqlResponseKind::AuthChallenge => "AUTH_CHALLENGE",
95            CqlResponseKind::AuthSuccess => "AUTH_SUCCESS",
96        };
97
98        f.write_str(kind_str)
99    }
100}
101
102/// Opcode of a response, used to identify the response type in a CQL frame.
103#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
104#[repr(u8)]
105pub enum ResponseOpcode {
106    /// See [CqlResponseKind::Error].
107    Error = 0x00,
108    /// See [CqlResponseKind::Ready].
109    Ready = 0x02,
110    /// See [CqlResponseKind::Authenticate].
111    Authenticate = 0x03,
112    /// See [CqlResponseKind::Supported].
113    Supported = 0x06,
114    /// See [CqlResponseKind::Result].
115    Result = 0x08,
116    /// See [CqlResponseKind::Event].
117    Event = 0x0C,
118    /// See [CqlResponseKind::AuthChallenge].
119    AuthChallenge = 0x0E,
120    /// See [CqlResponseKind::AuthSuccess].
121    AuthSuccess = 0x10,
122}
123
124impl TryFrom<u8> for ResponseOpcode {
125    type Error = TryFromPrimitiveError<u8>;
126
127    fn try_from(value: u8) -> Result<Self, TryFromPrimitiveError<u8>> {
128        match value {
129            0x00 => Ok(Self::Error),
130            0x02 => Ok(Self::Ready),
131            0x03 => Ok(Self::Authenticate),
132            0x06 => Ok(Self::Supported),
133            0x08 => Ok(Self::Result),
134            0x0C => Ok(Self::Event),
135            0x0E => Ok(Self::AuthChallenge),
136            0x10 => Ok(Self::AuthSuccess),
137            _ => Err(TryFromPrimitiveError {
138                enum_name: "ResponseOpcode",
139                primitive: value,
140            }),
141        }
142    }
143}
144
145/// A CQL response that has been received from the server.
146#[derive(Debug)]
147pub enum Response {
148    /// ERROR response, returned by the server when an error occurs.
149    Error(Error),
150    /// READY response, indicating that the server is ready to process requests,
151    /// typically after a connection is established.
152    Ready,
153    /// RESULT response, containing the result of a statement execution.
154    Result(result::Result),
155    /// AUTHENTICATE response, indicating that the server requires authentication.
156    Authenticate(authenticate::Authenticate),
157    /// AUTH_SUCCESS response, indicating that the authentication was successful.
158    AuthSuccess(authenticate::AuthSuccess),
159    /// AUTH_CHALLENGE response, indicating that the server requires further authentication.
160    AuthChallenge(authenticate::AuthChallenge),
161    /// SUPPORTED response, containing the features supported by the server.
162    Supported(Supported),
163    /// EVENT response, containing an event that occurred on the server.
164    Event(event::Event),
165}
166
167/// A CQL response that has been received from the server.
168#[derive(Debug)]
169#[non_exhaustive]
170pub enum ResponseV2 {
171    /// ERROR response, returned by the server when an error occurs.
172    Error(Error),
173    /// READY response, indicating that the server is ready to process requests,
174    /// typically after a connection is established.
175    Ready,
176    /// RESULT response, containing the result of a statement execution.
177    Result(result::Result),
178    /// AUTHENTICATE response, indicating that the server requires authentication.
179    Authenticate(authenticate::Authenticate),
180    /// AUTH_SUCCESS response, indicating that the authentication was successful.
181    AuthSuccess(authenticate::AuthSuccess),
182    /// AUTH_CHALLENGE response, indicating that the server requires further authentication.
183    AuthChallenge(authenticate::AuthChallenge),
184    /// SUPPORTED response, containing the features supported by the server.
185    Supported(Supported),
186    /// EVENT response, containing an event that occurred on the server.
187    Event(event::EventV2),
188}
189
190impl Response {
191    /// Returns the kind of this response.
192    pub fn to_response_kind(&self) -> CqlResponseKind {
193        match self {
194            Response::Error(_) => CqlResponseKind::Error,
195            Response::Ready => CqlResponseKind::Ready,
196            Response::Result(_) => CqlResponseKind::Result,
197            Response::Authenticate(_) => CqlResponseKind::Authenticate,
198            Response::AuthSuccess(_) => CqlResponseKind::AuthSuccess,
199            Response::AuthChallenge(_) => CqlResponseKind::AuthChallenge,
200            Response::Supported(_) => CqlResponseKind::Supported,
201            Response::Event(_) => CqlResponseKind::Event,
202        }
203    }
204
205    /// Deserialize a response from the given bytes.
206    pub fn deserialize(
207        features: &ProtocolFeatures,
208        opcode: ResponseOpcode,
209        buf_bytes: bytes::Bytes,
210        cached_metadata: Option<&Arc<ResultMetadata<'static>>>,
211    ) -> Result<Response, CqlResponseParseError> {
212        let buf = &mut &*buf_bytes;
213        let response = match opcode {
214            ResponseOpcode::Error => Response::Error(Error::deserialize(features, buf)?),
215            ResponseOpcode::Ready => Response::Ready,
216            ResponseOpcode::Authenticate => {
217                Response::Authenticate(authenticate::Authenticate::deserialize(buf)?)
218            }
219            ResponseOpcode::Supported => Response::Supported(Supported::deserialize(buf)?),
220            ResponseOpcode::Result => Response::Result(result::deserialize_with_features(
221                buf_bytes,
222                cached_metadata,
223                features,
224            )?),
225            ResponseOpcode::Event => Response::Event(event::Event::deserialize(buf)?),
226            ResponseOpcode::AuthChallenge => {
227                Response::AuthChallenge(authenticate::AuthChallenge::deserialize(buf)?)
228            }
229            ResponseOpcode::AuthSuccess => {
230                Response::AuthSuccess(authenticate::AuthSuccess::deserialize(buf)?)
231            }
232        };
233
234        Ok(response)
235    }
236
237    pub fn deserialize_metadata(
238        self,
239    ) -> Result<ResponseWithDeserializedMetadata, ResultMetadataAndRowsCountParseError> {
240        let result = match self {
241            Self::Error(e) => ResponseWithDeserializedMetadata::Error(e),
242            Self::Ready => ResponseWithDeserializedMetadata::Ready,
243            Self::Result(res) => {
244                ResponseWithDeserializedMetadata::Result(res.deserialize_metadata()?)
245            }
246            Self::Authenticate(auth) => ResponseWithDeserializedMetadata::Authenticate(auth),
247            Self::AuthSuccess(auth_succ) => {
248                ResponseWithDeserializedMetadata::AuthSuccess(auth_succ)
249            }
250            Self::AuthChallenge(auth_chal) => {
251                ResponseWithDeserializedMetadata::AuthChallenge(auth_chal)
252            }
253            Self::Supported(sup) => ResponseWithDeserializedMetadata::Supported(sup),
254            Self::Event(eve) => ResponseWithDeserializedMetadata::Event(eve),
255        };
256        Ok(result)
257    }
258
259    /// Converts this response into a `NonErrorResponse`, returning an error if it is an `Error` response.
260    pub fn into_non_error_response(self) -> Result<NonErrorResponse, error::Error> {
261        let non_error_response = match self {
262            Response::Error(e) => return Err(e),
263            Response::Ready => NonErrorResponse::Ready,
264            Response::Result(res) => NonErrorResponse::Result(res),
265            Response::Authenticate(auth) => NonErrorResponse::Authenticate(auth),
266            Response::AuthSuccess(auth_succ) => NonErrorResponse::AuthSuccess(auth_succ),
267            Response::AuthChallenge(auth_chal) => NonErrorResponse::AuthChallenge(auth_chal),
268            Response::Supported(sup) => NonErrorResponse::Supported(sup),
269            Response::Event(eve) => NonErrorResponse::Event(eve),
270        };
271
272        Ok(non_error_response)
273    }
274}
275
276impl ResponseV2 {
277    /// Returns the kind of this response.
278    pub fn to_response_kind(&self) -> CqlResponseKind {
279        match self {
280            Self::Error(_) => CqlResponseKind::Error,
281            Self::Ready => CqlResponseKind::Ready,
282            Self::Result(_) => CqlResponseKind::Result,
283            Self::Authenticate(_) => CqlResponseKind::Authenticate,
284            Self::AuthSuccess(_) => CqlResponseKind::AuthSuccess,
285            Self::AuthChallenge(_) => CqlResponseKind::AuthChallenge,
286            Self::Supported(_) => CqlResponseKind::Supported,
287            Self::Event(_) => CqlResponseKind::Event,
288        }
289    }
290
291    /// Deserialize a response from the given bytes.
292    pub fn deserialize(
293        features: &ProtocolFeatures,
294        opcode: ResponseOpcode,
295        buf_bytes: bytes::Bytes,
296        cached_metadata: Option<&Arc<ResultMetadata<'static>>>,
297    ) -> Result<Self, CqlResponseParseError> {
298        let buf = &mut &*buf_bytes;
299        let response = match opcode {
300            ResponseOpcode::Error => Self::Error(Error::deserialize(features, buf)?),
301            ResponseOpcode::Ready => Self::Ready,
302            ResponseOpcode::Authenticate => {
303                Self::Authenticate(authenticate::Authenticate::deserialize(buf)?)
304            }
305            ResponseOpcode::Supported => Self::Supported(Supported::deserialize(buf)?),
306            ResponseOpcode::Result => Self::Result(result::deserialize_with_features(
307                buf_bytes,
308                cached_metadata,
309                features,
310            )?),
311            ResponseOpcode::Event => Self::Event(event::EventV2::deserialize(buf)?),
312            ResponseOpcode::AuthChallenge => {
313                Self::AuthChallenge(authenticate::AuthChallenge::deserialize(buf)?)
314            }
315            ResponseOpcode::AuthSuccess => {
316                Self::AuthSuccess(authenticate::AuthSuccess::deserialize(buf)?)
317            }
318        };
319
320        Ok(response)
321    }
322
323    pub fn deserialize_metadata(
324        self,
325    ) -> Result<ResponseWithDeserializedMetadataV2, ResultMetadataAndRowsCountParseError> {
326        let result = match self {
327            Self::Error(e) => ResponseWithDeserializedMetadataV2::Error(e),
328            Self::Ready => ResponseWithDeserializedMetadataV2::Ready,
329            Self::Result(res) => {
330                ResponseWithDeserializedMetadataV2::Result(res.deserialize_metadata()?)
331            }
332            Self::Authenticate(auth) => ResponseWithDeserializedMetadataV2::Authenticate(auth),
333            Self::AuthSuccess(auth_succ) => {
334                ResponseWithDeserializedMetadataV2::AuthSuccess(auth_succ)
335            }
336            Self::AuthChallenge(auth_chal) => {
337                ResponseWithDeserializedMetadataV2::AuthChallenge(auth_chal)
338            }
339            Self::Supported(sup) => ResponseWithDeserializedMetadataV2::Supported(sup),
340            Self::Event(eve) => ResponseWithDeserializedMetadataV2::Event(eve),
341        };
342        Ok(result)
343    }
344}
345
346/// A CQL response that has been received from the server.
347#[derive(Debug)]
348pub enum ResponseWithDeserializedMetadata {
349    /// ERROR response, returned by the server when an error occurs.
350    Error(Error),
351    /// READY response, indicating that the server is ready to process requests,
352    /// typically after a connection is established.
353    Ready,
354    /// RESULT response, containing the result of a statement execution.
355    Result(result::ResultWithDeserializedMetadata),
356    /// AUTHENTICATE response, indicating that the server requires authentication.
357    Authenticate(authenticate::Authenticate),
358    /// AUTH_SUCCESS response, indicating that the authentication was successful.
359    AuthSuccess(authenticate::AuthSuccess),
360    /// AUTH_CHALLENGE response, indicating that the server requires further authentication.
361    AuthChallenge(authenticate::AuthChallenge),
362    /// SUPPORTED response, containing the features supported by the server.
363    Supported(Supported),
364    /// EVENT response, containing an event that occurred on the server.
365    Event(event::Event),
366}
367
368impl ResponseWithDeserializedMetadata {
369    /// Returns the kind of this response.
370    pub fn to_response_kind(&self) -> CqlResponseKind {
371        match self {
372            Self::Error(_) => CqlResponseKind::Error,
373            Self::Ready => CqlResponseKind::Ready,
374            Self::Result(_) => CqlResponseKind::Result,
375            Self::Authenticate(_) => CqlResponseKind::Authenticate,
376            Self::AuthSuccess(_) => CqlResponseKind::AuthSuccess,
377            Self::AuthChallenge(_) => CqlResponseKind::AuthChallenge,
378            Self::Supported(_) => CqlResponseKind::Supported,
379            Self::Event(_) => CqlResponseKind::Event,
380        }
381    }
382
383    /// Converts this response into a `NonErrorResponse`, returning an error if it is an `Error` response.
384    pub fn into_non_error_response(
385        self,
386    ) -> Result<NonErrorResponseWithDeserializedMetadata, error::Error> {
387        let non_error_response = match self {
388            Self::Error(e) => return Err(e),
389            Self::Ready => NonErrorResponseWithDeserializedMetadata::Ready,
390            Self::Result(res) => NonErrorResponseWithDeserializedMetadata::Result(res),
391            Self::Authenticate(auth) => {
392                NonErrorResponseWithDeserializedMetadata::Authenticate(auth)
393            }
394            Self::AuthSuccess(auth_succ) => {
395                NonErrorResponseWithDeserializedMetadata::AuthSuccess(auth_succ)
396            }
397            Self::AuthChallenge(auth_chal) => {
398                NonErrorResponseWithDeserializedMetadata::AuthChallenge(auth_chal)
399            }
400            Self::Supported(sup) => NonErrorResponseWithDeserializedMetadata::Supported(sup),
401            Self::Event(eve) => NonErrorResponseWithDeserializedMetadata::Event(eve),
402        };
403
404        Ok(non_error_response)
405    }
406}
407
408/// A CQL response that has been received from the server.
409#[derive(Debug)]
410#[non_exhaustive]
411pub enum ResponseWithDeserializedMetadataV2 {
412    /// ERROR response, returned by the server when an error occurs.
413    Error(Error),
414    /// READY response, indicating that the server is ready to process requests,
415    /// typically after a connection is established.
416    Ready,
417    /// RESULT response, containing the result of a statement execution.
418    Result(result::ResultWithDeserializedMetadata),
419    /// AUTHENTICATE response, indicating that the server requires authentication.
420    Authenticate(authenticate::Authenticate),
421    /// AUTH_SUCCESS response, indicating that the authentication was successful.
422    AuthSuccess(authenticate::AuthSuccess),
423    /// AUTH_CHALLENGE response, indicating that the server requires further authentication.
424    AuthChallenge(authenticate::AuthChallenge),
425    /// SUPPORTED response, containing the features supported by the server.
426    Supported(Supported),
427    /// EVENT response, containing an event that occurred on the server.
428    Event(event::EventV2),
429}
430
431impl ResponseWithDeserializedMetadataV2 {
432    /// Returns the kind of this response.
433    pub fn to_response_kind(&self) -> CqlResponseKind {
434        match self {
435            Self::Error(_) => CqlResponseKind::Error,
436            Self::Ready => CqlResponseKind::Ready,
437            Self::Result(_) => CqlResponseKind::Result,
438            Self::Authenticate(_) => CqlResponseKind::Authenticate,
439            Self::AuthSuccess(_) => CqlResponseKind::AuthSuccess,
440            Self::AuthChallenge(_) => CqlResponseKind::AuthChallenge,
441            Self::Supported(_) => CqlResponseKind::Supported,
442            Self::Event(_) => CqlResponseKind::Event,
443        }
444    }
445
446    /// Converts this response into a `NonErrorResponseV2`, returning an error if it is an `Error` response.
447    pub fn into_non_error_response(
448        self,
449    ) -> Result<NonErrorResponseWithDeserializedMetadataV2, error::Error> {
450        let non_error_response = match self {
451            Self::Error(e) => return Err(e),
452            Self::Ready => NonErrorResponseWithDeserializedMetadataV2::Ready,
453            Self::Result(res) => NonErrorResponseWithDeserializedMetadataV2::Result(res),
454            Self::Authenticate(auth) => {
455                NonErrorResponseWithDeserializedMetadataV2::Authenticate(auth)
456            }
457            Self::AuthSuccess(auth_succ) => {
458                NonErrorResponseWithDeserializedMetadataV2::AuthSuccess(auth_succ)
459            }
460            Self::AuthChallenge(auth_chal) => {
461                NonErrorResponseWithDeserializedMetadataV2::AuthChallenge(auth_chal)
462            }
463            Self::Supported(sup) => NonErrorResponseWithDeserializedMetadataV2::Supported(sup),
464            Self::Event(eve) => NonErrorResponseWithDeserializedMetadataV2::Event(eve),
465        };
466
467        Ok(non_error_response)
468    }
469}
470
471/// A CQL response that has been received from the server, excluding error responses.
472/// This is used to handle responses that are not errors, allowing for easier processing
473/// of valid responses without need to handle error case any later.
474#[derive(Debug)]
475pub enum NonErrorResponse {
476    /// See [`Response::Ready`].
477    Ready,
478    /// See [`Response::Result`].
479    Result(result::Result),
480    /// See [`Response::Authenticate`].
481    Authenticate(authenticate::Authenticate),
482    /// See [`Response::AuthSuccess`].
483    AuthSuccess(authenticate::AuthSuccess),
484    /// See [`Response::AuthChallenge`].
485    AuthChallenge(authenticate::AuthChallenge),
486    /// See [`Response::Supported`].
487    Supported(Supported),
488    /// See [`Response::Event`].
489    Event(event::Event),
490}
491
492impl NonErrorResponse {
493    /// Returns the kind of this non-error response.
494    pub fn to_response_kind(&self) -> CqlResponseKind {
495        match self {
496            NonErrorResponse::Ready => CqlResponseKind::Ready,
497            NonErrorResponse::Result(_) => CqlResponseKind::Result,
498            NonErrorResponse::Authenticate(_) => CqlResponseKind::Authenticate,
499            NonErrorResponse::AuthSuccess(_) => CqlResponseKind::AuthSuccess,
500            NonErrorResponse::AuthChallenge(_) => CqlResponseKind::AuthChallenge,
501            NonErrorResponse::Supported(_) => CqlResponseKind::Supported,
502            NonErrorResponse::Event(_) => CqlResponseKind::Event,
503        }
504    }
505}
506
507/// A CQL response that has been received from the server, excluding error responses.
508/// This is used to handle responses that are not errors, allowing for easier processing
509/// of valid responses without need to handle error case any later.
510/// The difference from [NonErrorResponse] is that Result::Rows variant holds [result::DeserializedMetadataAndRawRows]
511/// instead of [result::RawMetadataAndRawRows].
512#[derive(Debug)]
513pub enum NonErrorResponseWithDeserializedMetadata {
514    /// See [`Response::Ready`].
515    Ready,
516    /// See [`Response::Result`].
517    Result(result::ResultWithDeserializedMetadata),
518    /// See [`Response::Authenticate`].
519    Authenticate(authenticate::Authenticate),
520    /// See [`Response::AuthSuccess`].
521    AuthSuccess(authenticate::AuthSuccess),
522    /// See [`Response::AuthChallenge`].
523    AuthChallenge(authenticate::AuthChallenge),
524    /// See [`Response::Supported`].
525    Supported(Supported),
526    /// See [`Response::Event`].
527    Event(event::Event),
528}
529
530impl NonErrorResponseWithDeserializedMetadata {
531    /// Returns the kind of this non-error response.
532    pub fn to_response_kind(&self) -> CqlResponseKind {
533        match self {
534            Self::Ready => CqlResponseKind::Ready,
535            Self::Result(_) => CqlResponseKind::Result,
536            Self::Authenticate(_) => CqlResponseKind::Authenticate,
537            Self::AuthSuccess(_) => CqlResponseKind::AuthSuccess,
538            Self::AuthChallenge(_) => CqlResponseKind::AuthChallenge,
539            Self::Supported(_) => CqlResponseKind::Supported,
540            Self::Event(_) => CqlResponseKind::Event,
541        }
542    }
543}
544
545/// A CQL response that has been received from the server, excluding error responses.
546/// This is used to handle responses that are not errors, allowing for easier processing
547/// of valid responses without need to handle error case any later.
548/// The difference from [NonErrorResponse] is that Result::Rows variant holds [result::DeserializedMetadataAndRawRows]
549/// instead of [result::RawMetadataAndRawRows].
550#[derive(Debug)]
551#[non_exhaustive]
552pub enum NonErrorResponseWithDeserializedMetadataV2 {
553    /// See [`Response::Ready`].
554    Ready,
555    /// See [`Response::Result`].
556    Result(result::ResultWithDeserializedMetadata),
557    /// See [`Response::Authenticate`].
558    Authenticate(authenticate::Authenticate),
559    /// See [`Response::AuthSuccess`].
560    AuthSuccess(authenticate::AuthSuccess),
561    /// See [`Response::AuthChallenge`].
562    AuthChallenge(authenticate::AuthChallenge),
563    /// See [`Response::Supported`].
564    Supported(Supported),
565    /// See [`Response::Event`].
566    Event(event::EventV2),
567}
568
569impl NonErrorResponseWithDeserializedMetadataV2 {
570    /// Returns the kind of this non-error response.
571    pub fn to_response_kind(&self) -> CqlResponseKind {
572        match self {
573            Self::Ready => CqlResponseKind::Ready,
574            Self::Result(_) => CqlResponseKind::Result,
575            Self::Authenticate(_) => CqlResponseKind::Authenticate,
576            Self::AuthSuccess(_) => CqlResponseKind::AuthSuccess,
577            Self::AuthChallenge(_) => CqlResponseKind::AuthChallenge,
578            Self::Supported(_) => CqlResponseKind::Supported,
579            Self::Event(_) => CqlResponseKind::Event,
580        }
581    }
582}