bufbuild / protovalidate

Protocol Buffer Validation - Go, Java, Python, and C++ Beta Releases!
https://buf.build/bufbuild/protovalidate
Apache License 2.0
914 stars 37 forks source link

[Feature Request] support for Rust language #33

Open ivanitskiy opened 1 year ago

ivanitskiy commented 1 year ago

Feature description:

It would be really nice to support Rust language. There is a number of Protocol Buffer implementations for Rust, and post, rust-protobuf are one of them.

Problem it solves or use case:

Enables Rust ecosystem to have consistent validation for code written in Rust.

Proposed implementation or solution:

Contribution:

Examples or references:

Additional context:

Linking this issue https://github.com/bufbuild/protoc-gen-validate/issues/457 this is from the PGV project for reference

elliotmjackson commented 1 year ago

Hi @ivanitskiy, thanks for bringing up the idea of adding Rust support to protovalidate. I can see how this could be really beneficial for those working in the Rust ecosystem.

Just to set expectations, we don't have plans to work on this at the moment. But, knowing that there’s interest is really valuable, and I'm open to hearing more about what you have in mind.

If you or anyone in the community is interested in contributing, that would be amazing. Specifically, implementing Rust support would require building a CEL (Common Expression Language) interpreter in Rust. This would be a crucial component for validation logic. If that's something you or others might be up for tackling, we would be incredibly appreciative. Community contributions really make a difference.

Feel free to reach out if you have any questions or need more information - we will always offer support if this is something you would like to attempt.

ivanitskiy commented 1 year ago

A quick search led me to this not implemented crate protoc-gen-prost-validate. The idea of protoc-gen-prost project is to provide a collection of protoc plugin that generates code using the Prost! code generation engine.

felschr commented 1 year ago

It would be great to see some collaboration between buf & @neoeinstein's protoc-gen-prost.

derekperkins commented 1 year ago

The first library is new and active, the other two aren't, so at least there's a baseline for anyone interested in contributing

Alternatively, it might be easier to bind to the core C++ implementation: https://github.com/google/cel-spec

Adphi commented 1 month ago

We needed to cover the functionality of protoc-gen-validate (legacy) and ended up implementing it. It's available here. At one point we could investigate implementing protovalidate in Rust, but we found that the comparison between the implementation using prost-reflect and the one using derive based code generation showed that reflection based validation crushes the performance.