-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
P3P3 item - no one uses this most probably, but in the end it's better to implement itP3 item - no one uses this most probably, but in the end it's better to implement itenhancementNew feature or requestNew feature or request
Description
While we cannot make use of FFI
trait API (we don't have any assumptions about the origin of the char*
pointers provided by the user), we could probably utilize CassPtr
to some extent. Thanks to that, we would be handling null pointers on a type level (represented as None
).
I don't like current API for multiple reasons. One of them is that
pub unsafe fn ptr_to_cstr_n(ptr: *const c_char, size: size_t) -> Option<&'static str> {
if ptr.is_null() {
return None;
}
std::str::from_utf8(unsafe { std::slice::from_raw_parts(ptr as *const u8, size as usize) }).ok()
}
does not distinguish two scenarios:
- pointer is null
- provided bytes are non-utf8
In both of these scenarios, we return None
.
wprzytula
Metadata
Metadata
Assignees
Labels
P3P3 item - no one uses this most probably, but in the end it's better to implement itP3 item - no one uses this most probably, but in the end it's better to implement itenhancementNew feature or requestNew feature or request