Introduce IntoDynChannelCredentials trait for flexible channel creds.#2674
Introduce IntoDynChannelCredentials trait for flexible channel creds.#2674nathanielford wants to merge 1 commit into
Conversation
…tials. To support creating channels with various credentials configurations, we need to accept different credential representations (such as concrete types or Arc-wrapped trait objects). This trait provides a common conversion interface to type-erase these representations internally. This refactoring is isolated to its own commit to keep subsequent feature commits focused and legible.
dfawley
left a comment
There was a problem hiding this comment.
I'm not sure I understand exactly why this change is needed. I think we want to convert into the Dyn version of the trait internally, and not expose that trait to anyone else.
We already have the blanket impl of DynChannelCredentials -- why isn't that good enough? Is it because the blanket impl specifies T::Output more narrowly than the channel builder does?
|
@arjan-bal I'm looking into other ways of achieving this, per Doug's comment about this maybe not being necessary, but you can look at what I'm attempting with the channel type builder here: master...nathanielford:grpc-rust-nford:implement/channel-builder As soon as that's stable I'll create it's own PR for it, which currently relies on this PR, but if we decide we don't need it I can excise this chunk easily. |
|
@nathanielford, I was looking at For context, the constructor accepts an An alternative approach I considered was defining a wrapper struct: pub struct SharedChannelCreds {
inner: Arc<dyn DynChannelCredentials>,
}The channel constructor would then accept This prevents double |
To support creating channels with various credentials configurations, we need to accept different credential representations (such as concrete types or Arc-wrapped trait objects). This trait provides a common conversion interface to type-erase these representations internally. This refactoring is isolated to its own commit to keep subsequent feature commits focused and legible.
Motivation
When working on the Channel builder, it became clear having into traits for
DynChannelCredentialswould be useful. Because this trait is private, being able to automatically convert public implementors of theChannelCredentialstrait to what we are using internally was the ergonomic option.Solution
Add the into traits, update the relevant public traits to support it.