prost
prost copied to clipboard
Disable name conversion for enum items
I'm sorry if I missed something, but going through docs again and again I couldn't find the answer.
Is it possible to disable automatic conversion of names performed by prost-build?
I have a .proto spec that looks like this (I know it's very ugly, but I can't change it, it comes from third-party team "as is"):
enum MyEnum {
CAT = 1,
DOG1 = 2,
DOG2 = 3,
SNAKE_1 = 3,
...
}
and after processing by prost-build
it becomes
pub enum MyEnum {
Cat = 1,
Dog1 = 2,
Dog2 = 3,
Snake3 = 4,
...
}
The problem is, I also need to (de)serialize it with Serde, and that's where things get ugly - Serde isn't able to deduce the correct naming for some fields because naming scheme is inconsistent.
I need to somehow tell prost-build
not to perform conversion of enum items' names. I'm OK with a little bit of warnings on the Rust's side due to breaking naming conventions.
How can I do this automatically without annotating each field by hand?
I think the best solution in this case is to just copy the enum struct and derive serde on that. It might be possible in addition to have serde annotations to process the names.