quinn
quinn copied to clipboard
Create C/CPP bindings
Hi. Thanks for quinn. I want to call QUINN from C/CPP. How can I create a C/CPP bindings?
You can use Rust's FFI for that. Note that the high-level quinn crate relies on tokio, which will be difficult to interoperate with from C/C++. Binding quinn-proto and using it with an existing C/C++ event loop would make more sense, but is a complicated task in its own right. Additionally, quinn-proto's interface is currently extremely unstable. While this is an interesting use-case that we'd like to support someday, it would be difficult to accomplish at present.
@Ralith Thanks for you reply. Actually I am trying to write an video streaming application. It pulls video stream from the camera and encodes it(this part is done in CPP) then it will send the encoded data to transport protocol(like QUINN). In this case, I can use the TOKIO event loop and pull encoding data from CPP library then send this data with QUINN. This would be easier compared to call QUINN from CPP, right?
So you have pulling video and encoding it in C++, and you want to use the transport code from Quinn in Rust. Now you have to write driver code that pushes the encoded video out over the transport. Clearly it's possible to write the driver in either C++ or Rust, but it's up to you which of those you'd prefer. You might consider which interface is more complex (the video encoding one or the network transport one) and use the language from that one, so you have less work to do in your bindings.