3 releases
0.1.3 | Jun 11, 2024 |
---|---|
0.1.2 | May 13, 2024 |
0.1.1 |
|
0.1.0 | Apr 11, 2024 |
#1098 in Data structures
Used in fmod-oxide
39KB
585 lines
Like camino, but for C strings
lib.rs
:
UTF-8 equivalents of std
's C string types.
lanyard
is an extension of the std::ffi
module that adds new Utf8CStr
and Utf8CString
types.
They are like the standard library's CStr
and CString
types, except they are guaranteed to be valid UTF-8.
Therefore they allow the ability to losslessly convert into strings, they implement Display
, etc, etc.
The std::ffi
types are not guaranteed to be valid UTF-8, which is the right decision for the standard library.
However, in FFI, it's not uncommon to encounter APIs which expect all strings to be UTF-8. This generally requires
crate authors to convert between &str
and CStr
via CString
between the Rust-C boundary (which allocates every time).
With UTF-8 C strings, the conversion between a &str
and Utf8CStr
are made explicit, and allocations can be minimized.