Skip to main content

lc_chains/router_chain/
destination.rs

1// lc-chains/src/router_chain/destination.rs
2//! Route destination for the router chain.
3
4use std::sync::Arc;
5
6use crate::base::BaseChain;
7
8/// Route destination.
9pub struct RouteDestination {
10    /// Destination name.
11    name: String,
12    /// Destination description (used for routing decisions).
13    description: String,
14    /// Destination Chain.
15    chain: Arc<dyn BaseChain>,
16    /// Keyword list (used for keyword-based routing).
17    keywords: Vec<String>,
18}
19
20impl RouteDestination {
21    /// Create a new route destination.
22    pub fn new(
23        name: impl Into<String>,
24        description: impl Into<String>,
25        chain: Arc<dyn BaseChain>,
26    ) -> Self {
27        Self {
28            name: name.into(),
29            description: description.into(),
30            chain,
31            keywords: Vec::new(),
32        }
33    }
34
35    /// Set the keyword list used for keyword-based routing.
36    pub fn with_keywords(mut self, keywords: Vec<&str>) -> Self {
37        self.keywords = keywords.into_iter().map(String::from).collect();
38        self
39    }
40
41    /// Get the destination name.
42    pub fn name(&self) -> &str {
43        &self.name
44    }
45
46    /// Get the destination description.
47    pub fn description(&self) -> &str {
48        &self.description
49    }
50
51    /// Get the destination chain.
52    pub fn chain(&self) -> &Arc<dyn BaseChain> {
53        &self.chain
54    }
55
56    /// Get the keyword list.
57    pub fn keywords(&self) -> &[String] {
58        &self.keywords
59    }
60}