|
| 1 | +use crate::argconv::{free_boxed, ptr_to_ref, write_str_to_c}; |
| 2 | +use crate::cluster::CassCluster; |
| 3 | +use crate::types::*; |
| 4 | +use std::os::raw::c_char; |
1 | 5 |
|
| 6 | +#[no_mangle] |
| 7 | +pub unsafe extern "C" fn testing_get_connect_timeout_from_cluster( |
| 8 | + cluster: *mut CassCluster, |
| 9 | +) -> cass_uint16_t { |
| 10 | + let cluster = ptr_to_ref(cluster); |
| 11 | + cluster.session_builder.config.connect_timeout.as_millis() as cass_uint16_t |
| 12 | +} |
| 13 | + |
| 14 | +#[no_mangle] |
| 15 | +pub unsafe extern "C" fn testing_get_contact_points_from_cluster( |
| 16 | + cluster: *mut CassCluster, |
| 17 | + contact_points: *mut *const c_char, |
| 18 | + contact_points_length: *mut size_t, |
| 19 | + contact_points_boxed: *mut *const String, |
| 20 | +) { |
| 21 | + let cluster = ptr_to_ref(cluster); |
| 22 | + let str = Box::new(cluster.contact_points.join(",")); |
| 23 | + let result = str.as_str(); |
| 24 | + |
| 25 | + write_str_to_c(result, contact_points, contact_points_length); |
| 26 | + *contact_points_boxed = Box::into_raw(str); |
| 27 | +} |
| 28 | + |
| 29 | +#[no_mangle] |
| 30 | +pub unsafe extern "C" fn testing_free_contact_points_string(contact_points_boxed: *mut String) { |
| 31 | + free_boxed(contact_points_boxed) |
| 32 | +} |
| 33 | + |
| 34 | +#[no_mangle] |
| 35 | +pub unsafe extern "C" fn testing_get_port_from_cluster(cluster: *mut CassCluster) -> cass_int32_t { |
| 36 | + let cluster = ptr_to_ref(cluster); |
| 37 | + |
| 38 | + cluster.port as cass_int32_t |
| 39 | +} |
0 commit comments