FFI Struct
An attribute macro designed to create Rust structs used for FFI directly with adjusted paddings inserted, and reflection support for the struct to be able to iterate through its member info, such as member name, type ID, size, and offset.
Language|语言
Chinglish | 简体中文
Example
The code below shows the typical usage of the crate:
use *;
After the #[ffi_struct] has been applied to TestStructRust, a NEW struct is created and named TestStruct, which had the Rust suffix removed.
The struct TestStruct derives traits that are originally derived to TestStructRust, e. g. Default and Debug.
After specifying the member's alignments, the paddings were added to the new struct TestStruct.
Improvements compared to another crate struct_iterable
- Generic type parameters were allowed in the structure.
- Struct member iteration doesn't have to access the struct members, so the tightly packed struct is allowed.
- When specifying alignments, the paddings were added to the new struct.