Trait zero::Pod [] [src]

pub unsafe trait Pod: Sized { }

Implementing this trait means that the concrete type is plain old data (POD). Precisely, by implementing Pod the programmer asserts that it is safe to read the type from binary slices provided to read, etc.

Some guidelines for when Pod may be implemented (note that whether Pod should be implemented or not is a function of both the type and the input data. I.e., just because a type is Pod in one context does not mean it should be in another): * primitive numeric types (u8, i64, f32, etc.) are fine, * bools are fine, if the provided data ensures they may have only the values 0 or 1 (note that this is a stricter requirement that C), * structs containing only Pod data are fine, * structs must be repr(C) or repr(packed), if the former, the supplied data must have the correct alignment, * enums must have valid discriminants in the supplied data, this is probably only feasible if they have a specified representation, * there must not be invalid enum variants in the data, * any kind of pointer is probably a bad idea. Theoretically one could make raw pointers work.

Implementors