use thiserror::Error;
use zeroize::Zeroizing;
#[derive(Error, Debug)]
pub enum ProviderError {
#[error("Invalid configuration: {0}")]
InvalidConfiguration(String),
#[error("Secret not found: {0}")]
SecretNotFound(String),
#[error("Provider internal error: {0}")]
ClientError(#[from] Box<dyn std::error::Error + Send + Sync>),
}
pub struct ProviderSecret {
pub value: Zeroizing<String>,
pub version: Option<String>,
}
#[async_trait::async_trait]
pub trait VaultProvider: Send + Sync {
async fn get_secret(&self, name: &str) -> Result<ProviderSecret, ProviderError>;
}
#[async_trait::async_trait]
pub trait VaultProviderFactory: Send + Sync {
async fn validate(&self, config: &Zeroizing<String>) -> Result<(), ProviderError>;
async fn create(&self, config: Zeroizing<String>) -> Result<Box<dyn VaultProvider>, ProviderError>;
}