Skip to content

Commit 7851c04

Browse files
committed
cass_result: implement missing functions
Implemented two missing CassResult functions: - cass_result_column_type - cass_result_column_data_type
1 parent 84df0c8 commit 7851c04

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

scylla-rust-wrapper/src/query_result.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -934,6 +934,34 @@ pub unsafe extern "C" fn cass_result_column_name(
934934
CassError::CASS_OK
935935
}
936936

937+
#[no_mangle]
938+
pub unsafe extern "C" fn cass_result_column_type(
939+
result: *const CassResult,
940+
index: size_t,
941+
) -> CassValueType {
942+
let data_type_ptr = cass_result_column_data_type(result, index);
943+
if data_type_ptr.is_null() {
944+
return CassValueType::CASS_VALUE_TYPE_UNKNOWN;
945+
}
946+
cass_data_type_type(data_type_ptr)
947+
}
948+
949+
#[no_mangle]
950+
pub unsafe extern "C" fn cass_result_column_data_type(
951+
result: *const CassResult,
952+
index: size_t,
953+
) -> *const CassDataType {
954+
let result_from_raw: &CassResult = ptr_to_ref(result);
955+
let index_usize: usize = index.try_into().unwrap();
956+
957+
result_from_raw
958+
.metadata
959+
.col_data_types
960+
.get(index_usize)
961+
.map(Arc::as_ptr)
962+
.unwrap_or(std::ptr::null())
963+
}
964+
937965
#[no_mangle]
938966
pub unsafe extern "C" fn cass_value_type(value: *const CassValue) -> CassValueType {
939967
let value_from_raw = ptr_to_ref(value);

0 commit comments

Comments
 (0)