Crates.io | prost-serde-derive |
lib.rs | prost-serde-derive |
version | 0.1.5 |
source | src |
created_at | 2022-12-19 04:20:00.980733 |
updated_at | 2024-03-22 06:09:14.046989 |
description | Derive macro for serializing/deserializing structs generated by Prost with Serde |
homepage | https://github.com/segfault87/prost-serde-derive |
repository | https://github.com/segfault87/prost-serde-derive |
max_upload_size | |
id | 740780 |
size | 40,269 |
prost-serde-derive
is a procedural macro for serializing/deserializing structs generated by Prost with Serde.
When using tonic-build, add type attribute to the structs/enums like following:
fn main() {
tonic_build::configure()
.type_attribute("some.proto.SomeStruct", "#[derive(prost_serde_derive::Deserialize, prost_serde_derive::Serialize)]")
// Add following if you have to allow missing non-nullable fields when deserializing (will be filled with the default value)
.type_attribute("some.proto.SomeStruct", "#[prost_serde_derive(use_default_for_missing_fields)]")
// Add following if you have to allow deserializing even if there are type errors
.type_attribute("some.proto.SomeStruct", "#[prost_serde_derive(omit_type_errors)]")
// Serializing/deserializing Prost enumerations are also available
.type_attribute("some.proto.SomeEnum", "#[derive(prost_serde_derive::Deserialize, prost_serde_derive::Serialize)]")
.compile(...);
}
Make sure to include base64 to your dependencies when bytes
type is used in your proto.