Rust library guide
The one crate Rust apps add is reyin. It re-exports the public types and wires the concrete drivers and transports into reyin-core, and it provides a blocking facade for simple programs.
Add the dependency
Section titled “Add the dependency”cargo add reyinMost features are default. The default set is formats, usb, bluetooth, tcp,
drivers-all, pdf, render, templates, qr and blocking. Opt-in features: ipp-server,
sync, hub, hub-postgres, sim and pdf-worker (builds the PDF worker; the caller
still installs reyin::pdf::worker::WorkerBackend).
Re-exports
Section titled “Re-exports”pub use reyin_model::*;pub use reyin_core::{Manager, ManagerBuilder, Printer, Job, JobInfo, PrinterInfo, SubmitRequest};pub use reyin_qr as qr;pub use reyin_templates as templates;pub use reyin_render as render;pub use reyin_ipp as ipp; // feature ipp-serverpub use reyin_sync as sync; // feature sync
pub fn manager() -> ManagerBuilder;pub struct Drivers; // Drivers::all()pub struct Transports; // Transports::all()Async API
Section titled “Async API”Build a Manager through ManagerBuilder, register drivers and transports, then use the async Manager/Printer/Job API from reyin-core. The simulator provider is the usual choice for tests and examples.
let device = reyin::sim::SimDevice::new(reyin::sim::Emulator::Zpl, "zebra-zd421-203", "example");let provider = reyin::sim::SimProvider::new();provider.add(device.clone());let mut builder = reyin::Manager::builder() .data_dir(&data_dir) .transport(std::sync::Arc::new(provider));for driver in reyin::Drivers::all() { builder = builder.driver(driver); }let manager = builder.build().await?;Blocking API
Section titled “Blocking API”reyin::blocking owns a current-thread Tokio runtime on a dedicated worker. Callers just call methods; they block until the operation finishes.
let manager = reyin::blocking::Manager::from_builder(builder)?;let printers = manager.discover(Duration::from_millis(100))?;let printer = manager.printer(&printers[0].id)?;printer.print(document, print_options)?; // waits until doneprinter.submit(document, print_options)?; // returns a JobId at onceprinter.status()?;printer.capabilities()?;printer.apply_settings(&print_options)?;printer.calibrate()?;printer.identify()?;printer.set_media(roll, media_profile)?;manager.job_info(&job_id)?;manager.jobs(job_filter)?;manager.job_cancel(&job_id)?;manager.job_resume(&job_id, resume_from)?;manager.job_hold(&job_id)?;manager.job_release(&job_id)?;Example
Section titled “Example”crates/reyin/examples/sim-print.rs is a complete runnable example. Run it with:
cargo run -p reyin --example sim-print --features "sim blocking drivers-zpl"Batch printing in process
Section titled “Batch printing in process”With the feature batch, reyin::batch::BatchService plans, starts and controls a batch over a built engine, and with blocking too reyin::blocking::BlockingBatchService does the same on the manager’s worker. A start is idempotent per key, a restart brings batches back paused, and every plan is unattended unless the host passes a person’s start (see the crate page). The example compiles as a doctest of the type.
let svc = manager.batch_service(reyin::batch::Settings::default())?;let plan = svc.plan(spec)?;if plan.preview().startable { let started = svc.start_plan(plan, "labels-2026-11", reyin::batch::StartMode::Immediate)?; println!("{}", svc.status(&started.id)?.state);}svc.shutdown()?;Where each surface lives
Section titled “Where each surface lives”- Labels, templates, QR, render, IPP and sync are re-exported modules; read the crate docs under docs/crates for each.
- For a daemon/service use reyind and its docs (daemon.md).
- For bindings use bindings.md.
Async rule
Section titled “Async rule”Async library code never calls block_on. Only the blocking facade may drive its own runtime on a dedicated worker; do not call the blocking facade from inside a Tokio worker thread.
Source: docs/guides/rust-library.md at fe2ada6890.