Skip to content
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

Instantiating LittleEndiand and BigEndian for runtume byte order switching. #145

Closed
johollow opened this issue Apr 16, 2019 · 2 comments
Closed

Comments

@johollow
Copy link

johollow commented Apr 16, 2019

If LittleEndian and BigEndian were empty structs instead of empty enums, I would be able to have dynamic references to them. Then, I could write my code to use the ByteOrder interface, slotting in either LittleEndian or BigEndian once the byte order was determined at runtime. This is useful for certain file formats for which the endian is not known until the file is opened. (Usually these arise when transferring data that was written out in a native format between systems with different endian.)

It seems that this previous issue was posted by someone who wanted to achieve something like this goal: https://github.com/BurntSushi/byteorder/issues/59

Here is a relevant discussion:
https://github.com/BurntSushi/byteorder/issues/95

It seems like it is common to not know what byte order you should be reading until runtime. Perhaps Rust's object system can be used to handle this with the smallest possible change to byteorder.

As always, I am open to other ways of solving this problem.

@BurntSushi
Copy link
Owner

This sounds like a duplicate of #95, no?

@johollow
Copy link
Author

Yes, that's the same issue. Thanks for finding it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants