Skip to content

Implement serde traits for tonic_types::Status #2059

Open
@jzelinskie

Description

@jzelinskie

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions