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

i128/u128 support #2

Closed ckaran closed 2 years ago

ckaran commented 2 years ago

Hi, I attempted to add in in i128 and u128 support (see https://github.com/ckaran/binary-layout/tree/iu128), but I'm getting the strangest failure. Would you be willing to take a look before I try to turn this into a proper PR?

smessmer commented 2 years ago

Sure, what's the error? If you open a PR with it, we can run CI for it and I can take a look at the error message there

ckaran commented 2 years ago

Will do. I'll keep the branch separate so that it doesn't pollute master. The failure is a test error failure; I copied and modified the tests for *64 to *128, with modest modifications to make it work with *128. The test failure is below:

failures:

---- fields::primitive::tests::test_i128_bigendian stdout ----
thread 'fields::primitive::tests::test_i128_bigendian' panicked at 'assertion failed: `(left == right)`
  left: `1000000000000000000000000000000`,
 right: `1000000000000000000000000000255`', src/fields/primitive.rs:489:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    fields::primitive::tests::test_i128_bigendian

test result: FAILED. 72 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Edit

Done.

smessmer commented 2 years ago

https://github.com/smessmer/binary-layout/pull/4