tokio-rs / bytes

Utilities for working with bytes
MIT License
1.91k stars 288 forks source link

Add native-endian variants for all `get_x` and `put_y` functions in `Buf` and `BufMut` #576

Closed Phantomical closed 1 year ago

Phantomical commented 2 years ago

This PR introduces native-endian variants of all the get_x functions in Buf and put_y functions in BufMut. It is pretty much a straightforward copy-paste-and-tweak for each method. There are a lot of methods though, so this PR ended up being rather big.

My use case for these is that I am trying to use bytes to parse records as generated by perf_event_open. The fields in these use the native endianness of the host so using any of the existing methods on Buf would be wrong.

I've gone over this PR several times and I think that I have caught all the copy-paste errors but there may still be some that I missed.

Fixes #549.

Phantomical commented 1 year ago

@Darksonn what is needed to get this merged? The loom test failure is unrelated (and seems to be due to that workflow using an out-of-date toolchain).

Darksonn commented 1 year ago

Once I get around to fixing the loom test, I'll merge this. If you want, you're also welcome to submit a PR that fixes the loom test.

Phantomical commented 1 year ago

I've gone and submitted #577. This PR should be good to go whenever you have time :)

Darksonn commented 1 year ago

Thanks!