> ## Documentation Index
> Fetch the complete documentation index at: https://zinc.ossl.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Deno Adapter

> Use Zinc from Deno with Deno.dlopen

The Deno adapter uses `Deno.dlopen` to load the Zinc shared library. Like the Bun adapter, no native addon is needed. The FFI bindings are defined at runtime in TypeScript.

## Installation

```bash theme={null}
deno add @ossl/zinc
```

Requires Deno 1.33 or later with `--allow-ffi` and `--allow-read` permissions.

## SharedRegion

```typescript theme={null}
import { SharedRegion } from "@ossl/zinc";
```

### create

```typescript theme={null}
const region = SharedRegion.create("my-data", 4096);
```

Creates a new region. Throws on failure.

### open

```typescript theme={null}
const region = SharedRegion.open("my-data");
```

Opens an existing region.

### buffer

Returns a `Uint8Array` backed by the shared memory mapping. Uses `Deno.UnsafePointerView.getArrayBuffer` for zero-copy access.

```typescript theme={null}
const buf = region.buffer();
const view = new DataView(buf.buffer);
view.setFloat32(0, 3.14, true);
```

### notify

```typescript theme={null}
region.notify();
```

### wait

```typescript theme={null}
const ok = region.wait(1000);
```

Returns `true` on notification, `false` on timeout.

### close

```typescript theme={null}
region.close();
```

Supports `Symbol.dispose` for `using` declarations:

```typescript theme={null}
using region = SharedRegion.open("my-data");
const buf = region.buffer();
```

## Complete example

```typescript theme={null}
import { SharedRegion } from "@ossl/zinc";

// Writer
const w = SharedRegion.create("deno-channel", 4096);
const buf = w.buffer();
const view = new DataView(buf.buffer);
view.setFloat64(0, 2.71828, true);
w.notify();

setTimeout(() => w.close(), 5000);

// Reader (separate process)
const r = SharedRegion.open("deno-channel");
if (r.wait(3000)) {
    const data = r.buffer();
    const v = new DataView(data.buffer);
    console.log(v.getFloat64(0, true)); // 2.71828
}
r.close();
```

## Permissions

The adapter requires these Deno permissions:

* `--allow-ffi` to call `Deno.dlopen`
* `--allow-read` to locate the shared library

Without these, the import will fail with a permission error.

## FFI details

The library path is resolved relative to the adapter's Deno module location. The suffix is determined from `Deno.build.os`: `.dylib` on macOS, `.so` on Linux. `windows` is not mapped — Zinc does not support Windows. Pointer values are represented as `Deno.PointerValue` (which is `number | null` on 32-bit and `bigint | null` on 64-bit).
