#protocols #macro #silkroad #define

skrillax-protocol

Macro to build up a protocol for use with skrillax-stream

3 unstable releases

0.2.0 Oct 27, 2024
0.1.1 Jul 1, 2024
0.1.0 Jun 22, 2024

#1291 in Network programming

42 downloads per month

MIT license

105KB
1.5K SLoC

skrillax-protocol

Crates.io Docs.rs

This crate provides a simple macro, define_protocol!, which generates a lot of the boilerplate involved in working with protocols. While it's not inherently complicated to write that code manually, it becomes quite tedious for several packets and included other protocols. Please see the docs for more information and usage information.


lib.rs:

Provides a macro to create 'protocols'.

This expected to be used for the [skrillax_stream] crate.

A protocol defines a set of opcodes and their respective structures. It is essentially a mapping of opcode -> struct. To encourage more static dispatch and better developer ergonomics, we want to provide a nice way of constructing these mappings. Otherwise, this would become quite tedious. Additionally, this also generates some convenience functions to automatically move between different protocols that are related.

The macro to use is the [define_protocol!] macro - any other macro exports are just helper macros and should be ignored.

Dependencies

~6–15MB
~184K SLoC