I have an original body of a gRPC request that I want to decode to a Protobuf Message using Prost (and probably Tonic).
As I see the HTTP body part consist of a grpc-header
+ protobuf-message
. In my case the header is just 5 bytes like 000000003b
, which to my understanding are some gRPC flags (all zeroes) and length (3b
) of the actual message. I receive just as bytes as part of other payload, it's not a http request by itself only its bytes, so don't have Request
or other data provide by Tonic.
I looked at the Tonic's source code and I found some code to process it, but I'm not sure how I supposed to call it. My understanding that I should use ProstCodec
and give a DecodeBuf
as an input. But I don't see a way to create an instance of it. Its ::new
is crate-only and there is no From
/TryFrom
. So my guess it should not be used from an external code. And I cannot use ProstCode
directly then.
So my question is how to process the original gRPC body and decode a message from it? Is there any wrapper around ProstCodec
that I can use?