diff --git a/scylla-rust-wrapper/Cargo.toml b/scylla-rust-wrapper/Cargo.toml index bc171a80..c7100526 100644 --- a/scylla-rust-wrapper/Cargo.toml +++ b/scylla-rust-wrapper/Cargo.toml @@ -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" diff --git a/scylla-rust-wrapper/src/future.rs b/scylla-rust-wrapper/src/future.rs index 0d08ce68..65315bed 100644 --- a/scylla-rust-wrapper/src/future.rs +++ b/scylla-rust-wrapper/src/future.rs @@ -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); diff --git a/scylla-rust-wrapper/src/lib.rs b/scylla-rust-wrapper/src/lib.rs index 0f99f3cd..2833437d 100644 --- a/scylla-rust-wrapper/src/lib.rs +++ b/scylla-rust-wrapper/src/lib.rs @@ -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; diff --git a/scylla-rust-wrapper/src/misc.rs b/scylla-rust-wrapper/src/misc.rs new file mode 100644 index 00000000..5c7de1ec --- /dev/null +++ b/scylla-rust-wrapper/src/misc.rs @@ -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 +}