feat(axum): register checked handles

Add HandlerRegistry::register_handle for generated Handle<T> values and migrate examples away from passing raw numeric handle ids at registration sites.

req: ceremony/004

req: public_api/001
This commit is contained in:
slhx agent
2026-05-26 00:26:42 +02:00
parent 4803d681d2
commit bc8534a768
5 changed files with 34 additions and 21 deletions
+4 -4
View File
@@ -146,7 +146,7 @@ async fn events(Query(params): Query<BTreeMap<String, String>>) -> impl IntoResp
fn registry(state: Arc<AppState>) -> HandlerRegistry {
HandlerRegistry::new(ui::BUILD_FINGERPRINT)
.register(ui::board::handles::create_card.id().id, {
.register_handle(ui::board::handles::create_card, {
let state = state.clone();
move |form| {
// req: examples/001 req: form/002
@@ -161,7 +161,7 @@ fn registry(state: Arc<AppState>) -> HandlerRegistry {
board_effects(&board, "Card added")
}
})
.register(ui::board::handles::move_left.id().id, {
.register_handle(ui::board::handles::move_left, {
let state = state.clone();
move |form| {
// req: examples/001 req: list/003
@@ -172,7 +172,7 @@ fn registry(state: Arc<AppState>) -> HandlerRegistry {
board_effects(&board, if moved { "Card moved left" } else { "Card not found" })
}
})
.register(ui::board::handles::move_right.id().id, {
.register_handle(ui::board::handles::move_right, {
let state = state.clone();
move |form| {
// req: examples/001 req: list/003
@@ -183,7 +183,7 @@ fn registry(state: Arc<AppState>) -> HandlerRegistry {
board_effects(&board, if moved { "Card moved right" } else { "Card not found" })
}
})
.register(ui::board::handles::delete_card.id().id, {
.register_handle(ui::board::handles::delete_card, {
let state = state.clone();
move |form| {
// req: examples/001 req: list/003
+7 -7
View File
@@ -278,7 +278,7 @@ async fn events(Query(params): Query<BTreeMap<String, String>>) -> impl IntoResp
fn registry(shared: Arc<Shared>) -> HandlerRegistry {
HandlerRegistry::new(ui::BUILD_FINGERPRINT)
.register(ui::control_center::handles::launch_work.id().id, {
.register_handle(ui::control_center::handles::launch_work, {
let shared = shared.clone();
move |form| {
// req: form/002 req: examples/001
@@ -297,7 +297,7 @@ fn registry(shared: Arc<Shared>) -> HandlerRegistry {
demo_effects(&demo, "Launch accepted · 4 targets updated")
}
})
.register(ui::control_center::handles::advance_work.id().id, {
.register_handle(ui::control_center::handles::advance_work, {
let shared = shared.clone();
move |form| {
// req: list/003 req: examples/001
@@ -315,7 +315,7 @@ fn registry(shared: Arc<Shared>) -> HandlerRegistry {
demo_effects(&demo, "Pipeline advanced")
}
})
.register(ui::control_center::handles::move_to_lane.id().id, {
.register_handle(ui::control_center::handles::move_to_lane, {
let shared = shared.clone();
move |form| {
// req: list/003 req: examples/001
@@ -337,7 +337,7 @@ fn registry(shared: Arc<Shared>) -> HandlerRegistry {
demo_effects(&demo, "Drag-and-drop move persisted")
}
})
.register(ui::control_center::handles::delete_work.id().id, {
.register_handle(ui::control_center::handles::delete_work, {
let shared = shared.clone();
move |form| {
// req: list/003 req: examples/001
@@ -356,7 +356,7 @@ fn registry(shared: Arc<Shared>) -> HandlerRegistry {
demo_effects(&demo, "Card removed")
}
})
.register(ui::control_center::handles::spotlight_work.id().id, {
.register_handle(ui::control_center::handles::spotlight_work, {
let shared = shared.clone();
move |form| {
// req: examples/001
@@ -371,7 +371,7 @@ fn registry(shared: Arc<Shared>) -> HandlerRegistry {
demo_effects(&demo, "Inspector focused")
}
})
.register(ui::control_center::handles::simulate_push.id().id, {
.register_handle(ui::control_center::handles::simulate_push, {
let shared = shared.clone();
move |_| {
// req: push/003 req: examples/001
@@ -384,7 +384,7 @@ fn registry(shared: Arc<Shared>) -> HandlerRegistry {
)
}
})
.register(ui::control_center::handles::reset_demo.id().id, {
.register_handle(ui::control_center::handles::reset_demo, {
let shared = shared.clone();
move |_| {
// req: examples/001
+5 -5
View File
@@ -116,7 +116,7 @@ async fn events(Query(params): Query<BTreeMap<String, String>>) -> impl IntoResp
fn registry(state: Arc<ExampleState>) -> HandlerRegistry {
HandlerRegistry::new(ui::BUILD_FINGERPRINT)
.register(ui::counter::handles::increment.id().id, {
.register_handle(ui::counter::handles::increment, {
let state = state.clone();
move |_| {
// req: examples/001
@@ -125,7 +125,7 @@ fn registry(state: Arc<ExampleState>) -> HandlerRegistry {
ui::counter::slots::counter_value.text(*counter)
}
})
.register(ui::todos::handles::add_todo.id().id, {
.register_handle(ui::todos::handles::add_todo, {
let state = state.clone();
move |form| {
// req: examples/001
@@ -141,7 +141,7 @@ fn registry(state: Arc<ExampleState>) -> HandlerRegistry {
)
}
})
.register(ui::wizard::handles::next_step.id().id, {
.register_handle(ui::wizard::handles::next_step, {
let state = state.clone();
move |_| {
// req: examples/001
@@ -150,7 +150,7 @@ fn registry(state: Arc<ExampleState>) -> HandlerRegistry {
ui::wizard::slots::wizard_step.text(format!("Step {}", *step + 1))
}
})
.register(ui::auth::handles::login.id().id, |form| {
.register_handle(ui::auth::handles::login, |form| {
// req: examples/001
let ok = form.value("email") == Some("demo@example.com")
&& form.value("password").is_some_and(|password| !password.is_empty());
@@ -160,7 +160,7 @@ fn registry(state: Arc<ExampleState>) -> HandlerRegistry {
"Try demo@example.com with any password"
})
})
.register(ui::page_swap::handles::load_docs.id().id, |_| {
.register_handle(ui::page_swap::handles::load_docs, |_| {
// req: page_swap/002, req: examples/001
(
ui::page_swap::slots::content.html(render_docs_content(