feat(axum): parse typed interaction values

Add InteractionForm::parse for common typed field extraction and use it in example interaction handlers to avoid repeated string parsing plumbing.

req: form/004

req: dx/003

req: examples/003
This commit is contained in:
slhx agent
2026-06-02 00:31:32 +02:00
parent a462e7f097
commit 1e53a6f7df
4 changed files with 33 additions and 11 deletions
+7
View File
@@ -243,6 +243,13 @@ impl InteractionForm {
.find_map(|(field, value)| (field == name).then_some(value.as_str()))
}
pub fn parse<T>(&self, name: &str) -> Option<T>
where
T: std::str::FromStr,
{
self.value(name).and_then(|value| value.parse().ok())
}
pub fn values<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a str> + 'a {
self.fields
.iter()