Skip to content

Commit d4aaf9d

Browse files
authored
Merge pull request #165 from muzarski/display-consistency
misc: Display consistency
2 parents 1a17e38 + 714e219 commit d4aaf9d

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

scylla-rust-wrapper/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "scylla-cpp-driver-rust"
33
version = "0.1.0"
4-
edition = "2018"
4+
edition = "2021"
55
description = "Wrapper for Scylla's Rust driver, exports functions to be used by C"
66
repository = "https://github.com/scylladb/scylla-rust-driver"
77
readme = "./README.md"

scylla-rust-wrapper/src/future.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ mod tests {
292292
let wrapped_cass_fut = PtrWrapper(cass_fut);
293293
unsafe {
294294
let handle = thread::spawn(move || {
295-
let PtrWrapper(cass_fut) = wrapped_cass_fut;
295+
let wrapper = wrapped_cass_fut;
296+
let cass_fut = wrapper.0;
296297
let mut message: *const c_char = std::ptr::null();
297298
let mut msg_len: size_t = 0;
298299
cass_future_error_message(cass_fut, &mut message, &mut msg_len);

scylla-rust-wrapper/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pub mod inet;
2121
pub mod integration_testing;
2222
mod logging;
2323
pub mod metadata;
24+
pub mod misc;
2425
pub mod prepared;
2526
pub mod query_error;
2627
pub mod query_result;

scylla-rust-wrapper/src/misc.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use std::ffi::{c_char, CStr};
2+
3+
// CassConsistency definition.
4+
include!(concat!(env!("OUT_DIR"), "/cppdriver_data_query_error.rs"));
5+
6+
impl CassConsistency {
7+
pub(crate) fn as_cstr(&self) -> &'static CStr {
8+
match *self {
9+
Self::CASS_CONSISTENCY_UNKNOWN => c"UNKNOWN",
10+
Self::CASS_CONSISTENCY_ANY => c"ANY",
11+
Self::CASS_CONSISTENCY_ONE => c"ONE",
12+
Self::CASS_CONSISTENCY_TWO => c"TWO",
13+
Self::CASS_CONSISTENCY_THREE => c"THREE",
14+
Self::CASS_CONSISTENCY_QUORUM => c"QUORUM",
15+
Self::CASS_CONSISTENCY_ALL => c"ALL",
16+
Self::CASS_CONSISTENCY_LOCAL_QUORUM => c"LOCAL_QUORUM",
17+
Self::CASS_CONSISTENCY_EACH_QUORUM => c"EACH_QUORUM",
18+
Self::CASS_CONSISTENCY_SERIAL => c"SERIAL",
19+
Self::CASS_CONSISTENCY_LOCAL_SERIAL => c"LOCAL_SERIAL",
20+
Self::CASS_CONSISTENCY_LOCAL_ONE => c"LOCAL_ONE",
21+
_ => c"",
22+
}
23+
}
24+
}
25+
26+
#[no_mangle]
27+
pub unsafe extern "C" fn cass_consistency_string(consistency: CassConsistency) -> *const c_char {
28+
consistency.as_cstr().as_ptr() as *const c_char
29+
}

0 commit comments

Comments
 (0)