Skip to main content

SecretService

Trait SecretService 

Source
pub trait SecretService: Send + Sync {
    // Required method
    fn get_secret<'life0, 'life1, 'async_trait>(
        &'life0 self,
        name: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<String, AdkError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Expand description

Trait for retrieving secrets at runtime.

This is the core-level abstraction used by [ToolContext::get_secret] and InvocationContext::get_secret. Concrete implementations (e.g., AWS Secrets Manager, Azure Key Vault, GCP Secret Manager) live in adk-auth behind feature flags and implement this trait via the SecretProvider adapter.

§Example

use adk_core::SecretService;

struct EnvSecretService;

#[async_trait::async_trait]
impl SecretService for EnvSecretService {
    async fn get_secret(&self, name: &str) -> adk_core::Result<String> {
        std::env::var(name).map_err(|_| adk_core::AdkError::not_found(
            format!("secret '{name}' not found in environment"),
        ))
    }
}

Required Methods§

Source

fn get_secret<'life0, 'life1, 'async_trait>( &'life0 self, name: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<String, AdkError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Retrieve a secret value by name.

Returns the secret string on success, or an AdkError on failure.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§