Crates.io | repr_c_pub_struct |
lib.rs | repr_c_pub_struct |
version | 0.1.1 |
source | src |
created_at | 2021-12-26 20:10:00.726047 |
updated_at | 2022-03-13 05:25:29.322046 |
description | A library for extracting `#[repr(C)] pub struct`ures. |
homepage | |
repository | https://github.com/JohnScience/repr_c_pub_struct |
max_upload_size | |
id | 503434 |
size | 38,150 |
#[repr(C)] pub struct
uresIn order to expose a struct with stable ABI for interoperability with other programming languages,
Rust developers should use #[repr(C)]
attribute.
#[repr(C)]
pub struct Great {
}
You can read about it more here
This library allows to perform syn-driven parsing for obtaining the information about location of these repr-c-pub-structs.
src/main.rs
use repr_c_pub_struct::parse_for_repr_c_pub_structs;
fn main() {
let crate_root = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let repr_c_structs = parse_for_repr_c_pub_structs(crate_root.as_str());
println!("{:#?}", repr_c_structs);
}
src/unused.rs
#[repr(C)]
pub struct Unused {
// Test
}
[
ParsedFile {
path: "...\\repr_c_pub_struct\\src\\lib.rs",
repr_c_pub_structs: ReprCPubStructs(
[],
),
},
ParsedFile {
path: "...\\repr_c_pub_struct\\src\\main.rs",
repr_c_pub_structs: ReprCPubStructs(
[],
),
},
ParsedFile {
path: "...\\repr_c_pub_struct\\src\\unused.rs",
repr_c_pub_structs: ReprCPubStructs(
[
LineColumnEnds {
start_line: 1,
start_column: 0,
end_line: 4,
end_column: 1,
},
],
),
},
]
The paths will be absolute. The prefixes have been deleted intentionally.
All structures in this library implement Serialize and Deserialize traits from serde. Because of that you can convert into many data formats supporting serde.