Skip to main content

tap_agent/
config.rs

1//! Configuration for the TAP Agent
2
3use crate::error::Result;
4use std::collections::HashMap;
5
6/// Configuration options for a TAP Agent
7#[derive(Debug, Clone)]
8pub struct AgentConfig {
9    /// Agent DID
10    pub agent_did: String,
11
12    /// Security mode for messages
13    pub security_mode: Option<String>,
14
15    /// Enable debug mode
16    pub debug: bool,
17
18    /// Timeout in seconds for network operations
19    pub timeout_seconds: Option<u64>,
20
21    /// Additional configuration parameters
22    pub parameters: HashMap<String, String>,
23}
24
25impl AgentConfig {
26    /// Creates a new AgentConfig with the specified DID
27    /// Default security mode is SIGNED
28    pub fn new(did: String) -> Self {
29        Self {
30            agent_did: did,
31            security_mode: Some("SIGNED".to_string()),
32            debug: false,
33            timeout_seconds: Some(30),
34            parameters: HashMap::new(),
35        }
36    }
37
38    /// Sets a configuration parameter
39    pub fn set_parameter(&mut self, key: &str, value: &str) {
40        self.parameters.insert(key.to_string(), value.to_string());
41    }
42
43    /// Gets a configuration parameter
44    pub fn get_parameter(&self, key: &str) -> Option<&String> {
45        self.parameters.get(key)
46    }
47
48    /// Sets the security mode
49    pub fn with_security_mode(mut self, mode: &str) -> Self {
50        self.security_mode = Some(mode.to_string());
51        self
52    }
53
54    /// Sets the debug mode
55    pub fn with_debug(mut self, debug: bool) -> Self {
56        self.debug = debug;
57        self
58    }
59}
60
61impl Default for AgentConfig {
62    fn default() -> Self {
63        Self::new("default_did".to_string())
64    }
65}
66
67/// Validates an Agent configuration for required fields
68pub fn validate(_config: &AgentConfig) -> Result<()> {
69    // TODO: Add validation logic here
70    Ok(())
71}