Skip to main content

load

Function load 

Source
pub async fn load(identifier: &str) -> Result<Config>
Expand description

Load a configuration by identifier.

Routes through the plugin registry: finds a loader that can handle the identifier, loads the raw content, finds a formatter that can parse the content, and returns the parsed Config.

For bare names (e.g., "myapp"), the built-in FileLoader searches standard system paths. For scheme-based identifiers (e.g., "postgres://..."), a DbLoader must be registered via inventory.

ยงExamples

use prefer::load;

#[tokio::main]
async fn main() -> prefer::Result<()> {
    let config = load("myapp").await?;
    let value: String = config.get("some.key")?;
    Ok(())
}