-
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
Added version comparison and tests #147
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I left some nits regarding some code duplications and little optimization.
2.1 Doesn't allow decompression of higher version files by lower version compressor (Should it?)
I think so. The frame format may be changed in the future, so parsing them with an outdated compressor version may lead to undefined behavior.
Co-authored-by: Bohdan Siryk <[email protected]>
Added review suggestion.
@rukai Can you give a look at this PR please. Thanks! |
I have two concerns:
1. Crate versioning vs file versioningThe needs for versioning the ATSC crate is:
Semantic versioning is important here since it enables interoperability across the crate ecosystem while allowing non-breaking changes to be easily pulled in via The needs for file format versioning is:
Semantic versioning is overkill here. Concerns with using the same version
Proposed SolutionSo instead I propose that we store the version of the file as a u32. 2. store the version out of bincodeUnlike protocols like json or cbor, bincode does not provide any mechanism for performing upgrades on old file formats. So, if we are to continue using bincode then we need to store the version out of band so that we can deserialize to the old bincode format and then upgrade the deserialized values to the new format. I propose we do this by storing the u32 of the version as the first 4 bytes of the file and then begin decoding the bincode after reading those 4 bytes. |
I took a look at #146 and can see how you ended up with this solution. The focus of the issue was on compatibility with the logic of the compressor rather than changes to the file format itself. I still think that the approach I wrote up is worth considering since it enables changes to the file format as well. But if the ability to change the file format is not important then we can disregard my previous comment. Edit: Thinking about it, the addition of this version field demonstrates that we really do need versioning for file format changes, since its a breaking change to the existing file format. |
Amazing feedback, thanks! I think it makes all the sense to allow header inspection before the bincode. I also think that the version as u32 is a great plan. Then then compressors don't need to tie to the compressor version, but to the file version, makes much more sense. Going to rewrite this following this approach. |
Closes #146
This PR addresses issue #146 in the following way:
CompressorHeader
(Extracted fromCargo.toml
)2.1 Doesn't allow decompression of higher version files by lower version compressor (Should it?)