Derive Macro neli_proc_macros::Header
source · [−]#[derive(Header)]
{
// Attributes available to this derive:
#[neli]
}
Expand description
Derives the neli Header
trait for a struct or enum. Unlike
other derive macros in this crate, the Header
derive macro
does not impose type parameter bounds on type parameters.
See the accepted attribute for more information. The reason for
this is that the last field is considered to be the payload.
Because the payload may be represented by a type parameter,
we cannot blindly restrict type parameters or else we impose
an artificial restriction of TypeSize
on the payload type
parameter. This is a problem for the Header
trait as the
payload may be unsized even if the rest of the header is
composed exclusively of statically sized types and are therefore
compatible with the TypeSize
trait.
Acceptable struct attribute is:
#[neli(header_bound = "T: MyTrait")]
which will generate a trait bound in the impl for the specified type parameter.
While there is no implicit type parameter bound, every type
parameter that does not correspond to a payload should have
a specified type parameter bound of TypeSize
.