tikv / grpc-rs

The gRPC library for Rust built on C Core library and futures
Apache License 2.0
1.81k stars 253 forks source link

Q: is it possible to use grpc-rs with plain C based Protocol Buffers? #592

Open mw66 opened 2 years ago

mw66 commented 2 years ago

Hi,

Maybe this is a silly question: but is it possible to use grpc-rs with plain C based Protocol Buffers ? e.g.

https://github.com/nanopb/nanopb (for memory restricted system).

https://github.com/protobuf-c/protobuf-c

I think the output of those library are just C's struct, is it possible to use grpc-rs with these struct to achieve network communication?

Thanks!

BusyJay commented 2 years ago

Yes, but since grpc-rs is written in Rust, you may need to build up some bindings between C library and Rust.

grpc-rs runtime is developed without depending on specific codec, you can provide your known codec, check how it works in https://github.com/tikv/grpc-rs/blob/master/src/codec.rs. But gRPC is hard to used without a compiler, and compiler has to depend on specific codec. So to use a different protobuf library, you need to 1. provide codec function, 2. write a grpc compiler.