A library for extracting #[repr(C)] pub structures

In order to expose a struct with stable ABI for interoperability with other programming languages, Rust developers should use #[repr(C)] attribute.

```rust

[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.

Example

src/main.rs

rust 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

```rust

[repr(C)]

pub struct Unused { // Test } ```

Output on Windows

text [ 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, }, ], ), }, ]

Note

The paths will be absolute. The prefixes have been deleted intentionally.

Seralization & Deserialization

All structures in this library implement Serialize and Deserialize traits from serde. Because of that you can convert into many data formats supporting serde.

Data formats

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.