#version-string #extern #moving #across #ffi #ffi-safe

nightly ffi-string

A small crate for moving strings across extern "C"

5 stable releases

1.0.4 Dec 28, 2024
1.0.2 Dec 21, 2024
1.0.0 Dec 20, 2024

#1262 in Rust patterns

Download history 296/week @ 2024-12-20 181/week @ 2024-12-27 1/week @ 2025-01-03

478 downloads per month

MIT license

7KB
148 lines

FFIString

This is a small crate for moving strings across extern "C", giving FFI-safe version of String and &str

NOTE: You should also check out Abi Stable, which I didn't know about when I made this crate


This crate provides two types: FFIString and FFIStr

These work just like String and &'a str, but with #[repr(C)]


Why?

I'm trying to make a game engine that loads game code at runtime, and I want both sides to be written in Rust. Without extern "C", both sides would need to be compiled with the exact same version of rustc, so I need an FFI-safe way to pass around String and &str


If you have any ideas on how this can be improved, please submit an issue on the repository


lib.rs:

FFI String

This is a small crate for moving strings across extern "C", giving FFI-safe version of String and &str

No runtime deps