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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//! Configuration system for RDAPify.
//!
//! Loads [`RdapifyConfig`] from a TOML file and environment variables,
//! applies safe defaults for missing fields, and validates all values
//! before returning.
//!
//! # Quick start
//!
//! ```rust,no_run
//! use rdap_config::load_config;
//!
//! let config = load_config(None).expect("valid config");
//! println!("Timeout: {}s", config.rdap.timeout_seconds);
//! println!("Log level: {:?}", config.logging.level);
//! println!("Server: {}:{}", config.server.host, config.server.port);
//! ```
//!
//! # Config file search order
//!
//! | Priority | Source |
//! |----------|-------------------------------|
//! | 1 | `--config <path>` CLI flag |
//! | 2 | `$RDAPIFY_CONFIG` |
//! | 3 | `./rdapify.toml` |
//! | 4 | `~/.rdapify/rdapify.toml` |
//! | 5 | `/etc/rdapify/rdapify.toml` |
//!
//! If no file is found, all-default configuration is used without error.
//!
//! # Environment variable overrides
//!
//! | Variable | Config field |
//! |------------------------|------------------------|
//! | `RDAPIFY_RDAP_TIMEOUT` | `rdap.timeout_seconds` |
//! | `RDAPIFY_CACHE_TYPE` | `cache.type` |
//! | `RDAPIFY_SQLITE_PATH` | `sqlite.path` |
//! | `RDAPIFY_LICENSE_PATH` | `license.path` |
//! | `RDAPIFY_LOG_LEVEL` | `logging.level` |
//! | `RDAPIFY_LOG_FORMAT` | `logging.format` |
//! | `RDAPIFY_METRICS_PORT` | `metrics.port` |
//! | `RDAPIFY_SERVER_PORT` | `server.port` |
pub use ;
pub use ;
use Error;
/// Errors produced by the configuration system.
/// Convenience `Result` alias for this crate.
pub type Result<T> = Result;