Crates.io | serde-typeinfo |
lib.rs | serde-typeinfo |
version | 0.1.0 |
source | src |
created_at | 2023-03-28 16:03:28.602443 |
updated_at | 2023-03-28 16:03:28.602443 |
description | Runtime type info based on serde data model |
homepage | |
repository | https://github.com/termoshtt/serde-typeinfo |
max_upload_size | |
id | 823200 |
size | 36,561 |
"Serialize" type info to a runtime tag based on serde data model.
u8
integer will be "serialized" into Primitive::U8
enum without its valueuse serde_typeinfo::{TypeTag, Primitive};
assert_eq!(
TypeTag::from_value(&32_u8),
TypeTag::Primitive(Primitive::U8), // only tag, not includes 32
);
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()),
]
}
);
© 2023 Toshiki Teramura (@termoshtt)
This project is licensed under either of
at your option.