durian_macros
Macros for the durian
crate
These should not be used alone! The macros depend on Traits and paths defined in durian
Procedural Macros
Procedural macros for easily annotating structs as Packets
and automatically
implementing PacketBuilders
. The only
requirement is the struct must be de/serializable, meaning all nested fields also need to be
de/serializable.
#[bincode_packet]
will de/serialize your Packet using bincode
and applies necessary derive
macros automatically for you.
use bincode_packet;
// Automatically implements Packet, and generates a PositionPacketBuilder that implements
// PacketBuilder. You can also add other macros such as derive macros so long s they don't
// conflict with what #[bincode_packet] adds (See bincode_packet documentation).
// Works for Unit (empty) structs as well
;
You can also use the derive macros (BinPacket
and UnitPacket
) manually:
use ;
use ;
;
Declarative Macros
Regular macros for easy and concise calls to the PacketManager
.
These include macros for registering all your send
and receive
packets:
register_send!(packet_manager, <send packets>...)
register_receive!(packet_manager, <receive packets>...)
Where the <send packets>
a sequence of your send
packet types, or a slice of those types, and
<receive packets>
are a sequence of tuples containing (your receive
packet type, the associated packet builder),
or a slice of those tuples.
Example:
use ;
// Send packets
;
// Receive packets