Files
Agent-Tools/crates/agentdock-secrets/src/store.rs
T

22 lines
821 B
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! 密钥库抽象接口(架构 §4.1)
use crate::error::SecretStoreError;
/// 系统密钥库封装接口。`service` 固定前缀 `agentdock.<cli_id>`
/// `account` 为字段 id(如 `api_key`)。
pub trait SecretStore: Send + Sync {
/// 写入密钥。
fn set(&self, service: &str, account: &str, secret: &str) -> Result<(), SecretStoreError>;
/// 读取密钥。
fn get(&self, service: &str, account: &str) -> Result<String, SecretStoreError>;
/// 是否存在该密钥条目。
fn has(&self, service: &str, account: &str) -> bool;
/// 删除密钥条目。
fn delete(&self, service: &str, account: &str) -> Result<(), SecretStoreError>;
}
/// 构造 service 名:`agentdock.<cli_id>`。
pub fn service_name(cli_id: &str) -> String {
format!("agentdock.{cli_id}")
}