
Node Addons in Rust With Napi rs for JavaScript Speed
napi-rs generates a Node-API addon from annotated Rust. Functions become JavaScript functions, async work runs on a thread pool, and TypeScript types come for free.
Close to the metal: memory layout, no_std, unsafe, FFI and the microcontroller on your desk.

napi-rs generates a Node-API addon from annotated Rust. Functions become JavaScript functions, async work runs on a thread pool, and TypeScript types come for free.

PyO3 turns Rust functions and structs into Python modules, and Maturin builds and publishes them as wheels. A hot loop moves to Rust and the rest of the program stays Python.

A good binding is two crates. The sys crate mirrors the C header exactly, and the safe crate hides the pointers behind types that cannot be misused.

Memory must be freed by the allocator that created it. At an FFI boundary that means every allocation travels with a matching free function on the same side.

To expose Rust to C, mark functions extern "C" with a stable name, build a staticlib or cdylib and let cbindgen write the header. The rules are about layout, ownership and panics.

Rust calls C through extern declarations that you write or generate. bindgen reads a header and produces them, leaving you to wrap the unsafe calls in a safe API.

The goal of unsafe code is to contain it. A safe wrapper has a small unsafe core, private fields that protect invariants and an API that cannot be misused from safe code.

A global allocator is a type implementing GlobalAlloc, registered with one attribute. Wrapping the system allocator with atomic counters gives you live memory numbers.

Microcontrollers have kilobytes, not megabytes. Most of the savings come from five profile settings, avoiding the formatting machinery and finding the large symbols with cargo-bloat.

Bevy organizes a game as data and functions. Entities are IDs, components are plain structs and systems are ordinary functions that query for the components they need.

Under systemd a daemon does not fork or write pid files. It stays in the foreground, tells systemd when it is ready and exits cleanly on SIGTERM.

Network tools read bytes off the wire and interpret headers. Rust makes the parsing safe with slices and explicit offsets, and crates handle the platform socket details.
We send one email when a new post is published. No spam.