This change adds a From<i32> impl for the GrpcCode enum. This allows users to easily convert the result of the GrpcErrorsAsFailures back into an enum.
Fixes: #505
Motivation
I recently had to implement a custom TraceLayer on-failure struct, and it made sense to reuse the GrpcErrorsAsFailures class to extract the status. Unfortunately, it returns the error code as a NoneZeroI32 but tower_http doesn't have a convenient way to map this back to the num.
Implementing this is trivial, but still feels like a reasonable addition to this library.
Solution
I feel like this solution is pretty self-explanatory :).
This change adds a
From<i32>
impl for the GrpcCode enum. This allows users to easily convert the result of theGrpcErrorsAsFailures
back into an enum.Fixes: #505
Motivation
I recently had to implement a custom
TraceLayer
on-failure struct, and it made sense to reuse theGrpcErrorsAsFailures
class to extract the status. Unfortunately, it returns the error code as aNoneZeroI32
but tower_http doesn't have a convenient way to map this back to the num.Implementing this is trivial, but still feels like a reasonable addition to this library.
Solution
I feel like this solution is pretty self-explanatory :).