Below you will find pages that utilize the taxonomy term “Google”
Posts
read more
Rust Tonic `serde::Serialize`'ing types including Google's WKTs
I’m increasing using Rust in addition to Golang to write code. tonic is really excellent but I’d been struggling with coupling its generated types with serde_json because, by default, tonic doesn’t generate types with serde::Serialize annotations.
For what follows, the Protobuf sources are in Google’s googleapis repo, specifically google.firestore.v1.
(JSON) serializing generated types
For example, I’d like to do the following:
use google::firestore::v1::ListenRequest;
async fn mmain() -> Result<(), Box<dyn std::error::Error>> {
...
let rqst = ListenRequest { ... };
let json_string = serde_json::to_string(&rqst)?;
dbg!(json_string);
}
Yields: