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
59
60
61
62
63
64
65
66
67
68
69
use rxqlite::RSQliteClientTlsConfig;

#[derive(Debug, Clone)]
pub struct RXQLiteConnectOptions {
    pub(crate) inner: rxqlite::ConnectOptions,
}

impl RXQLiteConnectOptions {
  pub fn leader_id(mut self, leader_id: u64) -> Self {
    self.inner.leader_id = leader_id;
    self
  }
  pub fn host(mut self, host: &str) -> Self {
    self.inner.leader_host = host.to_owned();
    self
  }
  pub fn port(mut self, port: u16) -> Self {  
    self.inner.leader_port = port;
    self
  }
  
  /*
  pub fn user(mut self, user: Option<String>) -> Self {  
    self.inner.user = user;
    self
  }
  pub fn password(mut self, pwd: Option<String>) -> Self {  
    self.inner.pass = pwd;
    self
  }
  */
  pub fn use_ssl(mut self, use_ssl: bool) -> Self {  
    if use_ssl {
      //rxqlite::Scheme::HTTPS
      self.inner.tls_config = Some(Default::default());
      self.inner.tls_config.as_mut().unwrap().accept_invalid_certificates = false;
    } else {
      self.inner.tls_config = None;
    }
    self
  }
  pub fn use_insecure_ssl(mut self, use_insecure_ssl: bool) -> Self {
    if self.inner.tls_config.is_none() {
      self.inner.tls_config = Some(Default::default());
    }
    if use_insecure_ssl {
      //self.inner.scheme = rxqlite::Scheme::HTTPS;
      self.inner.tls_config.as_mut().unwrap().accept_invalid_certificates = true;
    } else {
      self.inner.tls_config.as_mut().unwrap().accept_invalid_certificates = false;
      //self.inner.scheme = rxqlite::Scheme::HTTP;
    }
    self
  }
  pub fn add_cert_path(mut self, cert_path: String) -> Self {
    if self.inner.tls_config.is_none() {
      self.inner.tls_config = Some(Default::default());
    }
    self.inner.tls_config.as_mut().unwrap().cert_paths.push(cert_path);
    self
  }
  pub fn tls_config(mut self, tls_config: Option<RSQliteClientTlsConfig>) -> Self {
    self.inner.tls_config =  tls_config;
    self
  }
}

pub mod connect;
mod parse;