Skip to content

Commit

Permalink
Merge pull request #165 from muzarski/display-consistency
Browse files Browse the repository at this point in the history
misc: Display consistency
  • Loading branch information
dkropachev authored Sep 10, 2024
2 parents 1a17e38 + 714e219 commit d4aaf9d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scylla-rust-wrapper/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "scylla-cpp-driver-rust"
version = "0.1.0"
edition = "2018"
edition = "2021"
description = "Wrapper for Scylla's Rust driver, exports functions to be used by C"
repository = "https://github.com/scylladb/scylla-rust-driver"
readme = "./README.md"
Expand Down
3 changes: 2 additions & 1 deletion scylla-rust-wrapper/src/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,8 @@ mod tests {
let wrapped_cass_fut = PtrWrapper(cass_fut);
unsafe {
let handle = thread::spawn(move || {
let PtrWrapper(cass_fut) = wrapped_cass_fut;
let wrapper = wrapped_cass_fut;
let cass_fut = wrapper.0;
let mut message: *const c_char = std::ptr::null();
let mut msg_len: size_t = 0;
cass_future_error_message(cass_fut, &mut message, &mut msg_len);
Expand Down
1 change: 1 addition & 0 deletions scylla-rust-wrapper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub mod inet;
pub mod integration_testing;
mod logging;
pub mod metadata;
pub mod misc;
pub mod prepared;
pub mod query_error;
pub mod query_result;
Expand Down
29 changes: 29 additions & 0 deletions scylla-rust-wrapper/src/misc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use std::ffi::{c_char, CStr};

// CassConsistency definition.
include!(concat!(env!("OUT_DIR"), "/cppdriver_data_query_error.rs"));

impl CassConsistency {
pub(crate) fn as_cstr(&self) -> &'static CStr {
match *self {
Self::CASS_CONSISTENCY_UNKNOWN => c"UNKNOWN",
Self::CASS_CONSISTENCY_ANY => c"ANY",
Self::CASS_CONSISTENCY_ONE => c"ONE",
Self::CASS_CONSISTENCY_TWO => c"TWO",
Self::CASS_CONSISTENCY_THREE => c"THREE",
Self::CASS_CONSISTENCY_QUORUM => c"QUORUM",
Self::CASS_CONSISTENCY_ALL => c"ALL",
Self::CASS_CONSISTENCY_LOCAL_QUORUM => c"LOCAL_QUORUM",
Self::CASS_CONSISTENCY_EACH_QUORUM => c"EACH_QUORUM",
Self::CASS_CONSISTENCY_SERIAL => c"SERIAL",
Self::CASS_CONSISTENCY_LOCAL_SERIAL => c"LOCAL_SERIAL",
Self::CASS_CONSISTENCY_LOCAL_ONE => c"LOCAL_ONE",
_ => c"",
}
}
}

#[no_mangle]
pub unsafe extern "C" fn cass_consistency_string(consistency: CassConsistency) -> *const c_char {
consistency.as_cstr().as_ptr() as *const c_char
}

0 comments on commit d4aaf9d

Please sign in to comment.