bip_handshake/message/
complete.rs1use std::net::SocketAddr;
2
3use message::protocol::Protocol;
4use message::extensions::{Extensions};
5
6use bip_util::bt::{InfoHash, PeerId};
7
8pub struct CompleteMessage<S> {
10 prot: Protocol,
11 ext: Extensions,
12 hash: InfoHash,
13 pid: PeerId,
14 addr: SocketAddr,
15 sock: S
16}
17
18impl<S> CompleteMessage<S> {
19 pub fn new(prot: Protocol, ext: Extensions, hash: InfoHash, pid: PeerId, addr: SocketAddr, sock: S) -> CompleteMessage<S> {
21 CompleteMessage{ prot: prot, ext: ext, hash: hash, pid: pid, addr: addr, sock: sock }
22 }
23
24 pub fn protocol(&self) -> &Protocol {
26 &self.prot
27 }
28
29 pub fn extensions(&self) -> &Extensions {
31 &self.ext
32 }
33
34 pub fn hash(&self) -> &InfoHash {
36 &self.hash
37 }
38
39 pub fn peer_id(&self) -> &PeerId {
41 &self.pid
42 }
43
44 pub fn address(&self) -> &SocketAddr {
46 &self.addr
47 }
48
49 pub fn socket(&self) -> &S {
51 &self.sock
52 }
53
54 pub fn into_parts(self) -> (Protocol, Extensions, InfoHash, PeerId, SocketAddr, S) {
56 (self.prot, self.ext, self.hash, self.pid, self.addr, self.sock)
57 }
58}