#[derive(Archive)]
{
// Attributes available to this derive:
#[archive]
}
Available on crate features
archive and derive only.Expand description
Derives the zero-copy archived mirror used by
rustbinary::archive::build / OwnedArchive / MappedArchive.
For a named struct, Archive generates:
- the
Archived{Name}mirror (#[repr(C)], derivedClone+Copy) whose fields are the archived forms of the source fields, - the
rustbinary::archive_codec::Archiveimpl, - the
rustbinary::archive_codec::ArchivedValuemarker, - the
rustbinary::archive_codec::CheckBytesstructural validator that bounds-checks every relative offset, length, and range in one pass.
Supported field types: scalar primitives (u8…f64, no bool),
String, Vec<T> of a scalar or of a nested archived struct, and a
nested archived struct field. bool is rejected: it has no
ArchivedValue (not every byte pattern is a valid bool) and would make
zero-copy element slices unsound. Generic type parameters, enums, unions,
Vec<String>, and nested Vec<Vec<…>> are rejected with a compile
error rather than generating subtly wrong code.