Skip to main content
The Bun adapter uses Bun’s built-in bun:ffi module to call the Zinc C ABI directly. No native addon compilation is needed. Bun loads libzinc_core at runtime through its FFI layer.

Installation

Requires Bun 1.0 or later.

SharedRegion

create

Creates a new region. Throws on failure.

open

Opens an existing region.

buffer

Returns a Buffer backed by the shared memory mapping. Uses bun:ffi’s toBuffer function for zero-copy access.

notify

wait

Returns true on notification, false on timeout.

close

The region also supports Symbol.dispose for using statements:

Complete example

FFI details

The adapter defines FFI signatures for the 7 C ABI functions. Handles are represented as BigInt (64-bit pointers) in Bun’s FFI type system. The zinc_ptr function returns a pointer that toBuffer wraps into a Buffer without copying. The library path is resolved relative to the adapter’s installation directory. If the library is not found, ensure libzinc_core.{so,dylib,dll} is on the standard library path.