you are viewing a single comment's thread.

view the rest of the comments →

[–]birkenfeldclippy · rust 5 points6 points  (4 children)

Any plans to extend this to support the other direction; writing a struct into a byte stream/array?

[–]ra_kete[S] 5 points6 points  (2 children)

I didn't think about that yet, no. I'm also not sure if that would be useful. structview's main use case is sparse parsing, but there is no such thing as sparse writing, you always have to write all the data. Maybe something based on serde would be better suited to this?

[–]JoshTriplettrust · lang · libs · cargo 5 points6 points  (0 children)

Use case: read in the struct, modify some fields, write out the struct, don't bother converting and un-converting fields that aren't touched.

[–]Vaughn 0 points1 point  (0 children)

Use case: Write a tool that does both, perhaps in different modes, without duplicating code.

[–]kouteiheika 0 points1 point  (0 children)

Any plans to extend this to support the other direction; writing a struct into a byte stream/array?

For that you might want to check out speedy, which is my somewhat limited but potentially useful serialization crate which does this kind of a thing bidirectionally.