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

Big endian encoding attribute #145

Open
delbonis opened this issue Jun 23, 2024 · 0 comments
Open

Big endian encoding attribute #145

delbonis opened this issue Jun 23, 2024 · 0 comments

Comments

@delbonis
Copy link

delbonis commented Jun 23, 2024

For network protocols, there is an established convention to encode integers as big endian. Borsh isn't designed specifically for network protocols, but with its compactness and its other nice properties, it's also fairly well-suited for defining network protocols.

Implementation wise, after reasoning through a few different stragies, I believe it would make the most sense to implement this by defining an attribute that can be defined on a struct or a field that has a #[derive(BorshSerialize, BorshDeserialize)] to indicate the integer encoding policy just for integers in that scope. This is fairly backwards compatible and allows types with little endian integers to be used interchangeably mixed in with types that use big endian ones.

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

1 participant