grpc / grpc/grpc-rust

Implement serde traits for `tonic_types::Status`

Open
#2,059 0 comments 5 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
12.5k
Forks
1.3k
Avg merge
4d 7h
Merged PRs (30d)
24

Description

## Feature Request

### Crates

tonic_types

### Motivation

I'm working with a gRPC API that uses both Well Known Types and Google's RPC types. I've setup the extern paths as such:

```
.google.protobuf=::pbjson_types
.google.rpc=::tonic_types
```

I'm trying to use `protoc-gen-prost-serde`, but it's failing to generate because some of the protobuf messages embed the Status type which does not implement deserialization. It's throwing this error:

```
the trait `Deserialize<'_>` is not implemented for `tonic_types::Status`
```

From what I've discovered, I can add a type attribute of `#[derive(serde::Serialize)]` to the types that I'm generating, but because I'm "linking" to the tonic_types library, I don't believe I can modify the `Status` type to support serialization without modifying upstream.

### Proposal

Have a feature for enabling the dependency on serde in the tonic_types crate.
I'm not a regular Rust programmer these days, so I'm probably not the best source of ideas.

### Alternatives

Would be super happy to hear any if I'm missing something!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.