- 
                Notifications
    
You must be signed in to change notification settings  - Fork 207
 
Description
- I have looked for existing issues (including closed) about this
 
Feature Request
GrpcCode does not provide the required From<T> implementations to easily be used over a tonic server that returns a tonic::Status with a tonic::Code. These logically are the same concept, but cannot be converted between these enums (and the numerical representaions) except by implementing your own matching logic.
Motivation
We are implementing a GrpcErrorsAsFailures for a tracing layer on top of a tonic server, and this returns a GrpcFailureClass::Code(NonZeroI32). It would be nice to have a simple path to convert this to a GrpcCode so we can leverage this in our tracing to get human-readable code strings.
Proposal
Similarly, if not identical, to impl From<i32> for tonic::Code.
Alternatives
The alternative is that users have to implement from_i32 or similar as methods themselves, which is potentially more error-prone than using a standard and common implementation, especially if gRPC status codes are changed in the future (such as to add new enumerated values for additional statuses).