Crates.io | crabi_test |
lib.rs | crabi_test |
version | 0.2.3 |
source | src |
created_at | 2024-11-02 15:33:41.986059 |
updated_at | 2024-11-21 00:58:27.060159 |
description | An experimental Rust library for exploring and experimenting with ABI concepts and cross-language interoperability. |
homepage | |
repository | |
max_upload_size | |
id | 1432958 |
size | 4,400 |
An Experimental Rust Library for ABI Exploration
crabi_test is a Rust library designed to facilitate practical exploration and understanding of Application Binary Interface (ABI) concepts, particularly as they relate to cross-language interoperability and Rust’s Foreign Function Interface (FFI).
The library provides a set of simple, well-documented examples to illustrate how Rust can interact with other languages like C. By using features like #[repr(C)] for predictable memory layouts and extern "C" functions for FFI, crabi_test demonstrates the challenges and considerations involved in ABI compatibility.
Data Structure Layouts: Examples of #[repr(C)] data structures to understand how Rust data can be made ABI-compliant. Cross-Language Function Calls: extern "C" functions that show how data is passed and modified between Rust and other languages. Practical Tests: Built-in tests to validate behavior and illustrate common pitfalls in ABI design and implementation.
crabi_test is suitable for:
Developers interested in systems programming and understanding how Rust can interface with C and other languages. Experiments and educational purposes, offering a foundation to explore the implications of ABI stability or the lack thereof in Rust.
##Example Code
#[repr(C)]
pub struct SimpleData {
pub value: i32,
pub flag: bool,
}
#[no_mangle]
pub extern "C" fn modify_simple_data(data: *mut SimpleData) {
// Function to modify SimpleData structure
}
Distributed under the MIT or Apache 2.0 license.
bensatlantik