2 releases

Uses new Rust 2024

new 0.1.1 Apr 1, 2025
0.1.0 Apr 1, 2025

#6 in #constraints

MIT license

21KB
516 lines

SARK

Static Asynchronous Rust web frameKit

Overview

SARK is a lightweight, single-threaded asynchronous web framework for Rust, built on top of the monoio runtime. It uses Rust's type system to provide fully static routing with zero dynamic dispatch.

Features

  • Zero dynamic dispatch - fully static routing using Rust's type system
  • No Box<dyn> or trait objects - maximized compiler optimizations
  • Single-threaded async architecture (no Send/Sync constraints)
  • Type-safe request routing and parameter extraction
  • State management via generics
  • Minimal API surface - easy to learn and use
  • Async/await native with AFIT (Async Functions in Traits)

Example

use http::Method;
use sark::{
    app::App,
    server::Server,
    service::Service,
    http::{Request, Response},
    error::Result,
};

struct HelloService;

impl Service for HelloService {
    async fn call(&self, _req: Request, _state: &()) -> Result<Response> {
        let mut resp = Response::ok();
        resp.set_body_str("Hello, World!");
        Ok(resp)
    }
}

fn main() -> Result<()> {
    let app = App::default()
        .route(Method::GET, "/", HelloService);

    let mut runtime = monoio::RuntimeBuilder::<monoio::LegacyDriver>::new()
        .build()
        .unwrap();

    runtime.block_on(async {
        Server::bind("127.0.0.1:3000")
            .serve(&app)
            .await
    })
}

Development Status

SARK is currently in early development and is not yet recommended for production use.

License

MIT

Dependencies

~3–16MB
~136K SLoC