Crates.io | seestr |
lib.rs | seestr |
version | 0.1.5 |
source | src |
created_at | 2024-11-28 22:24:13.808329 |
updated_at | 2024-11-29 07:08:48.809062 |
description | pointer-wide nul-terminated strings with ownership semantics |
homepage | https://crates.io/crates/seestr |
repository | https://github.com/aatifsyed/seestr |
max_upload_size | |
id | 1465025 |
size | 20,364 |
Pointer-wide nul-terminated strings for use in FFI.
The following C API:
char *create(void); // may return nul
void destroy(char *);
char *get_name(struct has_name *); // may return nul
char *version(void); // never null
Can be transcribed as follows:
extern "C" {
fn create() -> Option<Buf>;
fn destroy(_: Buf);
fn get_name(_: &HasName) -> Option<&NulTerminated>;
fn version() -> &'static NulTerminated;
}
As opposed to:
extern "C" {
fn create() -> *mut c_char;
fn destroy(_: *mut c_char);
fn get_name(_: *mut HasName) -> *mut c_char;
fn version() -> *mut c_char;
}