Skip to content

Commit b279526

Browse files
authored
Merge pull request #166 from muzarski/write_type_string
misc: cass_write_type_string
2 parents d4aaf9d + 14fb832 commit b279526

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

scylla-rust-wrapper/src/misc.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,24 @@ impl CassConsistency {
2727
pub unsafe extern "C" fn cass_consistency_string(consistency: CassConsistency) -> *const c_char {
2828
consistency.as_cstr().as_ptr() as *const c_char
2929
}
30+
31+
impl CassWriteType {
32+
pub(crate) fn as_cstr(&self) -> &'static CStr {
33+
match *self {
34+
Self::CASS_WRITE_TYPE_SIMPLE => c"SIMPLE",
35+
Self::CASS_WRITE_TYPE_BATCH => c"BATCH",
36+
Self::CASS_WRITE_TYPE_UNLOGGED_BATCH => c"UNLOGGED_BATCH",
37+
Self::CASS_WRITE_TYPE_COUNTER => c"COUNTER",
38+
Self::CASS_WRITE_TYPE_BATCH_LOG => c"BATCH_LOG",
39+
Self::CASS_WRITE_TYPE_CAS => c"CAS",
40+
Self::CASS_WRITE_TYPE_VIEW => c"VIEW",
41+
Self::CASS_WRITE_TYPE_CDC => c"CDC",
42+
_ => c"",
43+
}
44+
}
45+
}
46+
47+
#[no_mangle]
48+
pub unsafe extern "C" fn cass_write_type_string(write_type: CassWriteType) -> *const c_char {
49+
write_type.as_cstr().as_ptr() as *const c_char
50+
}

0 commit comments

Comments
 (0)