Skip to content

Commit 5c517b6

Browse files
committed
frame/request: doc RequestOpcode & CqlRequestKind
It seems that both enums should be merged into one. This is however left for 2.0.
1 parent 807b2b0 commit 5c517b6

File tree

1 file changed

+50
-0
lines changed
  • scylla-cql/src/frame/request

1 file changed

+50
-0
lines changed

scylla-cql/src/frame/request/mod.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,58 @@ use super::types::SerialConsistency;
3131
use super::TryFromPrimitiveError;
3232

3333
/// Possible requests sent by the client.
34+
// Why is it distinct from [RequestOpcode]?
35+
// TODO(2.0): merge this with `RequestOpcode`.
3436
#[derive(Debug, Copy, Clone)]
3537
#[non_exhaustive]
3638
pub enum CqlRequestKind {
39+
/// Initialize the connection. The server will respond by either a READY message
40+
/// (in which case the connection is ready for queries) or an AUTHENTICATE message
41+
/// (in which case credentials will need to be provided using AUTH_RESPONSE).
42+
///
43+
/// This must be the first message of the connection, except for OPTIONS that can
44+
/// be sent before to find out the options supported by the server. Once the
45+
/// connection has been initialized, a client should not send any more STARTUP
46+
/// messages.
3747
Startup,
48+
49+
/// Answers a server authentication challenge.
50+
51+
/// Authentication in the protocol is SASL based. The server sends authentication
52+
/// challenges (a bytes token) to which the client answers with this message. Those
53+
/// exchanges continue until the server accepts the authentication by sending a
54+
/// AUTH_SUCCESS message after a client AUTH_RESPONSE. Note that the exchange
55+
/// begins with the client sending an initial AUTH_RESPONSE in response to a
56+
/// server AUTHENTICATE request.
57+
///
58+
/// The response to a AUTH_RESPONSE is either a follow-up AUTH_CHALLENGE message,
59+
/// an AUTH_SUCCESS message or an ERROR message.
3860
AuthResponse,
61+
62+
/// Asks the server to return which STARTUP options are supported. The server
63+
/// will respond with a SUPPORTED message.
3964
Options,
65+
66+
/// Performs a CQL query, i.e., executes an unprepared statement.
67+
/// The server will respond to a QUERY message with a RESULT message, the content
68+
/// of which depends on the query.
4069
Query,
70+
71+
/// Prepares a query for later execution (through EXECUTE).
72+
/// The server will respond with a RESULT::Prepared message.
4173
Prepare,
74+
75+
/// Executes a prepared query.
76+
/// The response from the server will be a RESULT message.
4277
Execute,
78+
79+
/// Allows executing a list of queries (prepared or not) as a batch (note that
80+
/// only DML statements are accepted in a batch).
81+
/// The server will respond with a RESULT message.
4382
Batch,
83+
84+
/// Register this connection to receive some types of events.
85+
/// The response to a REGISTER message will be a READY message.
4486
Register,
4587
}
4688

@@ -65,13 +107,21 @@ impl std::fmt::Display for CqlRequestKind {
65107
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
66108
#[repr(u8)]
67109
pub enum RequestOpcode {
110+
/// See [CqlRequestKind::Startup].
68111
Startup = 0x01,
112+
/// See [CqlRequestKind::Options].
69113
Options = 0x05,
114+
/// See [CqlRequestKind::Query].
70115
Query = 0x07,
116+
/// See [CqlRequestKind::Prepare].
71117
Prepare = 0x09,
118+
/// See [CqlRequestKind::Execute].
72119
Execute = 0x0A,
120+
/// See [CqlRequestKind::Register].
73121
Register = 0x0B,
122+
/// See [CqlRequestKind::Batch].
74123
Batch = 0x0D,
124+
/// See [CqlRequestKind::AuthResponse].
75125
AuthResponse = 0x0F,
76126
}
77127

0 commit comments

Comments
 (0)