@@ -19,16 +19,65 @@ use crate::frame::TryFromPrimitiveError;
1919use super :: frame_errors:: CqlResponseParseError ;
2020
2121/// Possible CQL responses received from the server
22+ // Why is it distinct from [ResponseOpcode]?
23+ // TODO(2.0): merge this with `ResponseOpcode`.
2224#[ derive( Debug , Copy , Clone ) ]
2325#[ non_exhaustive]
2426pub enum CqlResponseKind {
27+ /// Indicates an error processing a request.
2528 Error ,
29+
30+ /// Indicates that the server is ready to process queries. This message will be
31+ /// sent by the server either after a STARTUP message if no authentication is
32+ /// required (if authentication is required, the server indicates readiness by
33+ /// sending a AUTH_RESPONSE message).
2634 Ready ,
35+
36+ /// Indicates that the server requires authentication, and which authentication
37+ /// mechanism to use.
38+
39+ /// The authentication is SASL based and thus consists of a number of server
40+ /// challenges (AUTH_CHALLENGE) followed by client responses (AUTH_RESPONSE).
41+ /// The initial exchange is however bootstrapped by an initial client response.
42+ /// The details of that exchange (including how many challenge-response pairs
43+ /// are required) are specific to the authenticator in use. The exchange ends
44+ /// when the server sends an AUTH_SUCCESS message or an ERROR message.
45+ ///
46+ /// This message will be sent following a STARTUP message if authentication is
47+ /// required and must be answered by a AUTH_RESPONSE message from the client.
2748 Authenticate ,
49+
50+ /// Indicates which startup options are supported by the server. This message
51+ /// comes as a response to an OPTIONS message.
2852 Supported ,
53+
54+ /// The result to a query (QUERY, PREPARE, EXECUTE or BATCH messages).
55+ /// It has multiple kinds:
56+ /// - Void: for results carrying no information.
57+ /// - Rows: for results to select queries, returning a set of rows.
58+ /// - Set_keyspace: the result to a `USE` statement.
59+ /// - Prepared: result to a PREPARE message.
60+ /// - Schema_change: the result to a schema altering statement.
2961 Result ,
62+
63+ /// An event pushed by the server. A client will only receive events for the
64+ /// types it has REGISTER-ed to. The valid event types are:
65+ /// - "TOPOLOGY_CHANGE": events related to change in the cluster topology.
66+ /// Currently, events are sent when new nodes are added to the cluster, and
67+ /// when nodes are removed.
68+ /// - "STATUS_CHANGE": events related to change of node status. Currently,
69+ /// up/down events are sent.
70+ /// - "SCHEMA_CHANGE": events related to schema change.
71+ /// The type of changed involved may be one of "CREATED", "UPDATED" or
72+ /// "DROPPED".
3073 Event ,
74+
75+ /// A server authentication challenge (see AUTH_RESPONSE for more details).
76+ /// Clients are expected to answer the server challenge with an AUTH_RESPONSE
77+ /// message.
3178 AuthChallenge ,
79+
80+ /// Indicates the success of the authentication phase.
3281 AuthSuccess ,
3382}
3483
@@ -53,13 +102,21 @@ impl std::fmt::Display for CqlResponseKind {
53102#[ derive( Debug , Copy , Clone , PartialEq , Eq , PartialOrd , Ord ) ]
54103#[ repr( u8 ) ]
55104pub enum ResponseOpcode {
105+ /// See [CqlResponseKind::Error].
56106 Error = 0x00 ,
107+ /// See [CqlResponseKind::Ready].
57108 Ready = 0x02 ,
109+ /// See [CqlResponseKind::Authenticate].
58110 Authenticate = 0x03 ,
111+ /// See [CqlResponseKind::Supported].
59112 Supported = 0x06 ,
113+ /// See [CqlResponseKind::Result].
60114 Result = 0x08 ,
115+ /// See [CqlResponseKind::Event].
61116 Event = 0x0C ,
117+ /// See [CqlResponseKind::AuthChallenge].
62118 AuthChallenge = 0x0E ,
119+ /// See [CqlResponseKind::AuthSuccess].
63120 AuthSuccess = 0x10 ,
64121}
65122
0 commit comments