[SAoC 2022] QUIC Protocol : Milestone 1, Part 1

Adam D Ruppe destructionator at gmail.com
Sun Sep 25 22:05:44 UTC 2022


On Sunday, 25 September 2022 at 20:51:49 UTC, Vlad Chicoș wrote:
> Converting an array of bytes into usable data structures is an 
> interesting problem as both the size of the fields and their 
> number can vary.

You probably want to treat it like deserializing a stream instead 
of trying to paint the struct directly over the content.

If there's just a few possibilities, you might express it as a 
union and button that up behind some property getters to keep it 
consistent... but really having a simple struct with the work 
done in a "loadFromPacket" kind of function is less likely to 
have bugs.


More information about the Digitalmars-d mailing list