tagged-serde

Crates.iotagged-serde
lib.rstagged-serde
version0.1.0
sourcesrc
created_at2024-03-28 18:49:02.01573
updated_at2024-03-28 18:49:02.01573
descriptionA procedural macro for serde enums with integer tags
homepage
repositoryhttps://github.com/tweag/nix-remote-rust
max_upload_size
id1189265
size7,413
(jneem)

documentation

README

tagged-serde

This crate has a procedural macro for generating serde implementations for enums (a.k.a. tagged unions) with integer tags. In the absence of thorough documentation, the main idea is that

#[derive(TaggedSerde)]
enum MyEnum {
  #[tagged_serde = 1]
  Str(String),
  #[tagged_serde = 42]
  Int(i32),
}

will define serde::Serialize and serde::Deserialize implementations for MyEnum so that MyEnum::Str("hi") will get serialized as (1, "hi") and MyEnum::Int(5) will get serialized as (42, 5).

Commit count: 64

cargo fmt