Skip to content
Main site
v0.13: Async, WebSockets, Debugger & Devlogv0.13.0

RFC 6455 WebSockets (@ws), HTML Templates & Pure-C17 Crypto

@ws live broadcast rooms, auto-XSS html_render templates, traversal-safe web_static, and pure ISO C17 SHA-256 / HMAC-SHA256.

6 min readUpdated: v0.13.0 Reference

Real-Time RFC 6455 WebSockets (@ws)

hadid
@ws("/ws/chat", "Live chat room")
fn on_chat(conn: i32): void {
    ws_send(conn, "HADID_WS_READY");
    while true {
        match ws_recv(conn) {
            Some(msg) => { ws_broadcast($"[chat] {msg}"); }
            None => { break; }
        }
    }
    ws_close(conn);
}

Auto-XSS HTML Templates, Static Files & Crypto

  • html_render(tpl, data_json) auto-escapes {{field}}, supports {{{raw}}}, {{#if}}, and {{#each}}.
  • web_static("/assets", "./public") enforces strict canonical path-traversal checks and sets X-Content-Type-Options: nosniff.
  • Pure ISO C17 crypto primitives: crypto_sha256, crypto_hmac_sha256, crypto_hmac_sha256_b64url, base64url_encode/decode, and crypto_const_eq.