Expand description
Proc-macro derives for the nlink Linux-netlink
library — typed GENL family / command / attribute / message
codecs.
Don’t depend on this crate directly. Use nlink and write
use nlink::macros::*; to pull in every macro plus the
supporting traits in one shot. See the README + the
define-your-own-genl-family recipe for end-to-end
usage; the runnable example lives at
crates/nlink/examples/macros/define_taskstats.rs.
§Shipped surface (0.16, Plan 154 Phases 1–6)
GenlCommand+#[genl_command(repr = "u8"|"u16")]— typed GENL command enumGenlAttribute+#[genl_attribute(repr = "u8"|"u16")]— typed attribute-kind enumGenlEnum+#[genl_enum(repr = "u8"|"u16"|"u32")]— typed value enum encoded inside an attribute payloadGenlMessage+#[genl_message(cmd = ...)]+ per-field#[genl_attr(...)]— typed request/response body. Pairs with the genericConnection::<F: GenlFamily>::send_typed<M, R>/dump_typed_stream<M, R>dispatch innlink.genl_family—#[genl_family(name = "...", version = N)]rewrites a unit-struct declaration into a complete family marker (ProtocolState+AsyncProtocolInit+GenlFamily+ sealed-trait impls +family_idfield +Default/Debug).
The three codec derives (GenlCommand, GenlAttribute,
GenlEnum) produce the same shape — From<EnumType> for ReprType + TryFrom<ReprType> for EnumType + a small
EnumTypeUnknownValue(repr) error newtype.
§Deferred follow-up
#[derive(NetlinkAttrs)] for nested attribute groups
(NLA_F_NESTED) is tracked as a Plan 154 follow-up. The
nlink::macros::NetlinkAttrs trait is already in tree so
hand-implementations work today; the derive will close the
last remaining “hand-roll this bit” gap.
Doc examples in this crate are ```text, not compiled: they show
the derives being applied, which needs both this crate and nlink in
scope, and nlink-macros cannot depend on nlink without a cycle. The
compiled versions live in nlink’s own documentation and in
crates/nlink/examples/macros/define_taskstats.rs.
Attribute Macros§
- genl_
family - Declare a Generic Netlink family marker.
Derive Macros§
- Genl
Attribute - Derive a typed-enum codec for a Generic Netlink attribute kind enum.
- Genl
Command - Derive a typed-enum codec for a Generic Netlink command ID enum.
- Genl
Enum - Derive a typed-enum codec for a value enum encoded inside an attribute payload (rather than as the attribute kind itself).
- Genl
Message - Derive
nlink::macros::GenlMessagefor a struct-shaped GENL message body. - Netlink
Attrs - Derive
NetlinkAttrsfor a nested attribute group — a struct the kernel encodes as the contents of a singleNLA_F_NESTEDattribute.