(core): Añade Route, RoutePath y Waypoint

`Route` resuelve URLs sensibles al `Context`/idioma en propiedades de
componentes; `RoutePath` (renombrado desde html/route.rs) es el valor
concreto de ruta + query. `Waypoint` transporta la URL de retorno entre
pantallas de listado/alta/edición vía query string.

Ajusta `Context::route()`, `Redirect` y los componentes que aceptan
rutas para integrarse con el nuevo tipo `Route`.
This commit is contained in:
Manuel Cillero 2026-07-19 22:16:21 +02:00
parent 6f82da220b
commit af548b03c9
25 changed files with 819 additions and 216 deletions

View file

@ -2,6 +2,8 @@ use crate::core::TypeInfo;
use crate::html::maud::{Escaper, Render};
use crate::{AutoDefault, CowStr, builder_fn, trace, util};
use thiserror::Error;
use std::any::Any;
use std::collections::HashMap;
use std::fmt::{self, Write};
@ -37,16 +39,15 @@ impl fmt::Debug for PropsExtra {
// **< PropsError >*********************************************************************************
/// Errores de acceso a valores extra de [`Props`].
///
/// - [`PropsError::ExtraNotFound`]: la clave no existe. Incluye la clave (`key`).
/// - [`PropsError::ExtraTypeMismatch`]: la clave existe pero el tipo solicitado no coincide con el
/// almacenado. Incluye la clave (`key`), tipo esperado (`expected`) y tipo realmente encontrado
/// (`found`) para facilitar el diagnóstico.
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq, Error)]
pub enum PropsError {
ExtraNotFound {
key: &'static str,
},
/// La clave no existe. Incluye la clave (`key`).
#[error("extra \"{key}\" not found")]
ExtraNotFound { key: &'static str },
/// La clave existe pero el tipo solicitado no coincide con el almacenado. Incluye la clave
/// (`key`), tipo esperado (`expected`) y tipo realmente encontrado (`found`) para facilitar el
/// diagnóstico.
#[error("type mismatch for extra \"{key}\": expected \"{expected}\", found \"{found}\"")]
ExtraTypeMismatch {
key: &'static str,
expected: &'static str,
@ -54,24 +55,6 @@ pub enum PropsError {
},
}
impl fmt::Display for PropsError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
PropsError::ExtraNotFound { key } => write!(f, "extra \"{key}\" not found"),
PropsError::ExtraTypeMismatch {
key,
expected,
found,
} => write!(
f,
"type mismatch for extra \"{key}\": expected \"{expected}\", found \"{found}\""
),
}
}
}
impl std::error::Error for PropsError {}
// **< PropsOp >************************************************************************************
/// Operaciones sobre el identificador, clases CSS, atributos HTML y valores extra en [`Props`].