summary refs log tree commit diff stats
path: root/rocie-macros/src/form/mod.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-10-05 18:27:05 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-10-05 18:27:05 +0200
commit1fc165f2a5a3b6d77da2cfea2aa05e1db1c73577 (patch)
tree2ea10b7aa960ecfa932b1091a43f101c5668cea8 /rocie-macros/src/form/mod.rs
parentfeat(form): Provide basic form framework (diff)
downloadweb-client-1fc165f2a5a3b6d77da2cfea2aa05e1db1c73577.zip
feat(form): Re-write the form macro as a proc macro
This allows more possibilities.
Diffstat (limited to '')
-rw-r--r--rocie-macros/src/form/mod.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/rocie-macros/src/form/mod.rs b/rocie-macros/src/form/mod.rs
new file mode 100644
index 0000000..2719826
--- /dev/null
+++ b/rocie-macros/src/form/mod.rs
@@ -0,0 +1,37 @@
+use syn::{Expr, Ident, LitStr, Type};
+
+mod parse;
+mod generate;
+
+pub use generate::form_impl;
+
+#[derive(Debug)]
+pub struct ParsedOnSubmit {
+    inputs: Vec<Ident>,
+    block: Expr,
+}
+
+#[derive(Debug)]
+pub enum ParsedChild {
+    Input {
+        name: Ident,
+        rust_type: Type,
+        html_type: LitStr,
+        label: LitStr,
+    },
+    Select {
+        name: Ident,
+        label: LitStr,
+        rust_type: Type,
+        options: SelectOptions,
+    },
+}
+
+#[derive(Debug)]
+pub struct SelectOptions(Vec<(LitStr, Expr)>);
+
+#[derive(Debug)]
+pub struct ParsedInput {
+    on_submit: ParsedOnSubmit,
+    children: Vec<ParsedChild>,
+}