pub unsafe trait Pod { }Expand description
We use this Pod trait to implement / constraint the *read_struct
functions. For the functions to work as expected and be safe, here is the
rule that a type T needs to follow to be Pod:
Tshould not contain a field / type that have invalid bit patterns (nochar, nobool, no pointers). We will read bytes from a file and basicallytransmutethose bytes toTso all possible bit patterns should be ‘fine’.
§Safety
Implementing this trait for a type T requires that T is safe to
initialize from any arbitrary bit pattern. This means:
Tmust not contain types with invalid bit patterns (e.g.,bool,char, references, pointers)- All possible byte patterns must represent valid values of
T - This is required because bytes are read from a file and transmuted to
T