I am using yup_oauth2 and attempting to create a Token
source that implements the GetToken
trait for use on Google Compute Engine.
pub trait GetToken {
fn token<'b, I, T>(&mut self, scopes: I) -> Result<Token, Box<Error>>
where
T: AsRef<str> + Ord + 'b,
I: IntoIterator<Item = &'b T>;
fn api_key(&mut self) -> Option<String>;
}
Depending on where the application is running, I want to resolve to different types that implement the above trait but the compiler is not happy because apparently traits with generics are not trait-object safe.
What is the idiomatic way of solving such a problem?