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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
mod local_direct;
mod simulator;
mod udp;
mod blackhole;
pub use self::udp::*;
pub use self::simulator::Simulator;
pub use self::local_direct::LocalDirect;
pub use self::blackhole::Blackhole;
pub use super::transmitter::{Transmitter, DynamicDispatchTransmitter};
use network::*;
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub enum TransportAddress{
Blackhole,
Simulator,
Local,
UDP(TransportAddressUDP),
UDT,
WebRTP,
SCMP,
Bluetooth,
ShamefulTCP
}
pub trait Transport {
fn make_transmitter( &self, args: &TransmitterArgs ) -> Option<Transmitter>;
fn is_local ( &self ) -> bool;
fn bind_network ( &self, &Network );
fn unbind_network ( &self, &Network );
fn get_return_address ( &self, &TransportAddress ) -> Option<TransportAddress>;
}
impl TransportAddress {
pub fn to_string (&self) -> String {
use self::TransportAddress::*;
match self {
&Simulator => "Simulator".to_string(),
&Local => "Local".to_string(),
&UDP(ref a) => a.to_string(),
_ => "UNKNOWN".to_string(),
}
}
pub fn is_local (&self) -> bool {
match self {
&TransportAddress::Local => true,
&TransportAddress::Simulator => true,
_ => false
}
}
}