- Nuevo atributo `#[settings]`: valores por defecto en los campos (tipos comprobados al compilar y documentados); claves desconocidas y valores no válidos rechazados. Sustituye a `include_config!`, que se elimina. - `LazySettings<T>::new()` declara los ajustes de una sección, y `Extension::settings()` los carga al arrancar, en orden; un error de configuración o una sección reclamada dos veces detiene el arranque. - Aviso de secciones que no corresponden a ninguna extensión. - Bootsier: [dev] bootsier_static_dir pasa a [bootsier] static_dir.
25 lines
750 B
Rust
25 lines
750 B
Rust
use pagetop::prelude::*;
|
|
|
|
// Settings that claim `[app]`, a section that already belongs to the global settings.
|
|
#[settings(section = "app")]
|
|
pub struct ClashingSettings {
|
|
pub name: String,
|
|
}
|
|
|
|
static SETTINGS: LazySettings<ClashingSettings> = LazySettings::new();
|
|
|
|
// `EXTENSIONS` is a global `OnceLock`, so this test needs its own test binary.
|
|
struct ClashingExtension;
|
|
|
|
#[async_trait]
|
|
impl Extension for ClashingExtension {
|
|
fn settings(&self) -> Option<&'static dyn LoadSettings> {
|
|
Some(&SETTINGS)
|
|
}
|
|
}
|
|
|
|
#[pagetop::test]
|
|
#[should_panic(expected = "Settings section [app] is claimed by more than one extension")]
|
|
async fn a_section_claimed_twice_stops_the_startup() {
|
|
let _ = Application::prepare(&ClashingExtension).await;
|
|
}
|