Skip to main content

Crate webio

Crate webio 

Source
Expand description

§📖 Documentation



WebIO

A minimalist, high-performance Rust web framework built with a zero-dependency philosophy for maximum speed and low memory footprint.

github crates.io docs.rs license downloads

§🦅 Overview

WebIO addresses the "Event Loop Freeze" common in traditional asynchronous runtimes. By utilizing OS-level pre-emption, it ensures that heavy mathematical calculations or massive data parses do not block the responsiveness of the server.

§⚙️ Key Technical Specs

  • Zero Dependencies: No tokio, hyper, or serde in the core.
  • Performance: ~50µs – 150µs response latency for cached assets.
  • Memory Safety: O(1) memory complexity for multi-gigabyte streams.
  • Concurrency: Go-inspired multi-threading using native OS threads.

§📚 Philosophy

WebIO provides a fully functional web engine with zero external dependencies. By strictly utilizing the Rust Standard Library, it ensures an ultra-light footprint, rapid compilation, and total memory predictability. This framework is designed for environments where Memory Predictability and Security Auditing are paramount.

§🦀 The “Pure Rust” Commitment

  • No tokio, async-std, or hyper.
  • No serde or heavy middleware bloat.
  • No unsafe code in the executor.
  • Just pure, high-performance Rust.

§🏛️ Architectural Pillars

  • Deterministic Concurrency: Unlike task-stealing executors, WebIO delegates each connection to a dedicated OS thread. This provides true kernel-level isolation for CPU-bound tasks, ensuring that one heavy request cannot starve the global listener.
  • Supply-Chain Security: By strictly avoiding external crates, WebIO is immune to third-party “Supply-Chain Attacks,” malicious updates, and “dependency hell.” The entire codebase remains transparent and fully auditable.
  • No Garbage Collection: Leveraging Rust’s ownership model ensures no unpredictable “GC pauses.” This deterministic memory management provides consistent performance for high-stakes computational and mathematical tasks.
  • Rapid Compilation: The absence of a massive dependency tree results in lightning-fast build times and a minimal binary footprint.

§🛠️ Installation

Include webio in the project:

cargo add webio

Or add webio to the Cargo.toml:

[dependencies]
webio = "MAJOR.MINOR.PATCH" # replace with the actual version

§🚀 Quick Start

WebIO provides a highly flexible routing system. These examples demonstrate the Closure Pattern for rapid development and the Handler Pattern for structured, modular applications.

§🌐 Basic Server Implementation

  1. Closure Pattern

The closure pattern allows for defining logic directly within the route registration. This approach is ideal for maintaining full engine control with minimal boilerplate in smaller projects.

use webio::*;

fn main() {
    let mut app = WebIo::new();

    app.route(GET, "/", |_, _| async {
        Reply::new(StatusCode::Ok)
            .header("Content-Type", "text/plain; charset=UTF-8")
            .body("Hello from 🦅 WebIO!")
    });

    app.run("127.0.0.1", "8080");
}
  1. Handler Pattern

The handler pattern isolates logic into dedicated async functions. This is the recommended approach for production-grade applications to ensure the codebase remains clean and testable.

use webio::*;

// Logic isolated into a dedicated handler function
async fn hello_handler(_req: Req, _params: Params) -> Reply {
    Reply::new(StatusCode::Ok)
            .header("Content-Type", "text/html; charset=UTF-8")
            .body("<h1>Hello from 🦅 WebIO!</h1>")
}

fn main() {
    let mut app = WebIo::new();
    
    // Register the handler by name
    app.route(GET, "/", hello_handler);
    
    app.run("127.0.0.1", "8080");
}

Re-exports§

pub use crate::core::*;
pub use crate::crypto::*;
pub use crate::engine::*;
pub use crate::mime::*;
pub use crate::utils::*;

Modules§

core
WebIO Core Engine
crypto
WebIO Cryptographic Engine
engine
WebIO Orchestration Engine
mime
MIME Module
utils
WebIO Utility & Protocol Engine