pub unsafe trait Header:
Clone
+ Sized
+ PartialEq
+ Eq
+ Debug {
// Required methods
fn total_size(&self) -> usize;
fn set_size(&mut self, total_size: usize);
// Provided method
fn payload_len(&self) -> usize { ... }
}Expand description
A sized header type for DynSizedStructure.
Note that header refers to the header pattern. Thus, depending on the use
case, this is not just a tag header. Instead, it refers to all bytes that
are fixed and not part of any optional terminating dynamic [u8] slice in a
DynSizedStructure.
The alignment of implementors must be compatible with the requirements
for the corresponding structure, which typically is ALIGNMENT.
§Safety
Implementors must be #[repr(C)], have no padding bytes or interior
mutability, allow every bit pattern, and have an alignment of at most
ALIGNMENT. Headers are referenced from raw memory and copied byte-wise.
Required Methods§
Sourcefn total_size(&self) -> usize
fn total_size(&self) -> usize
Returns the total size of the structure in bytes, including the fixed header and any dynamic payload.
Provided Methods§
Sourcefn payload_len(&self) -> usize
fn payload_len(&self) -> usize
Returns the length of the payload, i.e., the bytes that are additional to the header. The value is measured in bytes.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".