~janbaudisch/epistula

ref: 6f1e423b618e64ca10741b70712b315fda9e595a epistula/src/env.rs -rw-r--r-- 963 bytes
6f1e423bJan Baudisch builds: use archlinux 1 year, 5 months ago
                                                                                
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
use serde::Deserialize;
use std::net::{IpAddr, Ipv4Addr, SocketAddr};

#[derive(Clone, Deserialize)]
pub struct Config {
    #[serde(default = "default_http_address")]
    pub http_address: SocketAddr,
    #[cfg(unix)]
    pub unix_socket: Option<String>,
    pub smtp_host: String,
    #[serde(default = "default_smtp_port")]
    pub smtp_port: u16,
    #[serde(default = "default_smtp_tls")]
    pub smtp_tls: bool,
    pub smtp_user: String,
    #[serde(default = "default_smtp_password")]
    pub smtp_password: String,
    pub smtp_to: String,
    #[serde(default = "default_smtp_subject")]
    pub smtp_subject: String,
}

fn default_http_address() -> SocketAddr {
    SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 8080)
}

fn default_smtp_port() -> u16 {
    465
}

fn default_smtp_tls() -> bool {
    true
}

fn default_smtp_password() -> String {
    String::from("")
}

fn default_smtp_subject() -> String {
    String::from("New message")
}