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

Is there any plan on supporing network-endian on FixedInt ? #26

Closed
changrui0608 opened this issue Jun 19, 2022 · 3 comments
Closed

Is there any plan on supporing network-endian on FixedInt ? #26

changrui0608 opened this issue Jun 19, 2022 · 3 comments
Assignees

Comments

@changrui0608
Copy link
Contributor

reading/write from network-endian buffer or stream, which I think could be very helpful on network protocol things.

@dermesser
Copy link
Owner

Yes, this is a good point. Unfortunately the API so far is structured in an opinionated way, making it difficult to implement this flexibly. The easiest way may just be introducing a second trait "BigEndianFixedInt" (or a more elegant name), which also permits sharing the macro code. Unless you have a better idea?

I will take a look at this in the next few days (hopefully), so stay tuned.

@dermesser dermesser self-assigned this Jun 22, 2022
@changrui0608
Copy link
Contributor Author

For my needs, I recently found they're kind of unique, I think I eventually have to re-invent something else to meet my needs, then I'm gonna to close this issue, since I may not depends on this on my current work.

Supporting multiple endians may helps people in the future, you may look at this with your plan.

On the implementation way, I personally agree with the easiest way of introcuding new traits, both "BigEndianFixedInt" and shorter "BeFixedInt" sounds good to me, "LittleEndianFixedInt" or "LeFixedInt" could be retained for future, the original "FixedInt" is in machine's endian, everything is explicit, which is good.

Still, thanks for responses.

@changrui0608 changrui0608 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 23, 2022
@dermesser
Copy link
Owner

So far I simply decided (see README) that fixed ints here are going to be LE, but I agree that switching byte orders is useful.

A very simple alternative I came up with - even though not as elegant - is an endian reversal function. Given that FixedInt currently guarantees LE everywhere, reversing will guarantee BE. I will implement this as a stop-gap.

dermesser added a commit that referenced this issue Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants