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

Add Little Endian variants for Read/WriteExt #1915

Open
wants to merge 4 commits into
base: master
from

Conversation

@leshow
Copy link

leshow commented Dec 6, 2019

Motivation

There are functions to read in big endian format but not little endian, as mentioned on reddit.

Solution

Add read/write methods to AsyncReadExt and AsyncWriteExt that allow reading/writing in little endian.

Looks like these methods are all generated with macros, I'll add *Le variants of all the read/write types and then implement them in AsyncReadExt and AsyncWriteExt respectively.

I'm submitting a WIP MR to make sure I'm on the right track, I'll complete the docs and AsyncWriteExt shortly.

Tests are now fixed and everything appears to work correctly. I kept the test input the same between le and be variants.

leshow added 4 commits Dec 6, 2019
@leshow leshow changed the title WIP: Add Little Endian variants for Read/WriteExt Add Little Endian variants for Read/WriteExt Dec 7, 2019
@Kobzol

This comment has been minimized.

Copy link
Contributor

Kobzol commented Dec 7, 2019

Could this be parametrized with a type argument, same as in https://docs.rs/byteorder/1.1.0/byteorder/trait.ReadBytesExt.html?

@leshow

This comment has been minimized.

Copy link
Author

leshow commented Dec 7, 2019

The underlying crate tokio uses is the bytes crate, from which I copied the naming convention https://docs.rs/bytes/0.5.2/bytes/buf/trait.Buf.html#method.get_u16_le

This is the same naming that is used in std as well with methods like from_le

If you decide to move in a different direction, I can change this PR, but I think following the familiar naming convention is probably a good idea.

@Kobzol

This comment has been minimized.

Copy link
Contributor

Kobzol commented Dec 7, 2019

Ok, you're right, byteorder does it differently, but std and bytes use this convention, so it's a better idea for tokio as well I guess. Thanks for the PR btw! I need it in my use case.

@leshow

This comment has been minimized.

Copy link
Author

leshow commented Jan 9, 2020

Any update on this?

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

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.