1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
pub mod gateway_dht;
pub mod gateway_transport;
pub mod p2p_gateway;
use crate::{
dht::dht_trait::Dht,
transport::{protocol::TransportCommand, transport_trait::Transport, ConnectionId},
};
use std::{
cell::RefCell,
collections::{HashMap, VecDeque},
rc::Rc,
};
use url::Url;
pub fn url_to_transport_id(url: &Url) -> ConnectionId {
String::from(url.path())
}
pub struct P2pGateway<T: Transport, D: Dht> {
inner_transport: Rc<RefCell<T>>,
inner_dht: D,
identifier: String,
connection_map: HashMap<Url, ConnectionId>,
transport_inbox: VecDeque<TransportCommand>,
}