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
58
use std::net::SocketAddr;
use message::protocol::Protocol;
use message::extensions::{Extensions};
use bip_util::bt::{InfoHash, PeerId};
pub struct CompleteMessage<S> {
prot: Protocol,
ext: Extensions,
hash: InfoHash,
pid: PeerId,
addr: SocketAddr,
sock: S
}
impl<S> CompleteMessage<S> {
pub fn new(prot: Protocol, ext: Extensions, hash: InfoHash, pid: PeerId, addr: SocketAddr, sock: S) -> CompleteMessage<S> {
CompleteMessage{ prot: prot, ext: ext, hash: hash, pid: pid, addr: addr, sock: sock }
}
pub fn protocol(&self) -> &Protocol {
&self.prot
}
pub fn extensions(&self) -> &Extensions {
&self.ext
}
pub fn hash(&self) -> &InfoHash {
&self.hash
}
pub fn peer_id(&self) -> &PeerId {
&self.pid
}
pub fn address(&self) -> &SocketAddr {
&self.addr
}
pub fn socket(&self) -> &S {
&self.sock
}
pub fn into_parts(self) -> (Protocol, Extensions, InfoHash, PeerId, SocketAddr, S) {
(self.prot, self.ext, self.hash, self.pid, self.addr, self.sock)
}
}