summary refs log tree commit diff stats
path: root/rocie-macros/src/form/mod.rs
blob: 2719826d0d5daf07b99b47625484b0b21d30f3ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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>,
}