#protocols #macro #silkroad

skrillax-protocol

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

2 releases

0.1.1 Jul 1, 2024
0.1.0 Jun 22, 2024

#5 in #silkroad

Download history 148/week @ 2024-06-21 206/week @ 2024-06-28 11/week @ 2024-07-05

67 downloads per month

MIT license

97KB
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 ergonimics, 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
~181K SLoC