Skip to main content

Crate labelzoom

Crate labelzoom 

Source
Expand description

Official Rust client for the LabelZoom API.

LabelZoom converts barcode labels between printer languages (ZPL, EPL, TSPL, DPL), LabelZoom’s own XML/JSON model, PDF, and raster images. Almost everything the API does happens at one endpoint:

POST https://api.labelzoom.com/api/v2/convert/{sourceFormat}/to/{targetFormat}

Authentication is optional. Without a credential the API serves a free tier: watermarked output, the first label only, a 1 MB request cap, and no multi-page, JSON-target or image-to-image conversion.

use labelzoom::{ConversionOptions, ConvertRequest, LabelZoomClient, SourceFormat, TargetFormat};

let client = LabelZoomClient::new();          // anonymous; this works

let request = ConvertRequest::new(
    SourceFormat::Zpl,
    TargetFormat::Png,
    "^XA^FO20,20^A0N,28^FDHello^FS^XZ",
)
.options(ConversionOptions::new().dpi(300).label_size(4.0, 6.0));

client.convert(&request)?.save("label.png")?;

The behaviour of every LabelZoom SDK is specified in docs/API_CONTRACT.md and checked by the shared fixtures in conformance/, which this crate’s test suite executes.

Structs§

ApiError
A non-2xx response from the LabelZoom API.
ClientBuilder
Configures a LabelZoomClient.
ConversionOptions
The conversion parameters, in the shape the API expects.
ConversionResult
The outcome of a successful conversion.
ConvertRequest
One conversion.
HttpRequest
One outgoing HTTP request.
HttpResponse
One HTTP response, including a non-2xx one.
LabelSize
The media size, in INCHES – not dots, and not millimetres.
LabelZoomClient
Converts labels through the LabelZoom API.
PdfOptions
How a PDF source is read.
Position
The pixel offset of the extracted region. Server default 0,0.
ThreadSleeper
Sleeps for real. The default.
TransportError
The request never got a response: a dial failure, a timeout, a TLS error.
UreqTransport
The bundled blocking backend, behind the default ureq-transport feature.
ValidationError
A request rejected before it left the process.
ZplOptions
ZPL output settings.

Enums§

ApiErrorKind
Which class of API error this is.
ColorMode
How colour is reduced when rasterizing. Server default GRAYSCALE.
Error
Everything a conversion can fail with.
PdfConversionMode
How a PDF source is interpreted. Server default IMAGE.
SourceFormat
The format of the document being converted.
TargetFormat
The format to convert into.
ZplImageCompression
Encoding of images embedded in ZPL output. Server default Z64.

Constants§

API_KEY_ENV_VAR
The environment variable consulted when no credential is configured.
DEFAULT_BASE_URL
The production API host.
VERSION
This crate’s version, as it appears in the User-Agent.

Traits§

Sleeper
Waits between retry attempts.
Transport
Executes HTTP requests on the client’s behalf.