ex3_ic_agent/agent/
agent_config.rs

1use crate::{
2    agent::{NonceFactory, NonceGenerator, Transport},
3    identity::{anonymous::AnonymousIdentity, Identity},
4};
5use std::{sync::Arc, time::Duration};
6
7/// A configuration for an agent.
8pub struct AgentConfig {
9    /// See [`with_nonce_factory`](super::AgentBuilder::with_nonce_factory).
10    pub nonce_factory: Arc<dyn NonceGenerator>,
11    /// See [`with_identity`](super::AgentBuilder::with_identity).
12    pub identity: Arc<dyn Identity>,
13    /// See [`with_ingress_expiry`](super::AgentBuilder::with_ingress_expiry).
14    pub ingress_expiry: Option<Duration>,
15    /// The [`with_transport`](super::AgentBuilder::with_transport).
16    pub transport: Option<Arc<dyn Transport>>,
17}
18
19impl Default for AgentConfig {
20    fn default() -> Self {
21        Self {
22            nonce_factory: Arc::new(NonceFactory::random()),
23            identity: Arc::new(AnonymousIdentity {}),
24            ingress_expiry: None,
25            transport: None,
26        }
27    }
28}