seasick

Crates.ioseasick
lib.rsseasick
version0.1.0
sourcesrc
created_at2024-11-30 01:52:05.311254
updated_at2024-11-30 01:52:05.311254
descriptionFFI-safe nul-terminated strings with ownership semantics
homepagehttps://crates.io/crates/seasick
repositoryhttps://github.com/aatifsyed/seasick
max_upload_size
id1466224
size25,229
Aatif Syed (aatifsyed)

documentation

https://docs.rs/seasick

README

FFI-safe types for writing and transcribing C APIs.

&CStr and CString are not FFI safe.

#[deny(improper_ctypes)]
extern "C" {
    fn concat(_: &CStr, _: &CStr) -> CString;
}

&SeaStr and [SeaString] are FFI-safe equivalents.

extern "C" {
    fn concat(_: &SeaStr, _: &SeaStr) -> SeaString;
}

They use the non-null niche which is filled by [Option::None].

/** may return null */
char *foo(void);
extern "C" fn foo() -> Option<SeaString> { .. }
assert_eq!(size_of::<Option<SeaString>>(), size_of::<*mut c_char>());

[SeaBox] is an additional owned pointer type, with a pluggable [Allocator].

Commit count: 10

cargo fmt