-
-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use scroll_derive to generate read implementations for simple C structs #10
Comments
Sounds good to me. I wrote most of the existing code against Rust 1.14, which didn't support custom derives. No reason to avoid them today, though 😄 |
https://github.com/m4b/scroll_derive does this kind of thing |
Wouldn't bincode be a perfect fit for this? It should serialize and deserialize the structs the same way it's currently being done. Anything that requires a complicated deserialization can be customized. I believe it is also possible to have zero-copy deserialization with bincode now, but memory mapping the PDB seems unlikely at this point. |
Hmm… I'm slightly more comfortable with
There are enough offsets plumbed around (e.g. |
Yeah, I would recommend against bincode. bincode's really only designed to deserialize things that have been serialized with bincode and not as a general purpose binary reader. |
with scroll 0.8 you can now just add scroll to your #[macro_use]
extern crate scroll; instead of extern crate scroll;
#[macro_use]
extern crate scroll_derive; to get the derive impls (similar to failure). Let me know if you run into any issues!
|
We decided not to use I'm closing this issue to triage, but please feel free to reopen. |
I totally understand the compilation time argument but that's a bummer! I think custom derives make writing this kind of code so much less error-prone. I think |
That's right. Although, even with the derive, there were so many cases where we had to write custom It might be a nice experiment, but if the macro turns out too obscure, probably custom derives might be easier to understand and maintain. WDYT? |
While implementing module reading I noticed that there's some very repetitive code in pdb for reading simple C structs, like this example of reading the DBI header:
https://github.com/willglynn/pdb/blob/b4cdee36f37e817b3a45001019f46924ccd3d7fb/src/dbi.rs#L168
It feels like we could use serde derive and write our own reader implementation to use with it to avoid listing all the struct fields out there.
The text was updated successfully, but these errors were encountered: