Skip to content

Commit

Permalink
Merge pull request #166 from muzarski/write_type_string
Browse files Browse the repository at this point in the history
misc: cass_write_type_string
  • Loading branch information
dkropachev authored Sep 11, 2024
2 parents d4aaf9d + 14fb832 commit b279526
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scylla-rust-wrapper/src/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,24 @@ impl CassConsistency {
pub unsafe extern "C" fn cass_consistency_string(consistency: CassConsistency) -> *const c_char {
consistency.as_cstr().as_ptr() as *const c_char
}

impl CassWriteType {
pub(crate) fn as_cstr(&self) -> &'static CStr {
match *self {
Self::CASS_WRITE_TYPE_SIMPLE => c"SIMPLE",
Self::CASS_WRITE_TYPE_BATCH => c"BATCH",
Self::CASS_WRITE_TYPE_UNLOGGED_BATCH => c"UNLOGGED_BATCH",
Self::CASS_WRITE_TYPE_COUNTER => c"COUNTER",
Self::CASS_WRITE_TYPE_BATCH_LOG => c"BATCH_LOG",
Self::CASS_WRITE_TYPE_CAS => c"CAS",
Self::CASS_WRITE_TYPE_VIEW => c"VIEW",
Self::CASS_WRITE_TYPE_CDC => c"CDC",
_ => c"",
}
}
}

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

0 comments on commit b279526

Please sign in to comment.