-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
Feature Request
Tonic's client functions take IntoRequest<T> for the request type. But if I have a type R that implements Into<T>, I can't pass my_r.into() into the function because the type system won't figure out that I want the .into() for T.
If we'd have a generic implementation as below, we could pass an R object into the client method.
impl <R, T: From<R>> IntoRequest<T> for R {
fn into_request(self) -> Request<T> {
T::from(self).into_request()
}
}Motivation
Simplifying calling client functions with custom structs that Into the protobuf requests. I think this is a common pattern. The protobuf messages use only the raw types, so often clients have structs with business logic types and then conversion Into and TryFrom implementations between business-logic structs and protobuf structs.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels