-
Notifications
You must be signed in to change notification settings - Fork 2
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
Suggestion: serialize/deserialize with the serde
crate
#7
Comments
Just off the top, I'll pretty happily concede this crate is pretty rough around the edges and was actually written as a shared object library for c/python that incidentally could be used from rust. I think you're right that the c cruft is getting in the way. I would probably move all the c related stuff to a separate folder, probably a non-uploaded crate that only builds the shared library. Something like:
At the moment I don't think the part of the library that is actually meant to be used from rust uses the The actual file format this library writes/reads is already fixed so we can't use bincode so much that it would effect the encoded output, but it could be configured to write fixed length numbers LE so that we could use it to read the header information and clean up that part of the code. The format is meant to be a byte stream container so I'm not sure how much more we could use serde itself (beyond the use of serde_json since we require the metadata to be json and possible use of bincode as above), could you give me an example? |
This example https://github.com/second-state/rust-by-example-ext/blob/master/examples/serde/bincode/src/main.rs has this output:
Which appears to be Big Endian, which is odd and maybe problematic (but easier to read). But I do realise the CaRT format is more complex, and has internal byte sequences to mark some of the data. But serde & bincode with custom options is an option https://docs.rs/bincode/latest/bincode/config/index.html but I haven't done this so I don't know if it'll work. |
The serde crate is great for reading/writing data to disk with different formats. It works with the bincode crate to write data as raw bytes, which this crate does.
However, the code in this crate is difficult to read, especially with the extensive use of the
libc
crate. I'd like to suggest re-writing to useserde
,bincode
, with a more idiomatic Rust style, with a few C helper functions as needed. Instead, this feels like a C project with uncomfortable Rust wrappers.I'm happy to help and do the bulk of this if it would be accepted.
The text was updated successfully, but these errors were encountered: