gcloud_token/
lib.rs

1use std::fmt::Debug;
2use std::sync::Arc;
3
4use async_trait::async_trait;
5
6#[async_trait]
7pub trait TokenSource: Send + Sync + Debug {
8    /// token returns the valid token
9    async fn token(&self) -> Result<String, Box<dyn std::error::Error + Send + Sync>>;
10}
11
12pub trait TokenSourceProvider: Send + Sync + Debug {
13    /// token returns the token source implementation
14    fn token_source(&self) -> Arc<dyn TokenSource>;
15}
16
17#[derive(Debug)]
18pub struct NopeTokenSourceProvider {}
19
20impl TokenSourceProvider for NopeTokenSourceProvider {
21    fn token_source(&self) -> Arc<dyn TokenSource> {
22        panic!("This is dummy token source provider. you can use 'google_cloud_auth' crate")
23    }
24}