| Crates.io | quickform |
| lib.rs | quickform |
| version | 0.1.0 |
| created_at | 2024-12-15 05:22:14.919171+00 |
| updated_at | 2024-12-15 05:22:14.919171+00 |
| description | A flexible templating and operation execution framework for Rust |
| homepage | https://github.com/santiagomed/quickform |
| repository | https://github.com/santiagomed/quickform |
| max_upload_size | |
| id | 1483799 |
| size | 56,857 |
QuickForm is a flexible templating and operation execution framework for Rust that provides a type-safe, state-aware system for executing async operations and rendering their results using templates.
Add QuickForm to your Cargo.toml:
[dependencies]
quickform = "0.1.0"
Here's a basic example:
use quickform::App;
// Define some state
#[derive(Clone)]
struct User {
name: String,
age: u32,
}
// Define an async operation
async fn process_user(user: Data<User>) -> String {
format!("Hello, {}!", user.name)
}
// Create and run the app
let app = App::new()
.with_templates("templates/")
.with_state(User {
name: "Alice".to_string(),
age: 30,
})
.render_operation("greet.txt", process_user);
// Execute operations and write results
app.run("output/").await?;
QuickForm provides thread-safe state management through the Data<T> wrapper:
let state = Data::new(User { name: "Alice".to_string() });
// Update state
state.update(|user| user.name = "Bob".to_string()).await;
// Get state value
let user = state.clone_inner().await;
Templates are loaded from disk and rendered using the MiniJinja engine. Templates can access state data and operation results through a context object.
Example template:
Hello, {{ user.name }}!
Your account was created on {{ user.created_at | date }}.
QuickForm supports two types of operations:
Operations can accept up to 4 state parameters and return any serializable type.
For detailed documentation and examples, see the API documentation.
This project is licensed under the MIT License.