| Crates.io | html_form_struct_macro |
| lib.rs | html_form_struct_macro |
| version | 0.2.0 |
| created_at | 2026-01-09 06:23:23.826058+00 |
| updated_at | 2026-01-11 18:44:40.207455+00 |
| description | Procedural macros for html_form_struct. |
| homepage | |
| repository | https://github.com/owenthewizard/html_form_struct |
| max_upload_size | |
| id | 2031682 |
| size | 35,010 |
Generate a struct from an HTML form.
<form id="register">
<input type="text" name="username" required />
<input type="password" name="password" required />
<input type="email" name="email" />
<!--
form_struct: type=u32
-->
<input type="number" name="guess" />
</form>
use html_form_struct::form_struct;
#[form_struct("index.html", "form#register")]
// important: derive must come after form_struct
#[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)]
pub struct Registration;
Output:
#[derive(Debug, Clone, Eq, PartialEq, Hash, serde::Serialize, serde::Deserialize)]
pub struct Registration {
pub email: Option<String>,
pub guess: Option<u32>,
pub password: String,
pub username: String,
}
A production example can be found in esp32-wifi-bridge.
This project was created for esp32-wifi-bridge, but may be useful for others.
Obey rustfmt, Rust 2024, and clippy.
Pull requests are always welcome.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed under the terms of both the MIT License and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.