Closed jwerle closed 3 years ago
actually that tells me MutSlice is poorly named. while MutSlice is a writer with a write state, Slice does not have a read state
oh wait, completely missed the offset. i guess you CAN read multiple packed integers that way, so the name is fine. just change the docs to say
/// read 8 bytes from offset as a u64 in host endianess
or something similar that mentions offset
and make sure the endianess is actually host endianness. I believe shift is defined endianness independant, so your code is wrong on one or the other? i'm not sure. shift and endianess confuses me alot.
@aep Yeah I am rewriting to use the byteorder
module and make to_u{8,16,32,64}{be,le}()
variants. I can rename to_
back to read
host endianess is fine, push8 does that too.
i'm just using memcpy in push because shift is so confusing. But if you can verify your code is always using host endianess, its fine
@aep just pushed up some changes if you are free to take a look
makes sense to have, but not happy about the naming
read implies you can read multiple packed integers, but actually this is a conversion function and it ignores endianess.
i'd rather call it to_u8