#tuple #enums #struct #serde #proc-macro

serde-struct-tuple-enum

Procedural macro for deserializing an enum of structs from tuples

1 unstable release

0.1.0 Jan 1, 2025

#2147 in Rust patterns

Download history 160/week @ 2025-01-01

160 downloads per month
Used in 2 crates (via battler-wamp)

MIT license

3KB

serde-struct-tuple-enum

Latest Version

serde-struct-tuple-enum is a utility crate, built initially for battler-wamp. It provides procedural macros to automatically derive serde's Serialize and Deserialize traits for enum types, where each variant of the enum if a struct that is encoded as a tuple of its fields (specifically using serde-struct-tuple).

battler-wamp uses this macro for all WAMP messages, since WAMP messages are encoded as a list, where the first element determines the message variant.

Dependencies

~0.7–1.3MB
~29K SLoC