@@ -19,16 +19,65 @@ use crate::frame::TryFromPrimitiveError;
19
19
use super :: frame_errors:: CqlResponseParseError ;
20
20
21
21
/// Possible CQL responses received from the server
22
+ // Why is it distinct from [ResponseOpcode]?
23
+ // TODO(2.0): merge this with `ResponseOpcode`.
22
24
#[ derive( Debug , Copy , Clone ) ]
23
25
#[ non_exhaustive]
24
26
pub enum CqlResponseKind {
27
+ /// Indicates an error processing a request.
25
28
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).
26
34
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.
27
48
Authenticate ,
49
+
50
+ /// Indicates which startup options are supported by the server. This message
51
+ /// comes as a response to an OPTIONS message.
28
52
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.
29
61
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".
30
73
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.
31
78
AuthChallenge ,
79
+
80
+ /// Indicates the success of the authentication phase.
32
81
AuthSuccess ,
33
82
}
34
83
@@ -53,13 +102,21 @@ impl std::fmt::Display for CqlResponseKind {
53
102
#[ derive( Debug , Copy , Clone , PartialEq , Eq , PartialOrd , Ord ) ]
54
103
#[ repr( u8 ) ]
55
104
pub enum ResponseOpcode {
105
+ /// See [CqlResponseKind::Error].
56
106
Error = 0x00 ,
107
+ /// See [CqlResponseKind::Ready].
57
108
Ready = 0x02 ,
109
+ /// See [CqlResponseKind::Authenticate].
58
110
Authenticate = 0x03 ,
111
+ /// See [CqlResponseKind::Supported].
59
112
Supported = 0x06 ,
113
+ /// See [CqlResponseKind::Result].
60
114
Result = 0x08 ,
115
+ /// See [CqlResponseKind::Event].
61
116
Event = 0x0C ,
117
+ /// See [CqlResponseKind::AuthChallenge].
62
118
AuthChallenge = 0x0E ,
119
+ /// See [CqlResponseKind::AuthSuccess].
63
120
AuthSuccess = 0x10 ,
64
121
}
65
122
0 commit comments