serde-typeinfo 0.1.0

Runtime type info based on serde data model
Documentation
  • Coverage
  • 28.95%
    22 out of 76 items documented14 out of 22 items with examples
  • Size
  • Source code size: 38.11 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.55 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 21s Average build duration of successful builds.
  • all releases: 21s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • termoshtt/serde-typeinfo
    15 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • termoshtt

serde-typeinfo

"Serialize" type info to a runtime tag based on serde data model.

Examples

  • u8 integer will be "serialized" into Primitive::U8 enum without its value
use serde_typeinfo::{TypeTag, Primitive};

assert_eq!(
    TypeTag::from_value(&32_u8),
    TypeTag::Primitive(Primitive::U8), // only tag, not includes 32
);
  • User defined struct with serde::Serialize trait implementation will be "serialized" into TypeTag::Struct as its name and its fields' names and types, not includes values.
use serde_typeinfo::{TypeTag, Primitive};
use serde::Serialize;

#[derive(Serialize)]
struct A {
    a: u8,
    b: u8,
}

assert_eq!(
    TypeTag::from_value(&A { a: 2, b: 3 }),
    TypeTag::Struct {
        name: "A",
        fields: vec![
            ("a", Primitive::U8.into()),
            ("b", Primitive::U8.into()),
        ]
    }
);

License

© 2023 Toshiki Teramura (@termoshtt)

This project is licensed under either of

at your option.