use async_trait::async_trait;
use crate::models::{NewCredential, ProviderKind, RotationError, RotationStyle, Secret};
#[async_trait]
pub trait Connector: Send + Sync {
fn kind(&self) -> ProviderKind;
fn rotation_style(&self) -> RotationStyle;
fn manual_rotation_hint(&self) -> Option<String> {
None
}
async fn connect(&self) -> Result<(), RotationError>;
async fn list_keys(&self) -> Result<Vec<Secret>, RotationError>;
async fn create(&self, secret: &Secret) -> Result<NewCredential, RotationError>;
async fn verify(&self, credential: &NewCredential) -> Result<(), RotationError>;
fn supports_deactivate(&self) -> bool {
false
}
async fn account_name(&self) -> Option<String> {
None
}
async fn current_key_id(&self) -> Option<String> {
None
}
async fn deactivate_old(&self, _external_id: &str) -> Result<(), RotationError> {
Err(RotationError::NotImplemented(format!(
"{} keys have no disabled state",
self.kind().display_name()
)))
}
async fn delete_old(&self, _external_id: &str) -> Result<(), RotationError> {
Err(RotationError::NotImplemented(format!(
"{} keys can't be deleted through this tool",
self.kind().display_name()
)))
}
}