[][src]Macro neli::impl_var

macro_rules! impl_var {
    (
        $( #[$outer:meta] )*
        $vis:vis $name:ident, $ty:ty,
        $(
            $( #[cfg($meta:meta)] )*
            $var:ident => $val:expr
        ),*
    ) => { ... };
}

For naming a new enum, passing in what type it serializes to and deserializes from, and providing a mapping from variants to expressions (such as libc consts) that will ultimately be used in the serialization/deserialization step when sending the netlink message over the wire.

Usage

Create an enum named MyNetlinkProtoAttrs that can be serialized into u16s to use with Netlink. Represents the fields on a message you received from Netlink.

Here is an example specifying the enum visibility:

neli::impl_var!(
   pub MyNetlinkProtoAttrs,
   u16,
   Id => 16u16,
   Name => 17u16,
   Size => 18u16
);

or with doc comments:

 neli::impl_var!(
    /// These are the attributes returned
    /// by a fake netlink protocol.
    MyNetlinkProtoAttrs, u16,
    Id => 16u16,
    Name => 17u16,
    Size => 18u16
 );