Skip to main content

qualia_peer/
inventory.rs

1//! E20.1 inventory of public networking entry points.
2//!
3//! Every listed call goes through QPR (`qdnf`), not libp2p. Default daemons
4//! omit `libp2p-compat` (E20.2). LIG Swarm remains an explicit feature.
5
6/// One public networking entry. Names match the application-facing surface.
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub struct InventoryEntry {
9    pub name: &'static str,
10    pub path: &'static str,
11}
12
13const ENTRIES: &[InventoryEntry] = &[
14    InventoryEntry {
15        name: "pair",
16        path: "PeerHost::pair",
17    },
18    InventoryEntry {
19        name: "exchange_protected",
20        path: "PeerHost::exchange_protected",
21    },
22    InventoryEntry {
23        name: "announce",
24        path: "NativePeer::announce",
25    },
26    InventoryEntry {
27        name: "send_stream",
28        path: "NativePeer::send_stream",
29    },
30    InventoryEntry {
31        name: "lookup_qsr",
32        path: "NativePeer::lookup_qsr",
33    },
34    InventoryEntry {
35        name: "lookup_qsr_full",
36        path: "NativePeer::lookup_qsr_full",
37    },
38    InventoryEntry {
39        name: "open_session",
40        path: "NativePeer::open_session",
41    },
42    InventoryEntry {
43        name: "handshake_over_fragments",
44        path: "handshake_over_fragments",
45    },
46];
47
48/// Public QPR entry points. None of these import or call libp2p.
49pub fn public_entry_points() -> &'static [InventoryEntry] {
50    ENTRIES
51}
52
53/// This crate does not import `libp2p`.
54pub fn libp2p_imported() -> bool {
55    false
56}
57
58#[cfg(test)]
59mod tests {
60    use super::*;
61
62    #[test]
63    fn inventory_lists_qpr_entry_points() {
64        let names: [&str; 8] = [
65            "pair",
66            "exchange_protected",
67            "announce",
68            "send_stream",
69            "lookup_qsr",
70            "lookup_qsr_full",
71            "open_session",
72            "handshake_over_fragments",
73        ];
74        let listed = public_entry_points();
75        assert_eq!(listed.len(), 8);
76        let mut i = 0usize;
77        while i < names.len() {
78            assert_eq!(listed[i].name, names[i]);
79            i = i.saturating_add(1);
80        }
81        assert!(!libp2p_imported());
82    }
83}