-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprotocol.rs
More file actions
73 lines (67 loc) · 2.44 KB
/
Copy pathprotocol.rs
File metadata and controls
73 lines (67 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#![allow(deprecated)]
#[rustfmt::skip]
use crate::ffi::{
enum_CassProtocolVersion_,
enum_CassProtocolVersion__CASS_PROTOCOL_VERSION_DSEV1 as VERSION_DSEV1,
enum_CassProtocolVersion__CASS_PROTOCOL_VERSION_DSEV2 as VERSION_DSEV2,
enum_CassProtocolVersion__CASS_PROTOCOL_VERSION_V1 as VERSION_V1,
enum_CassProtocolVersion__CASS_PROTOCOL_VERSION_V2 as VERSION_V2,
enum_CassProtocolVersion__CASS_PROTOCOL_VERSION_V3 as VERSION_V3,
enum_CassProtocolVersion__CASS_PROTOCOL_VERSION_V4 as VERSION_V4,
enum_CassProtocolVersion__CASS_PROTOCOL_VERSION_V5 as VERSION_V5,
};
/// Apache Cassandra protocol version.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ProtocolVersion {
/// Deprecated.
#[deprecated(note = "This version is deprecated.")]
V1,
/// Deprecated.
#[deprecated(note = "This version is deprecated.")]
V2,
/// Apache Cassandra protocol version 3.
V3,
/// Apache Cassandra protocol version 4.
V4,
/// Apache Cassandra protocol version 5.
V5,
/// Only supported when using the DSE driver with DataStax Enterprise.
Dsev1,
/// Only supported when using the DSE driver with DataStax Enterprise.
Dsev2,
/// The protocol version is unknown to this crate.
Other(u32),
}
impl ProtocolVersion {
/// Creates a new `ProtocolVersion` from the driver object.
#[rustfmt::skip]
pub(crate) fn from_driver(version: enum_CassProtocolVersion_) -> Self {
use ProtocolVersion::*;
match version {
VERSION_V1 => V1,
VERSION_V2 => V2,
VERSION_V3 => V3,
VERSION_V4 => V4,
VERSION_V5 => V5,
VERSION_DSEV1 => Dsev1,
VERSION_DSEV2 => Dsev2,
unknown => Other(unknown),
}
}
/// Converts the `ProtocolVersion` to the driver's enum type.
#[rustfmt::skip]
pub(crate) fn to_driver(self) -> enum_CassProtocolVersion_ {
use ProtocolVersion::*;
match self {
V1 => VERSION_V1,
V2 => VERSION_V2,
V3 => VERSION_V3,
V4 => VERSION_V4,
V5 => VERSION_V5,
Dsev1 => VERSION_DSEV1,
Dsev2 => VERSION_DSEV2,
Other(unknown) => unknown,
}
}
}