Skip to content

Bindings guide

Three language bindings expose the same Reyin engine API on top of the Rust core: Node.js (npm package), Python (PyPI wheel) and Dart/Flutter (pub package). Each is built from this repository and is prepared-not-published; the crate specs (reyin-node, reyin-python, reyin-dart) are the contract, and the registry checklist lists the owner-only publication steps. No binding claims a physical printer, physical host-backend evidence or a published package; the Dart package implements mobile host bridges, but only simulator/simulator-mode evidence has been recorded.

All three bindings print on the in-process simulator; real transports require the host hardware and remain owner/lab evidence (WP-113). No native binary is committed: each binding builds from source.

Package: bindings/node (CommonJS and native ESM), bundled reyin CLI.

const reyin = require('reyin');
const manager = await reyin.Manager.create({ dataDir: '/tmp/reyin', simulator: true });
const printers = await manager.discover({ timeoutMs: 5000 });
const printer = await manager.printer(printers[0].id);
const job = await printer.submit(
{ bytes: pngBytes, format: 'png' },
{ copies: 1, mediaSize: { width: 50000, length: 30000 } },
);
console.log(await job.wait()); // { state: 'completed', ... }
await manager.close(); // printer/job handles then reject with E_CLOSED

The full documented API also covers events (bounded, lagging events skipped), cancellation, capabilities/status, applySettings/setMedia, renderPreview, qr.fit/qr.toSvg and the Document input variants. PDF is compiled in: macOS/iOS use the CoreGraphics backend, Linux/Windows need the PDFium bundle or REYIN_PDFIUM_PATH (WP-90 release packaging). Python, Node and Dart still render PDFs in-process; their language bindings have no worker option yet. For untrusted PDFs use the daemon or the worker-enabled CLI/C ABI. Binding worker support is tracked as the follow-up package embedders-bindings. TypeScript declarations and tsd checks ship with the package; the npm publication itself is owner-run.

Package: bindings/python (abi3 wheel, CPython 3.10+), typed asyncio and blocking facades.

import asyncio
import reyin
async def main() -> None:
async with await reyin.Manager.create(data_dir="~/.reyin", simulator=True) as manager:
printers = await manager.discover(timeout=5.0)
printer = await manager.printer(printers[0].id)
job = await printer.submit(
reyin.Document.png("label.png"),
reyin.PrintOptions(copies=2, darkness_pct=70),
)
async for event in job.events():
print(event)
print((await job.wait()).state)
asyncio.run(main())

The blocking facade (reyin.sync.Manager) exposes the same operations without an event loop. Typed dataclasses, .pyi stubs and py.typed ship with the wheel and strict mypy passes on the public API; structured QR payloads are under reyin.qr and schema models under reyin.schema. Build the wheel locally with maturin build --release; the package is not published on PyPI and the sdist is workspace-bound (a documented packaging follow-up).

Package: bindings/dart/reyin (Flutter plugin over a curated JSON C ABI), plus the pure-Dart reyin_types data classes.

final reyin = await Reyin.init(
dataDir: tempDir.path,
keyStore: appKeyStore, // the app implements KeyStore
config: const ReyinConfig(simulator: true),
);
final printers = await reyin.discover();
final printer = await reyin.printer(printers.first.id);
final preview = await reyin.renderer.layoutPreview(label, media);
final job = await printer.submit(Document.label(label), const PrintOptions());
await job.wait();
await reyin.dispose();

The package implements the editor contract listed in the Dart spec: discovery, events, jobs and control, settings/media, Renderer.layoutPreview, Templates (check/form/resolve/importTable/builtins), Qr (validate/parse/fit/bestFit/verify/ toSvg/toPng), the local IppServerHandle (setShared), the full SyncClient and the app-provided KeyStore. Android/iOS/macOS host bridges cover BLE, Android USB fd, Classic SPP, NSD registration, permissions and lifecycle; desktop uses the Rust transports. The public API matches reyin-editor’s reyin_fake so the app can swap implementations; physical BLE/USB/SPP evidence and pub.dev publication are owner/lab actions (WP-113, publishing).

  • simulator: true / simulator=True / ReyinConfig(simulator: true) injects the in-process ZPL simulator; omit it for real printers.
  • Dispose/close child handles before the manager. Node rejects with E_CLOSED after close; Python raises reyin.ReyinError; Dart throws ReyinException with a stable E_* code.
  • Event streams are bounded and live-only; lagged events are skipped, and job streams end with a terminal event.
  • See the crate specs for the full API surface, limits and open risks.

Source: docs/guides/bindings.md at fe2ada6890.