Expand description
Tools for implementing and transcribing C APIs.
&CStr, CString and Box are not FFI safe.
ⓘ
#[deny(improper_ctypes_definitions)]
extern "C" fn bad(_: &CStr, _: Box<u8>) -> CString { todo!() }&SeaStr, SeaString and SeaBox are FFI-safe equivalents.
#[deny(improper_ctypes_definitions)]
extern "C" fn good(_: &SeaStr, _: SeaBox<u8>) -> SeaString { todo!() }
All are pointer-wide, with a non-null niche filled by Option::None.
Option::None.assert_eq!(size_of::<SeaBox<u8>>(), size_of::<*mut u8>());
assert_eq!(size_of::<Option<SeaBox<u8>>>(), size_of::<*mut u8>());
assert_eq!(size_of::<SeaString>(), size_of::<*mut c_char>());
assert_eq!(size_of::<Option<SeaString>>(), size_of::<*mut c_char>());TransmuteFrom is the culmination of this crate,
for writing your own wrappers to C types.
See its documentation for more.
Modules§
- till_
null - Iterators for nul-terminated arrays of pointers.
Macros§
- assert_
abi macros - Assert that the ABI of two functions are compatible.
Structs§
- Alloc
Error - Heap allocation failure.
- CFor
Iteratorreturned bycfor.- Libc
libc - An
Allocatorwhich useslibc’s allocation functions. - SeaArray
- A fixed-sized array that MAY be truncated by an interior null.
- SeaBox
In - Owned, aligned pointer to a
T, which is freed onDrop. - SeaStr
- A run of bytes that is guaranteed to terminate at nul.
- SeaString
In - Pointer-wide,
owned handle to a
nul-terminated buffer, which is freed onDrop. - Write
Buffer alloc - A growable, nul-terminated UTF-8 buffer which implements
fmt::Write.
Traits§
- Allocator
- A set of free allocation functions.
- Transmute
From - Transmute between two types that have the same ABI.
- Transmute
MutFrom - Transmute between mutable references of two types that have compatible ABIs.
- Transmute
RefFrom - Transmute between references of two types that have compatible ABIs.
Functions§
- cfor
- Emulate a
C-styleforloop.
Type Aliases§
- SeaBox
libc - Owned, aligned pointer to a
Tallocated withmalloc, which isfree-ed onDrop. - SeaString
libc - Pointer-wide,
owned handle to a
nul-terminated buffer, allocated withmalloc, which isfree-ed onDrop.
Derive Macros§
- Transmute
From macros - Implement
TransmuteFrombetween two types. - Transmute
MutFrom macros - Transmute
RefFrom macros