smessmer / binary-layout

The binary-layout library allows type-safe, inplace, zero-copy access to structured binary data. You define a custom data layout and give it a slice of binary data, and it will allow you to read and write the fields defined in the layout from the binary data without having to copy any of the data. It's similar to transmuting to/from a #[repr(packed)] struct, but much safer.
Apache License 2.0
66 stars 9 forks source link

possible to add a NativeEndian marker? #21

Closed carlsverre closed 11 months ago

carlsverre commented 1 year ago

I am using this crate to work with sqlite datastructures of which most are BigEndian. However there is one structure which always uses the current machines native endianness. I would love to use this crate to handle all of my data wrangling however it appears there is no way to disable the explicit endianness conversions? From a cursory glance it looks very possible - what do you think? I can probably take a crack at this if you're ok with it and there are no crazy unknowns.

Thanks!

smessmer commented 1 year ago

Hi, thanks for reaching out. I'm open to adding native endian as long as users have to clearly mark it and it doesn't happen implicitly. I can review the PR if you want to create one.

carlsverre commented 1 year ago

Sounds good! Will take a crack at it. Thanks!