Structure
This crate provides the procedural macro NoCopy to the buffering crate. Buffering is feature
flagged to be able to use only this macro so there is no reason for this to be used outside of
that crate.
Restrictions
This only works currently if the following conditions are met for the data type:
- It is a struct with named fields
- The type of each field is stack allocated
Provided methods
Each struct to which NoCopy is applied will generate a union type to be used for buffer
operations. Traversal works like this:
- The union can be initialized either as a struct assigned to the
.structure()field of the union or using theMyUnionType::new_buffer()method and providing a slice - The union also provides methods
.get_field_nameand.set_field_namethat are generated per struct field - Getters and setters will respect endianness specified by the attribute
#[nocopy_macro(endian = "big")]or#[nocopy_macro(endian = "little")]provided in the original struct
Recognized attributes
Attributes can be added to the struct to specify whether integer types should be interpreted
as big endian values or little endian values in the form #[nocopy_macro(endian = "big")]
or #[nocopy_macro(endian = "little")]. If neither is specified, native endian is assumed for
integers. Another available attribute is provided as #[nocopy_macro(name = "MyUnionNameHere")]
to override the default name for the autogenerated union.