1use serde::{Deserialize, Serialize};
2use std::cmp::{max, min};
3
4#[derive(Debug, Serialize, Deserialize, Clone)]
5pub struct ClientConfig {
6 pub uri: String,
8 pub domain: String,
10 pub ca_cert: String,
12 pub client_cert: Option<CertConfig>,
14 pub pool_size: u8,
16}
17
18#[derive(Debug, Serialize, Deserialize, Clone)]
19pub struct CertConfig {
20 pub cert: String,
22 pub sk: String,
24}
25
26impl ClientConfig {
27 pub fn new(
28 uri: &str,
29 domain: &str,
30 ca_cert: &str,
31 client_cert: Option<CertConfig>,
32 size: u8,
33 ) -> Self {
34 let pool_size = min(16, max(2, size));
35 Self {
36 uri: uri.to_owned(),
37 domain: domain.to_owned(),
38 ca_cert: ca_cert.to_owned(),
39 client_cert,
40 pool_size,
41 }
42 }
43}
44
45impl CertConfig {
46 pub fn new(cert: &str, sk: &str) -> Self {
47 Self {
48 cert: cert.to_owned(),
49 sk: sk.to_owned(),
50 }
51 }
52}