agp_datapath/
tables.rs

1// Copyright AGNTCY Contributors (https://github.com/agntcy)
2// SPDX-License-Identifier: Apache-2.0
3
4// Copyright AGNTCY Contributors (https://github.com/agntcy)
5// SPDX-License-Identifier: Apache-2.0
6
7pub mod connection_table;
8pub mod errors;
9pub mod remote_subscription_table;
10pub mod subscription_table;
11
12pub mod pool;
13
14use crate::messages::AgentType;
15use errors::SubscriptionTableError;
16
17pub trait SubscriptionTable {
18    fn for_each<F>(&self, f: F)
19    where
20        F: FnMut(&AgentType, u64, &[u64], &[u64]);
21
22    fn add_subscription(
23        &self,
24        agent_type: AgentType,
25        agent_id: Option<u64>,
26        conn: u64,
27        is_local: bool,
28    ) -> Result<(), SubscriptionTableError>;
29
30    fn remove_subscription(
31        &self,
32        agent_type: AgentType,
33        agent_id: Option<u64>,
34        conn: u64,
35        is_local: bool,
36    ) -> Result<(), SubscriptionTableError>;
37
38    fn remove_connection(&self, conn: u64, is_local: bool) -> Result<(), SubscriptionTableError>;
39
40    fn match_one(
41        &self,
42        agent_type: AgentType,
43        agent_id: Option<u64>,
44        incoming_conn: u64,
45    ) -> Result<u64, SubscriptionTableError>;
46
47    fn match_all(
48        &self,
49        agent_type: AgentType,
50        agent_id: Option<u64>,
51        incoming_conn: u64,
52    ) -> Result<Vec<u64>, SubscriptionTableError>;
53}