pub trait ConfigSource:
Send
+ Sync
+ 'static {
// Required methods
fn name(&self) -> &str;
fn load(&self) -> BoxFuture<Result<HashMap<String, String>, String>>;
}Expand description
Where configuration comes from: environment, a file, a database, a vault, a license server.
Keys are lower case and dotted, such as db.url.
ⓘ
struct VaultSource { client: MyVaultClient }
impl ConfigSource for VaultSource {
fn name(&self) -> &str { "vault" }
fn load(&self) -> BoxFuture<std::result::Result<HashMap<String, String>, String>> {
let client = self.client.clone();
Box::pin(async move { client.read("secret/app").await.map_err(|e| e.to_string()) })
}
}Required Methods§
fn name(&self) -> &str
fn load(&self) -> BoxFuture<Result<HashMap<String, String>, String>>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".