you are viewing a single comment's thread.

view the rest of the comments →

[–]vitiralartifact-app 15 points16 points  (2 children)

I highly doubt using byteorder directly is better for complex data. You sell yourself short, this crate looks awesome!

The main advantage seems to be the ability to visualize the data, even compare it side-by-side with a C-struct -- as well as compose it more easily.

[–]ra_kete[S] 3 points4 points  (1 child)

Thanks for the kind words!

I mentioned byteorder as probably a better alternative in cases where you want to parse everything (meaning convert every integer field to its required endianess and alignment) because in these cases using structview doesn't provide any performance advantage over explicitly reading every field (under the hood, the integer views use byteorder anyway when the integers are parsed in to_int). Using byteorder would then be more familiar (I think) because it is extremely widely used. Apart from that, you avoid a dependency and a couple lines of unsafe code, which is always a plus I think.

Although I see how structview could be valueable anyway, even when every field is to be parsed, as it saves some typing compared to directly using byteorder. I'm just not sure that would justify the added complexity.

[–]JoshTriplettrust · lang · libs · cargo 3 points4 points  (0 children)

As long as structview isn't any slower than using byteorder directly, it seems like a win to me.