https://github.com/dr-montasir/webio_macros
Procedural macros for the WebIO ultra-low-latency framework.
https://github.com/dr-montasir/webio_macros
framework macro macros rust web
Last synced: 1 day ago
JSON representation
Procedural macros for the WebIO ultra-low-latency framework.
- Host: GitHub
- URL: https://github.com/dr-montasir/webio_macros
- Owner: dr-montasir
- Created: 2026-02-12T21:17:51.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2026-03-23T23:37:49.000Z (3 months ago)
- Last Synced: 2026-03-24T22:36:16.707Z (3 months ago)
- Topics: framework, macro, macros, rust, web
- Language: Rust
- Homepage: https://webio.tech
- Size: 12.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ฆ
webio_macros
**Procedural macros for the WebIO ultra-low-latency framework.**
`webio_macros` provides the high-level attribute sugar for the [WebIO](https://crates.io/crates/webio) ecosystem. Its primary goal is to provide a clean developer experience without introducing any external dependencies or runtime overhead.
## ๐ Installation
Run the following Cargo `command` in your project directory:
```shell
cargo add webio webio_macros
```
Or add `webio` and `webio_macros` as a dependencies in your `Cargo.toml`:
```toml
[dependencies]
webio = "MAJOR.MINOR.PATCH" # Replace with the latest version
webio_macros = "MAJOR.MINOR.PATCH" # Replace with the latest version
```
## ๐ The Entry Point
The flagship macro `#[webio_main]` enables the definition of an application entry point using standard `async fn main()` syntax.
### Why use `#[webio_main]`?
1. **Zero-Dependency Philosophy**: Written using only the built-in `proc_macro` library.
2. **Boilerplate Reduction**: Automatically handles the transition from synchronous OS threads to the WebIO async world.
3. **Turbo Performance**: Wraps code in the `webio::block_on` engine, maintaining **70ยตs - 400ยตs** response times.
## โก High-Speed Templates
WebIO includes a built-in, zero-dependency template engine via the `replace!` and `html!` macros. These perform efficient string transformations during compilation.
### `replace!` & `html!`
The `replace!` macro is a versatile tool for substituting `{{key}}` placeholders in any content. The `html!` macro acts as a semantic alias for web-specific development.
- **Efficiency**: No regex or heavy parsers; uses optimized string replacement.
- **Raw String Support**: Works perfectly with `r#""#` for embedding complex code or HTML.
- **Extensible**: Designed so developers can wrap it in their own `macro_rules!` (e.g., `css!`, `sql!`).
#### Example:
```rust
use webio_macros::{replace, html};
let user = "Ahmed";
// Using the core replace engine
let msg = replace!("Hello {{name}}", name = user);
// Using the semantic HTML alias
let view = html!(r#"
{{name}}"#, name = user);
```
## ๐ Usage
```rust,no_run
use webio::*;
use webio_macros::{webio_main, html};
#[webio_main]
async fn main() {
let mut app = WebIo::new();
app.route(GET, "/", |_, _| async {
let content = html!("
Hello from ๐ฆ
{{name}}!
", name = "WebIO");
Reply::new(StatusCode::Ok)
.header("Content-Type", "text/html; charset=UTF-8")
.body(content)
});
app.run("127.0.0.1", "8080");
}
```
## โ๏ธ License
Licensed under the MIT License. Built for performance.