1use jid::Jid;
2use transport::SslTransport;
3use error::Error;
4
5pub struct ClientBuilder {
6 jid: Jid,
7 host: Option<String>,
8 port: u16,
9}
10
11impl ClientBuilder {
12 pub fn new(jid: Jid) -> ClientBuilder {
13 ClientBuilder {
14 jid: jid,
15 host: None,
16 port: 5222,
17 }
18 }
19
20 pub fn host(mut self, host: String) -> ClientBuilder {
21 self.host = Some(host);
22 self
23 }
24
25 pub fn port(mut self, port: u16) -> ClientBuilder {
26 self.port = port;
27 self
28 }
29
30 pub fn connect(self) -> Result<Client, Error> {
31 let host = &self.host.unwrap_or(self.jid.domain.clone());
32 let transport = SslTransport::connect(host, self.port)?;
33 Ok(Client {
34 jid: self.jid,
35 transport: transport
36 })
37 }
38}
39
40pub struct Client {
41 jid: Jid,
42 transport: SslTransport,
43}
44
45impl Client {
46}