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

Support big endian headers in addition to little endian. #49

Merged
merged 4 commits into from
Dec 11, 2023
Merged

Conversation

de-vri-es
Copy link
Collaborator

Decided to go with a runtime setting. I expect overhead to be negligible.

This is sadly a major change, but in the future we could add config fields with a minor change, since the structs are now marked as non-exhaustive.

But since its a major change now anyway, I didn't preserve backwards compatibility for MessageHeader::encode/decode either.

/// The encoding and serialization of message bodies is up to the application code,
/// and it not affected by this configuration parameter.
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum Endian {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you feel about adding NativeEndian?

Copy link
Collaborator Author

@de-vri-es de-vri-es Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad: if both ends use NativeEndian on different platforms it could theoretically be different.

I'd rather be explicit what it is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, it makes sense for peers using unix sockets.... Hmmm.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could have a constructor that instantiates to one of the two endiannesses..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unix sockets were the use case I had in mind.

We could even forgo Endian for unix transport and just use native endian by default.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could even forgo Endian for unix transport and just use native endian by default.

That's not that easy though. You can use the StreamTransport with Unix stream sockets too.

Copy link
Contributor

@dan-jfisher dan-jfisher Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah good point.

Edit: My PR approvals stands :P

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added NativeEndian anyway ^^

src/transport/endian.rs Outdated Show resolved Hide resolved
src/transport/endian.rs Outdated Show resolved Hide resolved
@de-vri-es de-vri-es merged commit 9691a6b into main Dec 11, 2023
2 checks passed
@de-vri-es de-vri-es deleted the endian branch December 11, 2023 09:40
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

Successfully merging this pull request may close these issues.

3 participants