Skip to main content

config

Function config 

Source
pub fn config() -> &'static Config
Expand description

Returns the process-wide config Application::new() already loaded - the same OnceLock-backed idiom larust_orm::pool() uses for the connection pool. Unlike pool(), this panics rather than returning a Result if called before Application::new(): every Larust entry point calls Application::new() as its first line (there’s no analogue to pool()’s “forgot to call connect() later” scenario - nothing before Application::new() could plausibly need config at all), so treating this as a real caller-contract violation (like abort()’s own documented panic for an invalid status code) rather than a Result every call site would need to unwrap anyway is the better fit here.

Shares its name with the unrelated, one-argument larust_support::config(key) (Laravel’s stringly-typed config('app.name')) - a use larust_core::config; alongside use larust_support::config; in the same file is a duplicate-import error. Call this one by its full path (larust_core::config(), as every call site in this codebase already does) rather than importing it bare if a file needs both.