rust-protobuf icon indicating copy to clipboard operation
rust-protobuf copied to clipboard

Add Hash for SpecialFields , in order to enable derive hash in…

Open eyalsatori opened this issue 3 years ago • 1 comments

messag in CustomizeCallback during codegen

eyalsatori avatar Aug 07 '22 19:08 eyalsatori

following https://github.com/stepancheg/rust-protobuf/issues/211 , I tried to implement Hash and Eq with CustomizeCallback but i need Hash to be implement on SpecialFields (and some other structs) . In hash I don't have something equivalent to #[serde(skip)] like in the example in the serde example

eyalsatori avatar Aug 07 '22 19:08 eyalsatori

Added hash to SpecialFields in 6890eba9dbcfb39c09961d800ab56aa894f39243, but Timestamp is generated, it should not be changed manually.

stepancheg avatar Sep 26 '22 00:09 stepancheg

So if I have proto object that include well-known type and I need to implement hash on this object .

what I need to do is to fetch the proto definition from google , and do my customize code generation also on google proto ?

eyalsatori avatar Sep 27 '22 20:09 eyalsatori

Rust-protobuf can be patched to derive Hash for well-known types.

But well known types are generated. Generator need to be patched to patch these files. With some local hack.

Resulting change is correct. But it would be overwritten on next code regeneration if generator is not patched.

stepancheg avatar Sep 27 '22 21:09 stepancheg

cool , thanks !

eyalsatori avatar Sep 29 '22 10:09 eyalsatori