doum_cli/llm/anthropic/
secret.rs

1use crate::system::ProviderSecret;
2use anyhow::Result;
3use serde::{Deserialize, Serialize};
4
5/// Anthropic Secret information
6#[derive(Debug, Clone, Default, Serialize, Deserialize)]
7pub struct AnthropicSecret {
8    pub api_key: String,
9}
10
11impl ProviderSecret for AnthropicSecret {
12    fn validate(&self) -> Result<()> {
13        if self.api_key.is_empty() {
14            anyhow::bail!("API key cannot be empty");
15        }
16        Ok(())
17    }
18
19    fn masked(&self) -> String {
20        if self.api_key.len() > 14 {
21            format!(
22                "{}...{}",
23                &self.api_key[..10],
24                &self.api_key[self.api_key.len() - 4..]
25            )
26        } else {
27            "***".to_string()
28        }
29    }
30}